EPrints Technical Mailing List Archive

Message: #04276


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

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


Hi Ian,

Have you seen https://github.com/eprintsug/datesdatesdates

Regards,

Tim

Timothy Miles-Board
Web & Repositories Development Specialist, University of London Computer Centre
020 7863 1342  |  07742 970 351  | timothy.miles-board@london.ac.uk | @drtjmb
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 Field A.N. <af05v@ecs.soton.ac.uk>
Sent: 28 May 2015 3:21 PM
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] Re: Setting a date (as a sub-field)

>          my $new_date = {date => $date, date_type => $type};


         my $new_date = {date => $date, type => $type};

See if that makes a difference...

--
Adam Field
Business Relationship Manager and Community Lead
EPrints Services
+44 (0)23 8059 8814





On 28 May 2015, at 15:13, Ian Stuart wrote:

> 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.
>
> *** 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/