source: gsdl/trunk/bin/script/set_metadata.pl@ 19620

Last change on this file since 19620 was 12844, checked in by mdewsnip, 18 years ago

Incremental building and dynamic GDBM updating code, many thanks to John Rowe and John Thompson at DL Consulting Ltd.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1#!/usr/bin/perl -w
2
3BEGIN {
4 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
5 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
6 unshift (@INC, "$ENV{'GSDLHOME'}/bin/script");
7 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
8}
9
10use doc;
11use strict;
12# Include John's incremental building API
13use IncrementalBuildUtils;
14use IncrementalDocument;
15
16if (!$ARGV[0] || !$ARGV[1] || !$ARGV[2] || !$ARGV[3] || !$ARGV[4] || ($ARGV[3] eq "REPLACE" && !$ARGV[5])) {
17 print STDERR "Usage: set_metadata <collection> <oid> <metadata_field> (REPLACE <old_value> <new_value> | (ADD|REMOVE) <value>)\n";
18 print STDERR "[you tried: set_metadata ";
19 foreach my $arg (@$ARGV) {
20 print STDERR $arg . " ";
21 }
22 print STDERR "]\n";
23 exit;
24}
25
26my $collection = $ARGV[0];
27my $oid = $ARGV[1];
28my $field = $ARGV[2];
29my $action = $ARGV[3];
30my $a_value = $ARGV[4];
31my $b_value = "";
32if ($action eq "REPLACE")
33{
34 $b_value = $ARGV[5];
35}
36
37# We pass a 1 to force the indexes to be updated too.
38if ($action eq "ADD")
39{
40 &IncrementalBuildUtils::setDocumentMetadata($collection, $oid, $field, "", $a_value, 1);
41}
42elsif ($action eq "REMOVE")
43{
44 &IncrementalBuildUtils::setDocumentMetadata($collection, $oid, $field, $a_value, "", 1);
45}
46elsif ($action eq "REPLACE")
47{
48 &IncrementalBuildUtils::setDocumentMetadata($collection, $oid, $field, $a_value, $b_value, 1);
49}
50
51exit;
Note: See TracBrowser for help on using the repository browser.