Sep 24

How-To: Setting up depositor reassignment in ePrints

Category: eprints,today

ePrints is one of those projects that I seem to spend a lot of time doing minor tweaks to and changes to help the Library do their job effectively. This shifts from major projects like Author ID to mundane tasks like refreshing their templates and style to match the marketing departments wishes. One of the things I’ve done recently is setting up ePrints to be able to reassign the depositor field.

In ePrints when an eprint is deposited it is marked against the user who deposited it. This user has the ability to do tasks with the paper until it is submitted for review and it eventually works its way into the repository. When it is in the repository this is the name that is assigned to the document.

Here at USQ we have cases where we have departmental staff in faculties or research centres that deposit papers on the behalf of academics. These might be secretararies or research assistants who handle the initial entry of data into the system, attaching the paper and the other tasks that are required. At the end of this process the library wanted to change the depositor from this user and reassign it to the primary author of the paper. So they needed a way to reassign the depositor. They didn’t want this to occur immediately and wanted to have some control over the reassignment. Initially I built it with a user picker for the depositor to select the new user however the Library requested a generic text field instead that the depositor could use to type the details of the person to which they wished the depositor reassigned.

So the first step in all of this drama is to add a few fields. We ended up with three fields: the first was a field for the depositors to enter the name of the user who the item should be reassigned to, the second was an ItemRef field which linked to the user table to have a representation of the user and the last was a checkbox which controlled if the user of the item is reassigned. The first field is visible to any one in the repository who has an account whilst the last two are visible only to repository staff (e.g. editors or administrators).
So to do this, we need to navigate to /opt/eprints3/archives/[archivename]/cfg/cfg.d/ and add the following:

'name' => 'new_depositor_name',
'type' => 'text'
'name' => 'new_depositor_assignment',
'type' => 'itemref',
'datasetid' => 'user'
'name' => 'new_depositor_update',
'input_style' => 'checkbox',
'type' => 'boolean'

Once we’ve done this, you need to run “/opt/eprints3/bin/epadmin update_database_structure [archivename]” to add the new fields to the database.

The next task we need to do is add this to the eprint workflow so that the fields turn up on the screen. This can be achieve by going to “/opt/eprints3/archives/[archivename]/cfg/workflows/eprint/default.xml” and adding it into one of the stages. I picked the “Notes” stage or tab to put it in, eventually it looked like this:

<stage name="notes">
<component><field ref="new_depositor_name"/></component>
<epc:if test="$STAFF_ONLY = 'TRUE'">
<component><field ref="new_depositor_assignment"/></component>
<component><field ref="new_depositor_update"/></component>

If you don’t have a “notes” stage already, you will need to add a new one to the flow at the top, if you’re using a standard ePrints configuration, it will look similar to this:

<stage ref="type"/>
<stage ref="files"/>
<stage ref="core"/>
<stage ref="subjects"/>
<stage ref="notes"/>

Pretty easy! The next step is to add some translations in “/opt/eprints3/archives/[archivename]/cfg/lang/en/phrases/eprint_fields.xml”. Add these lines before the final line:

<phrase id="eprint_fieldname_new_depositor_name">Reassign Depositor</phrase>
<phrase id="eprint_fieldhelp_new_depositor_name">Enter the details of the depositor to which this ePrint should be assigned. Only people submitting on the behalf of other users should select this option to change the depositor. All reassignments are approved by repository staff.</phrase>
<phrase id="eprint_fieldname_new_depositor_assignment">New Depositor</phrase>
<phrase id="eprint_fieldhelp_new_depositor_assignment">Select the new depositor for this ePrint to reassign them as the depositor. There is no issue if this is set to 0.</phrase>
<phrase id="eprint_fieldname_new_depositor_update">Approve Depositor Reassignment</phrase>
<phrase id="eprint_fieldhelp_new_depositor_update">Ticking this box will trigger the reassignment of this item's depositor to the value specified in the new depositor field.</phrase>

So there is are two phrases for each field, the name and the help text that goes with it. Most of it is pretty self explanatory. The final step in this trip is to alter “/opt/eprints3/archives/usqep3/cfg/cfg.d/” to set it so that it will change the depositor of the item once the tick box is checked.

$c->{set_eprint_automatic_fields} = sub
my( $eprint ) = @_;

