Changeset 22421 for main/trunk/greenstone2/perllib/inexport.pm
- Timestamp:
- 2010-07-18T16:36:56+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/inexport.pm
r22413 r22421 51 51 { 52 52 my $class = shift (@_); 53 my ($ argv,$options) = @_;54 55 my $self = { 'xml' => 0 };53 my ($mode,$argv,$options,$opt_listall_options) = @_; 54 55 my $self = { 'xml' => 0, 'mode' => $mode }; 56 56 57 57 # general options available to all plugins … … 72 72 } 73 73 74 if ($self->{'listall'}) { 75 if ($self->{'xml'}) { 76 &PrintUsage::print_xml_usage($opt_listall_options); 77 } 78 else 79 { 80 &PrintUsage::print_txt_usage($opt_listall_options,"{export.params}"); 81 } 82 die "\n"; 83 } 84 85 74 86 if ($self->{'xml'}) { 75 87 &PrintUsage::print_xml_usage($options); … … 151 163 152 164 # Read in the collection configuration file. 153 my ($config filename, $gs_mode) = &colcfg::get_collect_cfg_name($out);154 my $collectcfg = &colcfg::read_collection_cfg ($config filename, $gs_mode);155 156 return $collectcfg;165 my ($config_filename, $gs_mode) = &colcfg::get_collect_cfg_name($out); 166 my $collectcfg = &colcfg::read_collection_cfg ($config_filename, $gs_mode); 167 168 return ($config_filename,$collectcfg); 157 169 } 158 170 … … 160 172 { 161 173 my $self = shift @_; 162 my ($inexport_mode,$collectcfg) = @_; 174 my ($collectcfg) = @_; 175 176 my $inexport_mode = $self->{'mode'}; 163 177 164 178 my $verbosity = $self->{'verbosity'}; 165 print STDERR "**** verbosity = $verbosity\n\n\n";166 167 179 my $debug = $self->{'debug'}; 168 180 my $importdir = $self->{'importdir'}; … … 218 230 } 219 231 } 232 $self->{'verbosity'} = $verbosity; 233 220 234 if (defined $collectcfg->{'manifest'} && $self->{'manifest'} eq "") { 221 235 $self->{'manifest'} = $collectcfg->{'manifest'}; … … 235 249 } 236 250 } 237 if ($self->{'groupsize'} == 1) { 251 252 if ((defined $self->{'groupsize'}) && ($self->{'groupsize'} == 1)) { 238 253 if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/) { 239 254 $self->{'groupsize'} = $collectcfg->{'groupsize'}; … … 287 302 288 303 # check keepold and removeold 304 my $checkdir = ($inexport_mode eq "import") ? "archives" : "export"; 305 289 306 my ($removeold, $keepold, $incremental, $incremental_mode) 290 307 = &scriptutil::check_removeold_and_keepold($self->{'removeold'}, $self->{'keepold'}, 291 $self->{'incremental'}, "archives",308 $self->{'incremental'}, $checkdir, 292 309 $collectcfg); 293 310 … … 301 318 { 302 319 my $self = shift @_; 303 my ($inexport_mode,$collectcfg) = @_; 320 my ($config_filename,$collectcfg) = @_; 321 322 my $inexport_mode = $self->{'mode'}; 304 323 305 324 my $verbosity = $self->{'verbosity'}; … … 330 349 my $removesuffix = $self->{'removesuffix'}; 331 350 332 my $gli = $self->{'gli'}; 333 334 print STDERR "<Import>\n" if $gli; 351 my $gli = $self->{'gli'}; 352 353 # related to export 354 my $xsltfile = $self->{'xsltfile'}; 355 my $group_marc = $self->{'group_marc'}; 356 my $mapping_file = $self->{'mapping_file'}; 357 my $xslt_mets = $self->{'xslt_mets'}; 358 my $xslt_txt = $self->{'xslt_txt'}; 359 my $fedora_namespace = $self->{'fedora_namespace'}; 360 361 if ($inexport_mode eq "import") { 362 print STDERR "<Import>\n" if $gli; 363 } 364 else { 365 print STDERR "<export>\n" if $gli; 366 } 335 367 336 368 my $manifest_lookup = new manifest($collectcfg->{'infodbtype'},$archivedir); … … 358 390 #some global options for the plugins 359 391 my @global_opts = (); 360 361 392 362 393 my $pluginfo = &plugin::load_plugins ($plugins, $verbosity, $out, $faillog, \@global_opts, $incremental_mode); … … 403 434 404 435 ####Use Plugout#### 405 my ($plugout); 406 if (defined $collectcfg->{'plugout'}) { 407 # If a plugout was specified in the collect.cfg file, assume it is sensible 408 # We can't check the name because it could be anything, if it is a custom plugout 409 $plugout = $collectcfg->{'plugout'}; 410 } 411 else{ 412 if ($saveas !~ /^(GreenstoneXML|GreenstoneMETS)$/) { 413 push @$plugout,"GreenstoneXMLPlugout"; 436 my $plugout; 437 438 if ($inexport_mode eq "import") { 439 if (defined $collectcfg->{'plugout'}) { 440 # If a plugout was specified in the collect.cfg file, assume it is sensible 441 # We can't check the name because it could be anything, if it is a custom plugout 442 $plugout = $collectcfg->{'plugout'}; 414 443 } 415 444 else{ 416 push @$plugout,$saveas."Plugout"; 417 } 418 } 419 420 push @$plugout,("-output_info",$archive_info) if (defined $archive_info); 421 push @$plugout,("-verbosity",$verbosity) if (defined $verbosity); 422 push @$plugout,("-gzip_output") if ($gzip); 423 push @$plugout,("-group_size",$groupsize) if (defined $groupsize); 424 push @$plugout,("-output_handle",$out) if (defined); 425 push @$plugout,("-debug") if ($debug); 426 445 if ($saveas !~ /^(GreenstoneXML|GreenstoneMETS)$/) { 446 push @$plugout,"GreenstoneXMLPlugout"; 447 } 448 else{ 449 push @$plugout,$saveas."Plugout"; 450 } 451 } 452 } 453 else { 454 if (defined $collectcfg->{'plugout'} && $collectcfg->{'plugout'} =~ /^(.*METS|DSpace|MARCXML)Plugout/) { 455 $plugout = $collectcfg->{'plugout'}; 456 } 457 else{ 458 if ($saveas !~ /^(GreenstoneMETS|FedoraMETS|DSpace|MARCXML)$/) { 459 push @$plugout,"GreenstoneMETSPlugout"; 460 } 461 else{ 462 push @$plugout,$saveas."Plugout"; 463 } 464 } 465 } 466 467 my $plugout_name = $plugout->[0]; 468 469 push @$plugout,("-output_info",$archive_info) if (defined $archive_info); 470 push @$plugout,("-verbosity",$verbosity) if (defined $verbosity); 471 push @$plugout,("-debug") if ($debug); 472 push @$plugout,("-group_size",$groupsize) if (defined $groupsize); 473 push @$plugout,("-gzip_output") if ($gzip); 474 push @$plugout,("-output_handle",$out) if (defined $out); 475 476 push @$plugout,("-xslt_file",$xsltfile) if (defined $xsltfile && $xsltfile ne ""); 477 478 if ($plugout_name =~ m/^MARCXMLPlugout$/) { 479 push @$plugout,("-group") if ($group_marc); 480 push @$plugout,("-mapping_file",$mapping_file) if (defined $mapping_file && $mapping_file ne ""); 481 } 482 if ($plugout_name =~ m/^.*METSPlugout$/) { 483 push @$plugout,("-xslt_mets",$xslt_mets) if (defined $xslt_mets && $xslt_mets ne ""); 484 push @$plugout,("-xslt_txt",$xslt_txt) if (defined $xslt_txt && $xslt_txt ne ""); 485 } 486 487 if ($plugout_name eq "FedoraMETSPlugout") { 488 push @$plugout,("-fedora_namespace",$fedora_namespace) if (defined $fedora_namespace && $fedora_namespace ne ""); 489 } 490 491 427 492 my $processor = &plugout::load_plugout($plugout); 428 493 $processor->setoutputdir ($archivedir); … … 443 508 &plugin::file_block_read($pluginfo, $importdir, "", $block_hash, $metadata, $gli); 444 509 445 446 510 if ($incremental || $incremental_mode eq "onlyadd") { 447 511 448 512 prime_doc_oid_count($archivedir); 449 450 513 451 514 # Can now work out which files were new, already existed, and have … … 532 595 &plugin::remove_some($pluginfo, $collectcfg->{'infodbtype'}, $archivedir, \@full_deleted_files); 533 596 mark_docs_for_deletion($archive_info,{}, 534 535 597 \@full_deleted_files, 598 $archivedir, $verbosity, "delete"); 536 599 537 600 … … 574 637 } 575 638 639 if ($saveas eq "FedoraMETS") { 640 # create collection "doc obj" for Fedora that contains 641 # collection-level metadata 642 643 my $doc_obj = new doc($config_filename,"nonindexed_doc","none"); 644 $doc_obj->set_OID("collection"); 645 646 my $col_name = undef; 647 my $col_meta = $collectcfg->{'collectionmeta'}; 648 649 if (defined $col_meta) { 650 store_collectionmeta($col_meta,"collectionname",$doc_obj); # in GS3 this is a collection's name 651 store_collectionmeta($col_meta,"collectionextra",$doc_obj); # in GS3 this is a collection's description 652 } 653 $processor->process($doc_obj); 654 } 655 576 656 &plugin::end($pluginfo, $processor); 577 657 … … 586 666 $processor->close_group_output() if $processor->is_group(); 587 667 588 # The following 'if' statement is in the export.pl version of the script,589 # The reason for the 'if' statement is now given in export.pl590 # Unclear at this point if the same should be done here591 ## if (($saveas =~ m/^.*METS$/) || ($saveas eq "MARC")) {592 # Not all export types need this (e.g. DSpace)593 594 # should we still do this in debug mode??595 596 668 # for backwards compatability with archvies.inf file 597 669 if ($arcinfo_doc_filename =~ m/(contents)|(\.inf)$/) { … … 602 674 } 603 675 604 605 ## }606 607 676 return $pluginfo; 608 677 } … … 612 681 { 613 682 my $self = shift @_; 614 my ($inexport_mode,$pluginfo) = @_; 683 my ($pluginfo) = @_; 684 685 my $inexport_mode = $self->{'mode'}; 615 686 616 687 my $statsfile = $self->{'statsfile'}; … … 634 705 &gsprintf($out, "\n"); 635 706 &gsprintf($out, "*********************************************\n"); 636 &gsprintf($out, "{ import.complete}\n");707 &gsprintf($out, "{$inexport_mode.complete}\n"); 637 708 &gsprintf($out, "*********************************************\n"); 638 709
Note:
See TracChangeset
for help on using the changeset viewer.