[12844] | 1 | #!/usr/bin/perl -w
|
---|
| 2 |
|
---|
| 3 | BEGIN {
|
---|
| 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 |
|
---|
| 10 | use doc;
|
---|
| 11 | use strict;
|
---|
| 12 | # Include John's incremental building API
|
---|
| 13 | use IncrementalBuildUtils;
|
---|
| 14 | use IncrementalDocument;
|
---|
| 15 |
|
---|
| 16 | if (!$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 |
|
---|
| 26 | my $collection = $ARGV[0];
|
---|
| 27 | my $oid = $ARGV[1];
|
---|
| 28 | my $field = $ARGV[2];
|
---|
| 29 | my $action = $ARGV[3];
|
---|
| 30 | my $a_value = $ARGV[4];
|
---|
| 31 | my $b_value = "";
|
---|
| 32 | if ($action eq "REPLACE")
|
---|
| 33 | {
|
---|
| 34 | $b_value = $ARGV[5];
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | # We pass a 1 to force the indexes to be updated too.
|
---|
| 38 | if ($action eq "ADD")
|
---|
| 39 | {
|
---|
[21644] | 40 | &IncrementalBuildUtils::setDocumentMetadata($collection, "gdbm", $oid, $field, "", $a_value, 1);
|
---|
[12844] | 41 | }
|
---|
| 42 | elsif ($action eq "REMOVE")
|
---|
| 43 | {
|
---|
[21644] | 44 | &IncrementalBuildUtils::setDocumentMetadata($collection, "gdbm", $oid, $field, $a_value, "", 1);
|
---|
[12844] | 45 | }
|
---|
| 46 | elsif ($action eq "REPLACE")
|
---|
| 47 | {
|
---|
[21644] | 48 | &IncrementalBuildUtils::setDocumentMetadata($collection, "gdbm", $oid, $field, $a_value, $b_value, 1);
|
---|
[12844] | 49 | }
|
---|
| 50 |
|
---|
| 51 | exit;
|
---|