Changeset 16968
- Timestamp:
- 2008-08-22T15:07:29+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/bin/script/explode_metadata_database.pl
r16790 r16968 15 15 use printusage; 16 16 use parse2; 17 use colcfg; 18 17 19 use FileHandle; 18 20 … … 80 82 'deft' => "100", 81 83 'reqd' => "no" }, 84 { 'name' => "plugin_options", 85 'desc' => "options for the plugin", 86 'type' => "string", 87 'reqd' => "no", 88 'modegli' => "3"}, 89 { 'name' => "collection", 90 'desc' => "collection for file", 91 'type' => "string", 92 'reqd' => "no", 93 'modegli' => "3"}, 82 94 { 'name' => "verbosity", 83 95 'desc' => "{import.verbosity}", … … 103 115 { 104 116 my ($language, $input_encoding, $metadata_set, $plugin, 105 $document_field, $document_prefix, $document_suffix, $records_per_folder, $ verbosity);117 $document_field, $document_prefix, $document_suffix, $records_per_folder, $plugin_options, $collection, $verbosity); 106 118 107 119 my $xml = 0; … … 169 181 $metadata_set = ""; 170 182 } 171 183 if (defined $collection && $collection =~ /\w/) { 184 if (($collection = &colcfg::use_collection("", $collection, "")) eq "") { 185 print STDERR "Collection $collection does not exist\n"; 186 die "\n"; 187 } 188 } 189 172 190 my $plugobj; 173 191 require "$plugin.pm"; 174 eval ("\$plugobj = new $plugin()"); 175 die "$@" if $@; 176 192 193 if (defined $plugin_options && $plugin_options =~ /\w/) { 194 my @options = split(/\s/, $plugin_options); 195 map { $_ = "\"$_\"" unless $_ =~ /^\"/; } @options; 196 $plugin_options = join (",", @options); 197 eval ("\$plugobj = new $plugin([], [$plugin_options])"); 198 die "$@" if $@; 199 } else { 200 eval ("\$plugobj = new $plugin()"); 201 die "$@" if $@; 202 } 177 203 # ...and initialize it 178 $plugobj->init( 1, "STDERR", "STDERR");179 204 $plugobj->init($verbosity, "STDERR", "STDERR"); 205 180 206 if ($input_encoding eq "auto") { 181 207 ($language, $input_encoding) = $plugobj->textcat_get_language_encoding ($filename); 182 } 208 } 183 209 184 210 # Create a directory to store the document files... … … 205 231 # Write the metadata from each record to the metadata.xml file 206 232 my $record_number = 1; 233 my $documents_directory; 207 234 foreach my $record_text (@metadata_records) { 208 235 209 236 # Check if we need to start a new directory for these records 210 my $documents_directory;211 237 check_need_new_directory($exploded_base_dir,$record_number,$records_per_folder, 212 238 \@metadata_records,\$documents_directory); 213 214 239 # Use the plugin's process function to avoid duplicating code 215 240 my $doc_obj = new doc($filename, "nonindexed_doc"); … … 219 244 # Try to get a doc to attach the metadata to 220 245 # If no match found, create a dummy .nul file 221 attach_metadata_or_ nul_doc($document_field, $doc_obj, $record_number,246 attach_metadata_or_make_nul_doc($document_field, $doc_obj, $record_number, 222 247 $documents_directory, $orig_base_dir, 223 248 $document_prefix, $document_suffix, $metadata_set, $verbosity); … … 356 381 $document_file = "doc.nul"; 357 382 } 358 359 383 open(DUMMY_FILE, ">$documents_directory/$document_file"); 360 384 close(DUMMY_FILE);
Note:
See TracChangeset
for help on using the changeset viewer.