[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] Re: Setting a date (as a sub-field)



On 28/05/15 15:32, Timothy Miles-Board wrote:
> Hi Ian,
>
> Have you seen https://github.com/eprintsug/datesdatesdates

I hadn't... and it's almost identical to what I created

it worked fine for you, yes?


   my $ds = $session->dataset( 'archive' );

   my $list = $ds->search;
   $list->map( sub {
     my( $session, $dataset, $eprint ) = @_;
     my ($date, $type);
     ($date, $type) = ($eprint->value('date'),
                       $eprint->value('date_type'));
     if ($date) {
       my $new_date = {date => $date}; #, dates_type => $type};
   print "Date: $date; Dates: ", Dumper $new_date;
       if ( $date =~ /\d+\-\d+\-\d+/ ) {
   print "Altering the date recording on #".$eprint->id."\n";
         $eprint->set_value( 'dates', [$new_date] );
       }
     }
     $eprint->commit;
           } );


Interestingly..... if I add a "sleep 2" after the commit, the ERRORs 
don't appear for 6 or 7 iterations!

-- 

Ian Stuart.
Developer: ORI, RJ-Broker, and OpenDepot.org
Bibliographics and Multimedia Service Delivery team,
EDINA,
The University of Edinburgh.

http://edina.ac.uk/

This email was sent via the University of Edinburgh.

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.