Changeset 18918
- Timestamp:
- 2009-04-08T14:18:44+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/bin/script/explode_metadata_database.pl
r18590 r18918 82 82 'deft' => "100", 83 83 'reqd' => "no" }, 84 { 'name' => "collection", 85 'desc' => "{explode.collection}", 86 'type' => "string", 87 'reqd' => "no", 88 'hiddengli' => "yes"}, 89 { 'name' => "use_collection_plugin_options", 90 'desc' => "{explode.use_collection_plugin_options}", 91 'type' => "flag", 92 'reqd' => "no", 93 'hiddengli' => "yes"}, 84 94 { 'name' => "plugin_options", 85 95 'desc' => "{explode.plugin_options}", 86 'type' => "string",87 'reqd' => "no",88 'modegli' => "3"},89 { 'name' => "collection",90 'desc' => "{explode.collection}",91 96 'type' => "string", 92 97 'reqd' => "no", … … 115 120 { 116 121 my ($language, $input_encoding, $metadata_set, $plugin, 117 $document_field, $document_prefix, $document_suffix, $records_per_folder, $plugin_options, $collection, $ verbosity);122 $document_field, $document_prefix, $document_suffix, $records_per_folder, $plugin_options, $collection, $use_collection_plugin_options, $verbosity); 118 123 119 124 my $xml = 0; … … 186 191 die "\n"; 187 192 } 188 } 189 193 } else { 194 undef $collection; 195 } 196 197 if ($use_collection_plugin_options) { 198 if (defined $plugin_options && $plugin_options =~ /\w/) { 199 print STDERR "Error: you cannot have -use_collection_plugin_options and -plugin_options set at the same time\n"; 200 die "\n"; 201 } 202 if (not defined $collection) { 203 print STDERR "Error: you must specify a collection using -collection to use -use_collection_plugin_options\n"; 204 die "\n"; 205 } 206 } 190 207 my $plugobj; 191 208 require "$plugin.pm"; 192 209 193 if (defined $plugin_options && $plugin_options =~ /\w/) { 210 my $plugin_options_string = ""; 211 if ($use_collection_plugin_options) { 212 # read in the collect.cfg file 213 # Read in the collection configuration file. 214 my ($configfilename, $gs_mode) = &colcfg::get_collect_cfg_name(STDERR); 215 my $collectcfg; 216 if ($gs_mode eq "gs2") { 217 $collectcfg = &colcfg::read_collect_cfg ($configfilename); 218 } elsif ($gs_mode eq "gs3") { 219 $collectcfg = &colcfg::read_collection_cfg_xml ($configfilename); 220 } 221 $plugin_options_string = &get_plugin_options($collectcfg, $plugin); 222 } 223 elsif (defined $plugin_options && $plugin_options =~ /\w/) { 194 224 my @options = split(/\s/, $plugin_options); 195 225 map { $_ = "\"$_\"" unless $_ =~ /^\"/; } @options; 196 $plugin_options = join (",", @options); 197 eval ("\$plugobj = new $plugin([], [$plugin_options])"); 226 $plugin_options_string= join (",", @options); 227 } 228 229 if ($plugin_options_string eq "") { 230 eval ("\$plugobj = new $plugin()"); 198 231 die "$@" if $@; 199 232 } else { 200 eval ("\$plugobj = new $plugin( )");233 eval ("\$plugobj = new $plugin([], [$plugin_options_string])"); 201 234 die "$@" if $@; 202 } 235 } 236 203 237 # ...and initialize it 204 238 $plugobj->init($verbosity, "STDERR", "STDERR"); … … 558 592 } 559 593 594 sub get_plugin_options { 595 my ($collectcfg, $plugin) = @_; 596 597 my $plugin_list = $collectcfg ->{'plugin'}; 598 599 foreach my $pluginoptions (@$plugin_list) { 600 my $pluginname = shift @$pluginoptions; 601 next unless $pluginname eq $plugin; 602 map { $_ = "\"$_\""; } @$pluginoptions; 603 my $options = join (",", @$pluginoptions); 604 return $options; 605 } 606 return ""; 607 } 608 560 609 &main(@ARGV); 561 610
Note:
See TracChangeset
for help on using the changeset viewer.