Changeset 28641 for main/trunk/greenstone2/perllib/inexport.pm
- Timestamp:
- 2013-11-19T11:51:13+13:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/inexport.pm
r28211 r28641 48 48 use File::Basename; 49 49 50 my $oidtype_list = 51 [ { 'name' => "hash", 52 'desc' => "{import.OIDtype.hash}" }, 53 { 'name' => "hash_on_full_filename", 54 'desc' => "{import.OIDtype.hash_on_full_filename}" }, 55 { 'name' => "assigned", 56 'desc' => "{import.OIDtype.assigned}" }, 57 { 'name' => "incremental", 58 'desc' => "{import.OIDtype.incremental}" }, 59 { 'name' => "filename", 60 'desc' => "{import.OIDtype.filename}" }, 61 { 'name' => "dirname", 62 'desc' => "{import.OIDtype.dirname}" }, 63 { 'name' => "full_filename", 64 'desc' => "{import.OIDtype.full_filename}" } ]; 65 66 $inexport::directory_arguments = 67 [ 68 { 'name' => "importdir", 69 'desc' => "{import.importdir}", 70 'type' => "string", 71 'reqd' => "no", 72 'hiddengli' => "yes" }, 73 { 'name' => "collectdir", 74 'desc' => "{import.collectdir}", 75 'type' => "string", 76 # parsearg left "" as default 77 #'deft' => &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect"), 78 'deft' => "", 79 'reqd' => "no", 80 'hiddengli' => "yes" }, 81 82 ]; 83 $inexport::arguments = 84 [ 85 # don't set the default to hash - want to allow this to come from 86 # entry in collect.cfg but want to override it here 87 { 'name' => "OIDtype", 88 'desc' => "{import.OIDtype}", 89 'type' => "enum", 90 'list' => $oidtype_list, 91 # parsearg left "" as default 92 #'deft' => "hash", 93 'reqd' => "no", 94 'modegli' => "2" }, 95 { 'name' => "OIDmetadata", 96 'desc' => "{import.OIDmetadata}", 97 'type' => "string", 98 #'type' => "metadata", #doesn't work properly in GLI 99 # parsearg left "" as default 100 #'deft' => "dc.Identifier", 101 'reqd' => "no", 102 'modegli' => "2" }, 103 { 'name' => "site", 104 'desc' => "{import.site}", 105 'type' => "string", 106 'deft' => "", 107 'reqd' => "no", 108 'hiddengli' => "yes" }, 109 { 'name' => "manifest", 110 'desc' => "{import.manifest}", 111 'type' => "string", 112 'deft' => "", 113 'reqd' => "no", 114 'hiddengli' => "yes" } , 115 { 'name' => "incremental", 116 'desc' => "{import.incremental}", 117 'type' => "flag", 118 'hiddengli' => "yes" }, 119 { 'name' => "keepold", 120 'desc' => "{import.keepold}", 121 'type' => "flag", 122 'reqd' => "no", 123 'hiddengli' => "yes" }, 124 { 'name' => "removeold", 125 'desc' => "{import.removeold}", 126 'type' => "flag", 127 'reqd' => "no", 128 'hiddengli' => "yes" }, 129 { 'name' => "language", 130 'desc' => "{scripts.language}", 131 'type' => "string", 132 'reqd' => "no", 133 'hiddengli' => "yes" }, 134 { 'name' => "maxdocs", 135 'desc' => "{import.maxdocs}", 136 'type' => "int", 137 'reqd' => "no", 138 # parsearg left "" as default 139 #'deft' => "-1", 140 'range' => "1,", 141 'modegli' => "1" }, 142 { 'name' => "debug", 143 'desc' => "{import.debug}", 144 'type' => "flag", 145 'reqd' => "no", 146 'hiddengli' => "yes" }, 147 { 'name' => "faillog", 148 'desc' => "{import.faillog}", 149 'type' => "string", 150 # parsearg left "" as default 151 #'deft' => &FileUtils::filenameConcatenate("<collectdir>", "colname", "etc", "fail.log"), 152 'deft' => "", 153 'reqd' => "no", 154 'modegli' => "3" }, 155 { 'name' => "out", 156 'desc' => "{import.out}", 157 'type' => "string", 158 'deft' => "STDERR", 159 'reqd' => "no", 160 'hiddengli' => "yes" }, 161 { 'name' => "statsfile", 162 'desc' => "{import.statsfile}", 163 'type' => "string", 164 'deft' => "STDERR", 165 'reqd' => "no", 166 'hiddengli' => "yes" }, 167 { 'name' => "verbosity", 168 'desc' => "{import.verbosity}", 169 'type' => "int", 170 'range' => "0,", 171 # parsearg left "" as default 172 # 'deft' => "2", 173 'reqd' => "no", 174 'modegli' => "3" }, 175 { 'name' => "gli", 176 'desc' => "{scripts.gli}", 177 'type' => "flag", 178 'reqd' => "no", 179 'hiddengli' => "yes" }, 180 { 'name' => "xml", 181 'desc' => "{scripts.xml}", 182 'type' => "flag", 183 'reqd' => "no", 184 'hiddengli' => "yes" }, 185 186 ]; 187 50 188 sub new 51 189 { … … 101 239 if ($intArgLeftinAfterParsing != 1 || (@$argv && $argv->[0] =~ /^\-+h/)) 102 240 { 241 ## TODO if we had invalid arg, can we signla that to user??? 103 242 &PrintUsage::print_txt_usage($options, "{import.params}"); 104 243 die "\n"; … … 306 445 } 307 446 308 if ((defined $self->{'groupsize'}) && ($self->{'groupsize'} == 1)) { 309 if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/) { 310 $self->{'groupsize'} = $collectcfg->{'groupsize'}; 311 } 312 } 313 314 if (!defined $self->{'saveas'} 315 || ($self->{'saveas'} !~ /^(GreenstoneXML|GreenstoneMETS)$/ )) { 316 # saveas was either not defined on the command-line, or it was not one of the recognized values 317 if (defined $collectcfg->{'saveas'} 318 && $collectcfg->{'saveas'} =~ /^(GreenstoneXML|GreenstoneMETS)$/) { 319 $self->{'saveas'} = $collectcfg->{'saveas'}; 320 } else { 321 $self->{'saveas'} = "GreenstoneXML"; # the default 322 } 323 } 447 324 448 325 449 if (!defined $self->{'OIDtype'} … … 342 466 } 343 467 344 my $sortmeta = $self->{'sortmeta'};345 if (defined $collectcfg->{'sortmeta'} && (!defined $sortmeta || $sortmeta eq "")) {346 $sortmeta = $collectcfg->{'sortmeta'};347 }348 # sortmeta cannot be used with group size349 $sortmeta = undef unless defined $sortmeta && $sortmeta =~ /\S/;350 if (defined $sortmeta && $self->{'groupsize'} > 1) {351 &gsprintf($out, "{import.cannot_sort}\n\n");352 $sortmeta = undef;353 }354 if (defined $sortmeta) {355 &gsprintf($out, "{import.sortmeta_paired_with_ArchivesInfPlugin}\n\n");356 }357 $self->{'sortmeta'} = $sortmeta;358 359 if (defined $collectcfg->{'removeprefix'} && $self->{'removeprefix'} eq "") {360 $self->{'removeprefix'} = $collectcfg->{'removeprefix'};361 }362 363 if (defined $collectcfg->{'removesuffix'} && $self->{'removesuffix'} eq "") {364 $self->{'removesuffix'} = $collectcfg->{'removesuffix'};365 }366 468 if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) { 367 469 $self->{'debug'} = 1; … … 391 493 print STDERR "Warning: -manifest flag should not be specified without also setting -keepold or -incremental\n"; 392 494 } 393 }495 } 394 496 395 497 sub process_files … … 415 517 416 518 my $saveas = $self->{'saveas'}; 519 my $saveas_options = $self->{'saveas_options'}; 417 520 my $OIDtype = $self->{'OIDtype'}; 418 521 my $OIDmetadata = $self->{'OIDmetadata'}; … … 549 652 } 550 653 } 654 551 655 } 552 656 else { … … 566 670 my $plugout_name = $plugout->[0]; 567 671 672 if ($inexport_mode eq "export" && defined $saveas_options) { 673 my @user_plugout_options = split(" ", $saveas_options); 674 push @$plugout, @user_plugout_options; 675 } 568 676 push @$plugout,("-output_info",$archive_info) if (defined $archive_info); 569 677 push @$plugout,("-verbosity",$verbosity) if (defined $verbosity); 570 678 push @$plugout,("-debug") if ($debug); 571 push @$plugout,("-group_size",$groupsize) if (defined $groupsize);572 679 push @$plugout,("-gzip_output") if ($gzip); 573 680 push @$plugout,("-output_handle",$out) if (defined $out); … … 575 682 push @$plugout,("-xslt_file",$xsltfile) if (defined $xsltfile && $xsltfile ne ""); 576 683 684 if ($inexport_mode eq "import") { 685 if ($plugout_name =~ m/^GreenstoneXMLPlugout$/) { 686 push @$plugout,("-group_size",$groupsize) if (defined $groupsize); 687 } 688 } 577 689 if ($plugout_name =~ m/^MARCXMLPlugout$/) { 578 690 push @$plugout,("-group") if ($group_marc); … … 898 1010 } 899 1011 900 # write out the archive information file 901 $processor->close_file_output() if (defined $groupsize) && ($groupsize > 1); 1012 # signal to the processor (plugout) that we have finished processing - if we are group processing, then the final output file needs closing. 902 1013 $processor->close_group_output() if $processor->is_group(); 903 1014 904 # for backwards compatability with archvies.inf file 905 if ($arcinfo_doc_filename =~ m/(contents)|(\.inf)$/) { 906 $archive_info->save_info($arcinfo_doc_filename); 907 } 908 else { 909 $archive_info->save_revinfo_db($arcinfo_src_filename); 910 } 911 1015 # if ($inexport_mode eq "import") { 1016 # write out the archive information file 1017 # for backwards compatability with archvies.inf file 1018 if ($arcinfo_doc_filename =~ m/(contents)|(\.inf)$/) { 1019 $archive_info->save_info($arcinfo_doc_filename); 1020 } 1021 else { 1022 $archive_info->save_revinfo_db($arcinfo_src_filename); 1023 } 1024 # } 912 1025 return $pluginfo; 913 1026 } … … 1380 1493 } 1381 1494 1382 1495 1383 1496 1;
Note:
See TracChangeset
for help on using the changeset viewer.