Changeset 14935 for gsdl/trunk/bin
- Timestamp:
- 2007-12-20T21:55:31+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/bin/script/export.pl
r14925 r14935 50 50 use plugin; 51 51 use plugout; 52 use manifest; 52 53 use util; 53 54 use scriptutil; 54 55 use FileHandle; 55 use gsprintf ;56 use gsprintf 'gsprintf'; 56 57 use printusage; 57 58 use parse2; … … 61 62 [ { 'name' => "hash", 62 63 'desc' => "{import.OIDtype.hash}" }, 64 { 'name' => "assigned", 65 'desc' => "{import.OIDtype.assigned}" }, 63 66 { 'name' => "incremental", 64 67 'desc' => "{import.OIDtype.incremental}" }, 65 { 'name' => "assigned",66 'desc' => "{import.OIDtype.assigned}" },67 68 { 'name' => "dirname", 68 69 'desc' => "{import.OIDtype.dirname}" } ]; … … 72 73 [ { 'name' => "DSpace", 73 74 'desc' => "{export.saveas.DSpace}" }, 74 { 'name' => "METS", 75 'desc' => "{export.saveas.METS}"}, 75 { 'name' => "GreenstoneMETS", 76 'desc' => "{export.saveas.GreenstoneMETS}"}, 77 { 'name' => "FedoraMETS", 78 'desc' => "{export.saveas.FedoraMETS}"}, 76 79 { 'name' => "GA", 77 80 'desc' => "{export.saveas.GA}"}, … … 89 92 # modegli: The lowest detail mode this argument is visible at in GLI 90 93 91 my $saveas_argument = 94 my $saveas_argument = 92 95 { 'name' => "saveas", 93 96 'desc' => "{export.saveas}", … … 102 105 [ 103 106 $saveas_argument, 104 { 'name' => "saveas_version",105 'desc' => "{export.saveas_version}",106 'type' => "string",107 'reqd' => "no",108 'deft' => "greenstone" },109 107 { 'name' => "exportdir", 110 108 'desc' => "{export.exportdir}", … … 128 126 # parsearg left "" as default 129 127 #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"), 130 'reqd' => "no", 128 'deft' => "", 129 'reqd' => "no", 130 'hiddengli' => "yes" }, 131 { 'name' => "manifest", 132 'desc' => "{import.manifest}", 133 'type' => "string", 134 'deft' => "", 135 'reqd' => "no", 131 136 'hiddengli' => "yes" }, 132 137 { 'name' => "listall", … … 145 150 'reqd' => "no", 146 151 'modegli' => "4" }, 152 { 'name' => "incremental", 153 'desc' => "{import.incremental}", 154 'type' => "flag", 155 'hiddengli' => "yes" }, 147 156 { 'name' => "keepold", 148 157 'desc' => "{export.keepold}", 149 158 'type' => "flag", 150 159 'reqd' => "no", 151 160 'hiddengli' => "yes" }, 152 161 { 'name' => "removeold", 153 162 'desc' => "{export.removeold}", … … 207 216 'reqd' => "no", 208 217 'hiddengli' => "no" }, 218 { 'name' => "fedora_namespace", 219 'desc' => "{FedoraMETSPlugout.fedora_namespace}", 220 'type' => "string", 221 'deft' => "greenstone", 222 'reqd' => "no", 223 'hiddengli' => "no" }, 209 224 { 'name' => "mapping_file", 210 225 'desc' => "{MARCXMLPlugout.mapping_file}", … … 244 259 'args' => [ $saveas_argument ] }; 245 260 246 sub gsprintf 261 #sub gsprintf 262 #{ 263 # return &gsprintf::gsprintf(@_); 264 #} 265 266 267 sub store_collectionmeta 247 268 { 248 return &gsprintf::gsprintf(@_); 269 my ($collectionmeta,$field,$doc_obj) = @_; 270 271 my $section = $doc_obj->get_top_section(); 272 273 my $field_hash = $collectionmeta->{$field}; 274 275 foreach my $k (keys %$field_hash) 276 { 277 my $val = $field_hash->{$k}; 278 279 280 ### print STDERR "*** $k = $field_hash->{$k}\n"; 281 282 my $md_label = "ex.$field"; 283 284 285 if ($k =~ m/^\[l=(.*?)\]$/) 286 { 287 288 my $md_suffix = $1; 289 $md_label .= "^$md_suffix"; 290 } 291 292 293 $doc_obj->add_utf8_metadata($section,$md_label, $val); 294 295 if (($md_label eq "ex.collectionname^en") || ($md_label eq "ex.collectionname")) 296 { 297 $doc_obj->add_utf8_metadata($section,"dc.Title", $val); 298 } 299 300 } 249 301 } 250 302 … … 254 306 sub main { 255 307 # params 256 my ($language, $verbosity, $importdir, $exportdir, $site, $keepold, $listall, 257 $removeold, $saveas, $saveas_version, $debug, $OIDtype, $OIDmetadata, 258 $maxdocs, $statsfile, $xsltfile, $mapping_file, $out, $faillog, $gs_mode, $collectcfg, 259 $collectdir, $gli,$xslt_mets,$xslt_txt,$group_marc); 308 my ($language, $verbosity, $debug, 309 $importdir, $manifest, $incremental, $keepold, 310 $exportdir, $site, $listall, 311 $removeold, $saveas, 312 $OIDtype, $OIDmetadata, 313 $out, $faillog, $collectdir, $gli, 314 $gs_mode, $collectcfg, 315 $maxdocs, $statsfile, 316 $mapping_file, 317 $xsltfile, 318 $xslt_mets, $xslt_txt, $fedora_namespace, $group_marc); 319 260 320 my $xml = 0; 261 321 262 322 # other vars 263 my ($configfilename, $collection, $export_info_filename, $export_info, $processor, $pluginfo); 323 my ($configfilename, $collection, 324 $export_info_filename, $export_info, 325 $processor, $pluginfo); 326 264 327 my $service = "export"; 265 328 … … 341 404 eval { 342 405 # get and check the collection name 343 print STDERR "**** site = $site\n";344 406 if (($collection = &colcfg::use_collection($site, $collect_name, $collectdir)) eq "") { 345 407 &PrintUsage::print_txt_usage($options, "{export.params}"); … … 372 434 my $plugins = []; 373 435 my @global_opts = (); 374 436 375 437 # Read in the collection configuration file. 376 438 ($configfilename, $gs_mode) = &colcfg::get_collect_cfg_name($out); 377 439 378 440 if ($gs_mode eq "gs2") { 379 441 $collectcfg = &colcfg::read_collect_cfg ($configfilename); … … 381 443 $collectcfg = &colcfg::read_collection_cfg_xml ($configfilename); 382 444 } 445 446 if (defined $collectcfg->{'importdir'} && $importdir eq "") { 447 $importdir = $collectcfg->{'importdir'}; 448 } 449 if (defined $collectcfg->{'exportdir'} && $exportdir eq "") { 450 $exportdir = $collectcfg->{'exportdir'}; 451 } 452 453 # fill in the default import and export directories if none 454 # were supplied, turn all \ into / and remove trailing / 455 $importdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq ""; 456 $importdir =~ s/[\\\/]+/\//g; 457 $importdir =~ s/\/$//; 458 if (!-e $importdir) { 459 &gsprintf($out, "{import.no_import_dir}\n\n", $importdir); 460 die "\n"; 461 } 462 463 $exportdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "export") if $exportdir eq ""; 464 $exportdir =~ s/[\\\/]+/\//g; 465 $exportdir =~ s/\/$//; 383 466 384 467 if (defined $collectcfg->{'plugin'}) { … … 392 475 $verbosity = 2; # the default 393 476 } 394 }395 if (defined $collectcfg->{'importdir'} && $importdir eq "") {396 $importdir = $collectcfg->{'importdir'};397 }398 if (defined $collectcfg->{'exportdir'} && $exportdir eq "") {399 $exportdir = $collectcfg->{'exportdir'};400 477 } 401 478 … … 476 553 if ($saveas eq "DSpace"){ 477 554 $export_info_filename = &util::filename_cat ($exportdir, "contents"); 478 } elsif ($saveas eq "METS"|| $saveas eq "GA" || $saveas eq "MARC" ) {555 } elsif ($saveas =~ m/^.*METS$/ || $saveas eq "GA" || $saveas eq "MARC" ) { 479 556 $export_info_filename = &util::filename_cat ($exportdir, "export.inf"); 480 557 } … … 488 565 } 489 566 else{ 490 if ($saveas !~ /^(GA| METS|DSpace|MARCXML)$/) {567 if ($saveas !~ /^(GA|.*METS|DSpace|MARCXML)$/) { 491 568 push @$plugout,"GAPlugout"; 492 569 } … … 505 582 push @$plugout,("-output_handle",$out) if (defined $out); 506 583 push @$plugout,("-xslt_file",$xsltfile) if (defined $xsltfile); 507 push @$plugout,("-group") if ($group_marc && $plugout_name =~ /^MARCXMLPlugout$/); 508 push @$plugout,("-mapping_file",$mapping_file) if (defined $mapping_file && $plugout_name =~ /^MARCXMLPlugout$/); 509 push @$plugout,("-saveas_version",$saveas_version) if (defined $saveas_version && $plugout_name =~ /^METSPlugout$/); 510 push @$plugout,("-xslt_mets",$xslt_mets) if (defined $xslt_mets && $plugout_name =~ /^METSPlugout$/); 511 push @$plugout,("-xslt_txt",$xslt_txt) if (defined $xslt_txt && $plugout_name =~ /^METSPlugout$/); 584 push @$plugout,("-group") if ($group_marc && $plugout_name =~ m/^MARCXMLPlugout$/); 585 push @$plugout,("-mapping_file",$mapping_file) if (defined $mapping_file && $plugout_name =~ m/^MARCXMLPlugout$/); 586 push @$plugout,("-xslt_mets",$xslt_mets) if (defined $xslt_mets && $plugout_name =~ m/^.*METSPlugout$/); 587 push @$plugout,("-xslt_txt",$xslt_txt) if (defined $xslt_txt && $plugout_name =~ m/^.*METSPlugout$/); 588 push @$plugout,("-fedora_namespace",$fedora_namespace) if (defined $fedora_namespace && $plugout_name eq "FedoraMETSPlugout"); 589 512 590 $processor = &plugout::load_plugout($plugout); 513 591 … … 521 599 # process the import directory 522 600 &plugin::read ($pluginfo, $importdir, "", {}, $processor, $maxdocs,0, $gli); 601 602 if ($saveas eq "FedoraMETS") 603 { 604 # create collection "doc obj" for Fedora that contains 605 # collection-level metadata 606 607 my $doc_obj = new doc($configfilename,"nonindexed_doc"); 608 $doc_obj->set_OID("collection"); 609 610 my $col_name = undef; 611 my $col_meta = $collectcfg->{'collectionmeta'}; 612 if (defined $col_meta) 613 { 614 store_collectionmeta($col_meta,"collectionname",$doc_obj); 615 store_collectionmeta($col_meta,"collectioextra",$doc_obj); 616 617 } 618 619 $processor->process($doc_obj); 620 } 523 621 524 622 &plugin::end($pluginfo, $processor); … … 529 627 $processor->close_file_output() if $groupsize > 1; 530 628 $processor->close_group_output() if $processor->is_group(); 531 if ($saveas eq "METS") {629 if ($saveas =~ m/^.*METS$/) { 532 630 $export_info->save_info($export_info_filename); 533 631 }
Note:
See TracChangeset
for help on using the changeset viewer.