# Depositor Reassignment
if( $eprint->get_value( “new_depositor_update” ) eq “TRUE” && $eprint->get_value( “new_depositor_assignment” ) != 0 )
$eprint->set_value( “userid”, $eprint->get_value( “new_depositor_assignment” ) );
$eprint->set_value( “new_depositor_assignment”, “” );
$eprint->set_value( “new_depositor_name”, “” );
$eprint->set_value( “new_depositor_update”, “FALSE” );
# End Depositor Reassignment
my $type = $eprint->get_value( “type” );
if( $type eq “monograph” || $type eq “thesis” )
These nine lines surrounded by Depositor Reassignment is inserted where it is and at this point we’re done. We’ll need to restart the server before we get too far just to ensure that everything takes properly and then we can test it all out.

The workflow at this point is that a user of the system marks down the person they wish to reassign as the depositor. We have an overnight report which runs to email one of our repository editors to notify them of items that are being requested to be transferred. They then view these items and enter the user ID of the user in question into the new depositor field (they can use lookup to validate it) and at this point they need to check the box to actually update the assignment. In ticking the box the the depositor is set to the value of the new depositor field, the reassignment field is blanked, the new depositor field is blanked and the check is cleared.

The most unfriendly aspect of this is finding the user in question. To do so you need to traverse the user search, find the user and then grab their user ID and put it in the field. This is a bit much. We also wanted to have the option to send an ameila but the editors need to be able to customise the email before it is sent and wanted control.

Fortunately the solution to the first problem was to utilise the Itemref custom InputForm Component that I created for the Author ID project. The second was to create a new one that primitively created a “mailto” link with a lot of the details pre-populated. For the latter I might have been able to do it within the workflow language but I felt it was easier to build in Perl.
Before we begin, we’re going to need a few files:

  • The “” file needs to be put in the “/opt/eprints3/perl_lib/EPrints/Plugin/InputForm/Component” directory.
  • The “” file needs to be put in the “/opt/eprints3/perl_lib/EPrints/Plugin/InputForm” directory.
  • The “user” file needs to be put in the “/opt/eprints3/cgi/users/popup/user” directory. The “popup” directory might not exist in your installation and will probably have to be added first.

Once you’ve got these files in place we’re ready to do some more modifications. In the “/opt/eprints3/archives/[archivename]/cfg/workflows/eprint/default.xml” file where we had the following:

<component><field ref="new_depositor_assignment"/></component>

We’re going to change that to the following:

<component type="Field::Itemref"><field ref="new_depositor_assignment" external_lookup_url="{$config{perl_url}}/users/popup/user" external_lookup_params="userid="/></component>

This then tells the system to add a new “Find Entry” button which will popup with the user search window. The user search is limited to repository users so anyone who isn’t authorised will receive a login request form. It also tells ePrints to use the new Itemref InputForm Component to handle this field as well, which is what puts the Find Entry button and handles the other logic.
To add the email option, we add a single line after the above mentioned on to load it up:

<component type="USQ_DepositorEmail" />

Pretty simple changes here so far – this then puts some text with a link up if we need it. The last change we need to make is to include this into our language files. There are a few strings, we’ll just put them into the “/opt/eprints3/archives/[archivename]/cfg/lang/en/phrases/eprint_fields.xml” file we used previously:

<epp:phrase id="Plugin/InputForm/Component/USQ_DepositorEmail:mail_depositors">Click here to populate a new email message to the depositors</phrase>
<epp:phrase id="Plugin/InputForm/Component/USQ_DepositorEmail:email_message_subject">EPrints Depositor Reassignment</phrase>
<epp:phrase id="Plugin/InputForm/Component/USQ_DepositorEmail:email_message_body">Hi <pin name="new_depositor" />,
An item has been deposited on your behalf by <pin name="current_depositor" />.
You can view this item here: <pin name="eprint_url" /></phrase>
<epp:phrase id="Plugin/InputForm/Component/USQ_DepositorEmail:new_depositor_id_unset">New depositor ID is unset. Setting the depositor ID will activate this item.</phrase>
<epp:phrase id="lib/metafield/itemref:find_entry">Find entry</phrase>

All pretty simple, again these lines should be inserted before the line in the file. Once you’ve done this, restart the server again to pick up all of the changes and you should see a user picker interface and a little bit of text you can click to make a quick email message. You can customise the email message by altering the language strings to change what you want to display.

1 comment

1 Comment so far

  1. rebeca December 4th, 2009 3:43 am

    Under the open access philosophy, Redalyc looks forward to contribute to the scientific editorial work produced in and about Iberoamerica, making available for the students and researchers the content of more then 550 magazines from different knowledge areas.

Leave a comment

%d bloggers like this: