EPrints Technical Mailing List Archive

Message: #04273


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

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


I'm extending my EPrints repository (EP 3.3.14) to hold multiple dates - so eprint_fields.pl has the following added:


     {
         'name'     => 'dates',
         'type'     => 'compound',
         'multiple' => 1,
         'fields'   => [
             {
                 'sub_name'       => 'date',
                 'type'           => 'date',
                 'min_resolution' => 'year',
             },
             {
                 'sub_name'    => 'type',
                 'type'    => 'set',
                 'options' => [ 'submitted', 'accepted',
                                'published', 'completed', ],
             },
         ],
     },
(and do the database update, and add the various phrases, and restart)

I then run a bit of code to copy from $ep->{date} & $ep->{date_type}
into my new structure:

   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, date_type => $type};
         $eprint->set_value( 'dates', [$new_date] );
       }
       $eprint->commit;
	}
   } );

The problem is that some dates are coming out the system as '2011-02' or '2008' and this is throwing the set_value routine:

   Dates: $VAR1 = {
           'date' => '2009-11-09',
           'date_type' => 'published'
    };
    ERROR:  invalid input syntax for integer:
    "f75237ba80d51376a093ee1a825a42cd" at ../EPrints/DataObj.pm line 294.

 From http://wiki.eprints.org/w/Date_field this should work fine?

Any thoughts?

--

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

http://edina.ac.uk/


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