EPrints Technical Mailing List Archive

Message: #08033


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

Re: [EP-tech] DOI Minting


Hi All,

Since I asked publicly, I think it's only fair that I include my mistakes for anybody who might be thinking of playing with EPrints triggers.

Using the commit trigger caused my Twtitter bot to send out tweets each time an item was updated and caused the DataCite plugin to pile up a load of failed tasks in the indexer.

For those who are as inexperienced as I am with this, I recommend using sensible checks. For DataCite I just check the item is of type "thesis" (for our needs we only want DOI's on theses) and that the DOI field isn't already populated in z_datacitedoi.pl within this bit:

if($c->{datacitedoi}{auto_coin}){
    $c->add_dataset_trigger( "eprint", EP_TRIGGER_AFTER_COMMIT , sub {
        my ( %params ) = @_;

        my $repository = $params{repository};

        return undef if (!defined $repository);

        if (defined $params{dataobj}) {
            my $dataobj = $params{dataobj};
            my $type = $dataobj->get_value( "type" );
            if ($type eq "thesis"){
                my $eprint_id = $dataobj->id;
                $repository->dataset( "event_queue" )->create_dataobj({
                    pluginid => "Event::DataCiteEvent",
                    action ="" "datacite_doi",
                    params => [$dataobj->internal_uri],
                });
          }}

       });
    }

(I've not included the check for the DOI field yet and I know the $type variable isn't necessary, but I was being really careful).

For my Twitter bot I need to add a field to record if a tweet has been sent previously or not and then check this in the twitter script. I suppose you might want to add additional checks to ensure the item isn't a template/new version of an existing item depending on your requirements and what you're using the trigger for.

Otherwise, it's a really useful trigger for those weird cases where you aren't depending on a status change to make things happen. Just be very careful.

Thanks,
James

On Tue, Nov 12, 2019 at 4:48 PM James Kerwin via Eprints-tech <eprints-tech@ecs.soton.ac.uk> wrote:
Thanks everyone, It turns out I had more options than I thought!

I went with Rory in the end. I've been putting off getting to grips with triggers for ages and so this was a good opportunity.

The DataCite plugin works how I want and after a brief ban on my Twitter account, the twitter bot works as I want it to. For some reason, after changing the trigger on the Twitter script it sent LOADS of Tweets so I may need to take another look at it tomorrow.

The important one was DataCite and that's spot on.

As usual, thank you all for the advice.

James

On Tue, Nov 12, 2019 at 1:51 PM Yuri via Eprints-tech <eprints-tech@ecs.soton.ac.uk> wrote:
Maybe write the event directly in the mysql table used for the queue to
mint and tweet?


Il 12/11/19 13:56, Rory McNicholl via Eprints-tech ha scritto:
> Hi James,
>
> yes the trigger is the EP_TRIGGER_STATUS_CHANGE one, so from what you
> say that won't be happening.
>
> I guess options would be
>
> a)  to use a more general trigger like EP_TRIGGER_AFTER_COMMIT and
> then check the status of the item and whether there is already a DOI
> in place etc etc etc... though you may end up with a lot more logic to do?
>
> b) you could enable the action_coin plugin in the z_datacitedoi.pl and
> then go and press the "Coin DOI" button in the UI. I guess that would
> be a drag if you have more than a handful of Theses to process.
>
> Maybe there's a c) out there without any downsides?
>
> Cheers,
>
> Rory
>
> Rory McNicholl
> Team Lead - Research Technologies
> CoSector, University of London
> Senate House
> Malet Street
> London
> WC1E 7HU
>
> t: +44 (0)20 7863 1344
> e: rory.mcnicholl@london.ac.uk
> w: https://eur03.safelinks.protection.outlook.com/?url="">
>
> The University of London is an exempt charity in England and Wales.
> ------------------------------------------------------------------------
> *From:*
eprints-tech-bounces@ecs.soton.ac.uk
> <eprints-tech-bounces@ecs.soton.ac.uk> on behalf of James Kerwin via
> Eprints-tech <eprints-tech@ecs.soton.ac.uk>
> *Sent:* 12 November 2019 12:42
> *To:* eprints-tech@ecs.soton.ac.uk <eprints-tech@ecs.soton.ac.uk>
> *Subject:* [EP-tech] DOI Minting
> Hi All,
>
> I'm currently going through the process of uploading a load of
> digitised theses.
>
> I've managed to write scripts to create the EPrints friendly metadata
> and altered the bin/import script to slurp up a load of XML files and
> do the deposits for me.
>
> I'm having trouble getting the DOIs to mint on deposit (datacite) and
> to get my twitter bot to send tweets upon deposit (my own
> Frankenstein's monster of a script).
>
> Usually these scripts are triggered when an item moves from the review
> to the live archive. The digitised theses items are going straight
> into the live archive which I guess is why they aren't being triggered.
>
> Does anybody have any helpful advice on this?
>
> Thanks,
> James
>
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: https://eur03.safelinks.protection.outlook.com/?url="">
> *** EPrints community wiki:
https://eur03.safelinks.protection.outlook.com/?url="">
> *** EPrints developers Forum:
https://eur03.safelinks.protection.outlook.com/?url="">

*** Options:
http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/
*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/