Changeset 14957 for gsdl/trunk/bin/script/import.pl
- Timestamp:
- 2008-02-12T15:01:48+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/bin/script/import.pl
r14925 r14957 39 39 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugouts"); 40 40 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/classify"); 41 42 if (defined $ENV{'GSDLEXTS'}) { 43 my @extensions = split(/:/,$ENV{'GSDLEXTS'}); 44 foreach my $e (@extensions) { 45 my $ext_prefix = "$ENV{'GSDLHOME'}/ext/$e"; 46 47 unshift (@INC, "$ext_prefix/perllib"); 48 unshift (@INC, "$ext_prefix/perllib/cpan"); 49 } 50 } 41 51 } 52 53 use strict; 54 no strict 'refs'; # allow filehandles to be variables and vice versa 55 no strict 'subs'; # allow barewords (eg STDERR) as function arguments 42 56 43 57 use arcinfo; … … 55 69 56 70 57 use strict;58 no strict 'refs'; # allow filehandles to be variables and vice versa59 no strict 'subs'; # allow barewords (eg STDERR) as function arguments60 61 71 my $oidtype_list = 62 72 [ { 'name' => "hash", … … 69 79 'desc' => "{import.OIDtype.dirname}" } ]; 70 80 71 #** define to use the original GA format or METS format 81 82 # used to control output file format 72 83 my $saveas_list = 73 [ { 'name' => "GA", 74 'desc' => "{import.saveas.GA}" }, 75 { 'name' => "METS", 76 'desc' => "{import.saveas.METS}" } ]; 84 [ { 'name' => "DSpace", 85 'desc' => "{export.saveas.DSpace}" }, 86 { 'name' => "GreenstoneMETS", 87 'desc' => "{export.saveas.GreenstoneMETS}"}, 88 { 'name' => "FedoraMETS", 89 'desc' => "{export.saveas.FedoraMETS}"}, 90 { 'name' => "GA", 91 'desc' => "{export.saveas.GA}"}, 92 { 'name' => "MARCXML", 93 'desc' => "{export.saveas.MARCXML}"} 94 ]; 77 95 78 96 … … 85 103 # modegli: The lowest detail mode this argument is visible at in GLI 86 104 105 my $saveas_argument 106 = { 'name' => "saveas", 107 'desc' => "{import.saveas}", 108 'type' => "enum", 109 'list' => $saveas_list, 110 'deft' => "GA", 111 'reqd' => "no", 112 'modegli' => "3" }; 113 114 87 115 my $arguments = 88 [ { 'name' => "archivedir", 116 [ 117 $saveas_argument, 118 { 'name' => "archivedir", 89 119 'desc' => "{import.archivedir}", 120 'type' => "string", 121 'reqd' => "no", 122 'hiddengli' => "yes" }, 123 { 'name' => "importdir", 124 'desc' => "{import.importdir}", 90 125 'type' => "string", 91 126 'reqd' => "no", … … 124 159 'reqd' => "no", 125 160 'modegli' => "4" }, 126 { 'name' => "importdir",127 'desc' => "{import.importdir}",128 'type' => "string",129 'reqd' => "no",130 'hiddengli' => "yes" },131 161 { 'name' => "incremental", 132 162 'desc' => "{import.incremental}", … … 176 206 'reqd' => "no", 177 207 'hiddengli' => "yes" }, 178 { 'name' => "saveas",179 'desc' => "{import.saveas}",180 'type' => "enum",181 'list' => $saveas_list,182 'deft' => "GA",183 'reqd' => "no",184 'modegli' => "3" },185 208 { 'name' => "sortmeta", 186 209 'desc' => "{import.sortmeta}", … … 245 268 246 269 sub main { 247 my ($verbosity, $importdir, $archivedir, $site, $manifest, $incremental, $keepold, 248 $removeold, $saveas, $version, 249 $gzip, $groupsize, $OIDtype, $OIDmetadata, $debug, 250 $maxdocs, $collection, $configfilename, $collectcfg, $gs_mode, 251 $pluginfo, $sortmeta, $removeprefix, $removesuffix, 252 $archive_info_filename, $statsfile, 253 $archive_info, $processor, $out, $faillog, $collectdir, $gli, $language); 270 # params 271 my ($language, $verbosity, $debug, 272 $importdir, $site, $manifest, $incremental, $keepold, 273 $removeold, $saveas, 274 $OIDtype, $OIDmetadata, 275 $maxdocs, $statsfile, 276 $out, $faillog, $collectdir, $gli, 277 278 $archivedir, 279 $gzip, $groupsize, 280 $sortmeta, $removeprefix, $removesuffix, 281 ); 254 282 255 283 my $xml = 0; 284 285 # other vars 286 my ($configfilename, $collectcfg, $collection, 287 $archive_info_filename, $archive_info, 288 $gs_mode, 289 $processor, $pluginfo); 256 290 257 291 my $service = "import"; … … 261 295 my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options"); 262 296 # Parse returns -1 if something has gone wrong 263 if ($intArgLeftinAfterParsing == -1)297 if ($intArgLeftinAfterParsing == -1) 264 298 { 265 299 &PrintUsage::print_txt_usage($options, "{import.params}"); … … 408 442 } 409 443 else{ 410 if ($saveas !~ /^(GA| METS)$/) {444 if ($saveas !~ /^(GA|.*METS|DSpace|MARCXML)$/) { 411 445 push @$plugout,"GAPlugout"; 412 446 } … … 493 527 494 528 # read the archive information file 495 $archive_info_filename = &util::filename_cat ($archivedir, "archives.inf"); 529 530 # If saveas=DSpace, a "contents" file will be created, otherwise "archives.inf" 531 532 # the plugouts should be doing this!! 533 if ($saveas eq "DSpace"){ 534 $archive_info_filename = &util::filename_cat ($archivedir, "contents"); 535 } elsif ($saveas =~ m/^.*METS$/ || $saveas eq "GA" || $saveas eq "MARC" ) { 536 $archive_info_filename = &util::filename_cat ($archivedir, "archives.inf"); 537 } 538 496 539 $archive_info = new arcinfo (); 497 540 $archive_info->load_info ($archive_info_filename); … … 531 574 } 532 575 576 if ($saveas eq "FedoraMETS") 577 { 578 # This would be better (should?!) be done in Plugout!! 579 580 # create collection "doc obj" for Fedora that contains 581 # collection-level metadata 582 583 my $doc_obj = new doc($configfilename,"nonindexed_doc"); 584 $doc_obj->set_OID("collection"); 585 586 my $col_name = undef; 587 my $col_meta = $collectcfg->{'collectionmeta'}; 588 if (defined $col_meta) 589 { 590 store_collectionmeta($col_meta,"collectionname",$doc_obj); 591 store_collectionmeta($col_meta,"collectioextra",$doc_obj); 592 593 } 594 595 $processor->process($doc_obj); 596 } 597 598 533 599 &plugin::end($pluginfo, $processor); 534 600 … … 538 604 $processor->close_file_output() if $groupsize > 1; 539 605 $processor->close_group_output() if $processor->is_group(); 540 # should we still do this in debug mode?? 541 $archive_info->save_info($archive_info_filename); 606 607 # The following 'if' statement is in the export.pl version of the script, 608 # but not (so far) the import.pl version. Why is this? 609 ## if ($saveas =~ m/^.*METS$/) { 610 # should we still do this in debug mode?? 611 612 $archive_info->save_info($archive_info_filename); 613 ## } 542 614 543 615 # write out import stats
Note:
See TracChangeset
for help on using the changeset viewer.