No need for that awful java language.
Here in only 30 lines of code is is some Unix Shell and Postgres that
will do what you want. It has been pruned and edited to hide local
system info and the code. The orignal did multiple metadata items at
once and here is on one item. You will need to eye it over in case I
added and error. Try it out on a development machine first. The main
trick of the code is to get a unique metadata_value_id.
Create a file with itemids that you wish to alter. Then following on the
same line add a vertical bar and then metadata content as the second
field. the cut command uses a vertical bar as a field separator.
Create a new metadata items in the GUI and get the metadata id number
edit this number into the variable metaDataCode1 within the code.
( sorry thats so unclean - I always upset purists ) Press go!
-------------------------------------------------------------------------------------
SRC=./srcfile
logFile="./metdataAddLog.txt"
nextValueId=$(psql -A -t -c "select max(metadata_value_id)+1 from
metadatavalue")
metaDataCode1=40
#Clean the source of aberant characters
./cleanText.py $srcFile $cleanedSrc
echo "metadata_value_id start value"
echo $nextValueId > $logFile
# Read each line of the source file containing wanted fields to add to
metadata
# Metadata_value_id is just a sequence number increment with each store.
# record starting number in log in case need to delete all the addtions
while read line
do
itemid=$(echo $line|cut -d"|" -f1)
md1=$(echo $line|cut -d"|" -f2)
echo metadata1: $md1 itemId: $itemid sequenceid: $nextValueId
if [ "$itemid" = "" ]
then
echo "No item number for $sysid" >> $logFile
else
nextValueId=$(psql -A -t -c "select max(metadata_value_id)+1
from metadatavalue")
psql -A -t -c "insert into metadatavalue (metadata_value_id,
item_id, metadata_field_id, text_value, text_lang,confidence) values
($nextValueId, $itemid, $metaDataCode1, '$md1', 'en', -1 )"
nextValueId=$(psql -A -t -c "select max(metadata_value_id)+1 from
metadatavalue")
fi
done < $SRC
On Thu, 2014-03-06 at 11:18 +1300, Andrea Schweer wrote:
> Hi Daniel,
>
> On 05/03/14 05:58, Daniel Garcia Mejia wrote:
> > Thanks for your help but I have a last question. I think that 'Item
> > Template' is useful for my automatic submitter metadata, but it is
> > possible in box 'Value' in Item Template to put some code to return
> > the submitter of item? How I can return in box 'Value' the submitters
> > name for each item that I have in the collection? My repository
> > doesn't have a unique submitter in my collections, we have some
> > different submitters...
>
> The item template can only fill in a fixed value, so it won't work for
> your use case. I think the best option is to write a custom
> non-interactive submission step that fills in the information you're
> after. See here for documentation:
> https://wiki.duraspace.org/display/DSDOC3x/Submission+User+Interface#SubmissionUserInterface-CreatingaNon-InteractiveStep
>
> This will require someone with Java development skills but you will not
> be modifying the core of DSpace. Custom submission steps are nicely
> encapsulated from the rest of DSpace and are usually no problem at all
> to migrate across DSpace versions. Just put your custom class into a
> package-appropriate directory under
> [dspace-src]/dspace/modules/additions/src/main/java and reference it in
> the item-submission.xml configuration file as explained in the official
> documentation at the link above.
>
> cheers,
> Andrea
>
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries. Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
DSpace-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette