EPrints Technical Mailing List Archive

Message: #04837

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

[EP-tech] Re: Updating a compound multiple field

Hi Martin,

I'm not sure I've tested it (I've used an API script to populate compound fields (multilang fields in particular) where values were stored using set_value() in the way you're mentioning), but if it doesn't do so then it's API behaviour would be counter to the other fields' behaviour.

My script was something like that:

use Data::Dumper;
my $ep = EPrints->new();
my $repo = $ep->repository( "myrepo" );
my $ds = $repo->dataset("archive");
my $list = $ds->search;
my $n = $list->count();
my @docs = $list->slice(0, $n);

foreach $d (@docs)
    if ($d->is_set('ml_title'))
        print "item with id " . $d->id . " has ml_title set\n";
    } else {
        if ($d->is_set('title'))
#            print "Updating ml_title for eprint.id = " . $d->id . "\n";
            my $tit = $d->get_value('title');
            my @ml_tit = [ {lang=>'en', text=>$tit}, {lang=>'el', text=>$tit} ];
        #    print Dumper(@ml_tit);
            $d->set_value('ml_title', @ml_tit);

I don't know, this may help you test your case...

On 02/10/2015 05:37 μμ, martin.braendle@id.uzh.ch wrote:


just a short question: Am I assuming correctly if I update a compound multiple field with

$dataobj->set_value( array of hashes )

that the new values overwrite the existing ones and are not appended to the existing values?

E.g. if I want to keep the existing values, I need to read them out first and create a merged array with the new values that I have to write back?



Dr. Martin Brändle
Zentrale Informatik
Universität Zürich
Stampfenbachstr. 73
CH-8006 Zürich

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

George Mamalakis

IT and Security Officer, 
Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),
PhD (Aristotle Univ. of Thessaloniki),
MSc (Imperial College of London)

School of Electrical and Computer Engineering
Aristotle University of Thessaloniki

phone number : +30 (2310) 994379