EPrints Technical Mailing List Archive

Message: #09197


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] get_all_documents from eprint trigger on commit


CAUTION: This e-mail originated outside the University of Southampton.
Hi All,

I'm doing some work around our rights retention policy. It involves checking if something was deposited before or after the date it comes into effect. Quite a big piece of work for me and I'm happy to share code/workflow etc.

I have a script that is kicked off by an eprint trigger on commit. Is it possible for me to use "get_alldocuments" from this? I was able to do this in a /bin script using:

my $eprintid = 3000633;

my $eprint = $ds->dataobj($eprintid);
my @documents_list  = $eprint->get_all_documents;

foreach my $document (@documents_list) {
$document->set_value('license','cc_by_4');

$document->commit();
}

Carrying this over into a trigger which starts with:

$c->add_dataset_trigger( 'eprint', EP_TRIGGER_AFTER_COMMIT, sub
{
     my( %args ) = @_;

     my( $repo, $eprint, $changes ) = @args{qw( repository dataobj changed )};

I was at it until 3am trying all sorts of different things. Using Data:Dumper to print the content of @documents to the error log, along with some other checkpoints, I can see that the section of code is entered into, but it just moves past @documents without printing anything and gets to the print statement immediately after. The only reasonable conclusion being that it isn't finding any documents. It seems reasonable that as this is an "eprint" trigger I can't access documents, but I know that in a slightly different script I can grab all the documents with only an EPrint ID, which I have here along with the $repo.

Can anybody please tell me if this approach is possible and maybe what I'm doing wrong? (Happy to share the entire script and everything else related to this project whether advice is forthcoming or not). If it isn't possible, my solution would be to push all of the IDs into a file, then have a script that slurps them up and does the "get_all_documents" on them, but that would be a far worse solution in terms of workflow.

Thanks,
James