source: gsdl/trunk/bin/script/export.pl@ 18590

Last change on this file since 18590 was 18590, checked in by kjdon, 15 years ago

GLI three modes change: changed modegli for some script arguments. 3 becomes 2 or 3, 4 becomes 3

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 19.3 KB
RevLine 
[8879]1#!/usr/bin/perl -w
2
3###########################################################################
4#
5# export.pl --
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
[17142]10# Copyright (C) 2004 New Zealand Digital Library Project
[8879]11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27
28
29# This program will export a particular collection into a specific Format (e.g. METS or DSpace)
30
31package export;
32
33BEGIN {
34 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
35 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
36 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
37 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
38 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
[12333]39 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugouts");
[14942]40
41 if (defined $ENV{'GSDLEXTS'}) {
42 my @extensions = split(/:/,$ENV{'GSDLEXTS'});
43 foreach my $e (@extensions) {
44 my $ext_prefix = "$ENV{'GSDLHOME'}/ext/$e";
45
46 unshift (@INC, "$ext_prefix/perllib");
47 unshift (@INC, "$ext_prefix/perllib/cpan");
[17142]48 unshift (@INC, "$ext_prefix/perllib/plugins");
49 unshift (@INC, "$ext_prefix/perllib/plugouts");
[14942]50 }
51 }
[8879]52}
53
[10340]54use strict;
55no strict 'refs'; # allow filehandles to be variables and vice versa
56no strict 'subs'; # allow barewords (eg STDERR) as function arguments
57
[10162]58use arcinfo;
[8879]59use colcfg;
60use plugin;
[12333]61use plugout;
[14935]62use manifest;
[8879]63use util;
[10417]64use scriptutil;
[8879]65use FileHandle;
[14935]66use gsprintf 'gsprintf';
[8879]67use printusage;
[10340]68use parse2;
[8879]69
[10340]70
[8879]71my $oidtype_list =
72 [ { 'name' => "hash",
[12691]73 'desc' => "{import.OIDtype.hash}" },
[14935]74 { 'name' => "assigned",
75 'desc' => "{import.OIDtype.assigned}" },
[8879]76 { 'name' => "incremental",
[12691]77 'desc' => "{import.OIDtype.incremental}" },
78 { 'name' => "dirname",
79 'desc' => "{import.OIDtype.dirname}" } ];
[8879]80
[17142]81# what format to export as
[8879]82my $saveas_list =
[17142]83 [ { 'name' => "GreenstoneMETS",
[14935]84 'desc' => "{export.saveas.GreenstoneMETS}"},
85 { 'name' => "FedoraMETS",
86 'desc' => "{export.saveas.FedoraMETS}"},
[12333]87 { 'name' => "MARCXML",
[17142]88 'desc' => "{export.saveas.MARCXML}"},
89 { 'name' => "DSpace",
90 'desc' => "{export.saveas.DSpace}" }
[12333]91 ];
[8879]92
93
94# Possible attributes for each argument
95# name: The name of the argument
96# desc: A description (or more likely a reference to a description) for this argument
[12361]97# type: The type of control used to represent the argument. Options include: string, int, flag, regexp, metadata, language, enum etc
[8879]98# reqd: Is this argument required?
99# hiddengli: Is this argument hidden in GLI?
100# modegli: The lowest detail mode this argument is visible at in GLI
101
[14935]102my $saveas_argument =
[9233]103 { 'name' => "saveas",
104 'desc' => "{export.saveas}",
105 'type' => "enum",
106 'list' => $saveas_list,
[17142]107 'deft' => "GreenstoneMETS",
[9233]108 'reqd' => "no",
109 'modegli' => "3" };
110
111
[8879]112my $arguments =
[10340]113 [
114 $saveas_argument,
115 { 'name' => "exportdir",
[8879]116 'desc' => "{export.exportdir}",
117 'type' => "string",
118 'reqd' => "no",
119 'hiddengli' => "yes" },
[10340]120 { 'name' => "importdir",
121 'desc' => "{import.importdir}",
122 'type' => "string",
123 'reqd' => "no",
124 'hiddengli' => "yes" },
[8879]125 { 'name' => "collectdir",
126 'desc' => "{export.collectdir}",
127 'type' => "string",
[14925]128 # parsearg left "" as default
129 #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
[14935]130 'deft' => "",
131 'reqd' => "no",
132 'hiddengli' => "yes" },
[17142]133 { 'name' => "site",
134 'desc' => "{import.site}",
135 'type' => "string",
136 'deft' => "",
137 'reqd' => "no",
138 'hiddengli' => "yes" },
139 { 'name' => "manifest",
[14935]140 'desc' => "{import.manifest}",
141 'type' => "string",
142 'deft' => "",
143 'reqd' => "no",
[8879]144 'hiddengli' => "yes" },
[9233]145 { 'name' => "listall",
[12691]146 'desc' => "{export.listall}",
[9233]147 'type' => "flag",
148 'reqd' => "no" },
[8879]149 { 'name' => "debug",
150 'desc' => "{export.debug}",
151 'type' => "flag",
152 'reqd' => "no",
153 'hiddengli' => "yes" },
154 { 'name' => "faillog",
155 'desc' => "{export.faillog}",
156 'type' => "string",
[10340]157 'deft' => "",
[8879]158 'reqd' => "no",
[18590]159 'modegli' => "3" },
[17142]160 # does this make sense?
161# { 'name' => "incremental",
162# 'desc' => "{import.incremental}",
163# 'type' => "flag",
164# 'hiddengli' => "yes" },
[8879]165 { 'name' => "keepold",
166 'desc' => "{export.keepold}",
167 'type' => "flag",
168 'reqd' => "no",
[14935]169 'hiddengli' => "yes" },
[10340]170 { 'name' => "removeold",
171 'desc' => "{export.removeold}",
172 'type' => "flag",
173 'reqd' => "no",
174 'modegli' => "3" },
[8879]175 { 'name' => "language",
176 'desc' => "{scripts.language}",
177 'type' => "string",
178 'reqd' => "no",
[18590]179 'modegli' => "3" },
[8879]180 { 'name' => "maxdocs",
181 'desc' => "{export.maxdocs}",
182 'type' => "int",
183 'reqd' => "no",
184 'range' => "1,",
185 'modegli' => "1" },
[12691]186 { 'name' => "OIDtype",
187 'desc' => "{import.OIDtype}",
188 'type' => "enum",
189 'list' => $oidtype_list,
190 # parsearg left "" as default
191 #'deft' => "hash",
192 'reqd' => "no",
[18590]193 'modegli' => "2" },
[12691]194 { 'name' => "OIDmetadata",
195 'desc' => "{import.OIDmetadata}",
196 'type' => "metadata",
197 'deft' => "dc.Identifier",
198 'reqd' => "no",
[18590]199 'modegli' => "2" },
[8879]200 { 'name' => "out",
201 'desc' => "{export.out}",
202 'type' => "string",
203 'deft' => "STDERR",
204 'reqd' => "no",
205 'hiddengli' => "yes" },
[9951]206 { 'name' => "statsfile",
207 'desc' => "{export.statsfile}",
208 'type' => "string",
209 'deft' => "STDERR",
210 'reqd' => "no",
211 'hiddengli' => "yes" },
[12333]212 { 'name' => "xsltfile",
213 'desc' => "{BasPlugout.xslt_file}",
214 'type' => "string",
215 'reqd' => "no",
216 'hiddengli' => "yes" },
217 { 'name' => "xslt_txt",
218 'desc' => "{METSPlugout.xslt_txt}",
219 'type' => "string",
220 'reqd' => "no",
221 'hiddengli' => "no" },
222 { 'name' => "xslt_mets",
223 'desc' => "{METSPlugout.xslt_mets}",
224 'type' => "string",
225 'reqd' => "no",
226 'hiddengli' => "no" },
[14935]227 { 'name' => "fedora_namespace",
228 'desc' => "{FedoraMETSPlugout.fedora_namespace}",
229 'type' => "string",
230 'deft' => "greenstone",
231 'reqd' => "no",
232 'hiddengli' => "no" },
[12598]233 { 'name' => "mapping_file",
234 'desc' => "{MARCXMLPlugout.mapping_file}",
235 'type' => "string",
236 'reqd' => "no",
237 'hiddengli' => "no" },
[12333]238 { 'name' => "group_marc",
239 'desc' => "{MARCXMLPlugout.group}",
240 'type' => "flag",
241 'reqd' => "no",
242 'hiddengli' => "no" },
[8879]243 { 'name' => "verbosity",
244 'desc' => "{export.verbosity}",
245 'type' => "int",
246 'range' => "0,3",
247 'deft' => "2",
248 'reqd' => "no",
[18590]249 'modegli' => "3" },
[10340]250 { 'name' => "gli",
[17142]251 'desc' => "{scripts.gli}",
[10340]252 'type' => "flag",
253 'reqd' => "no",
254 'hiddengli' => "yes" },
255 { 'name' => "xml",
256 'desc' => "{scripts.xml}",
257 'type' => "flag",
258 'reqd' => "no",
259 'hiddengli' => "yes" }
260 ];
[8879]261
262my $options = { 'name' => "export.pl",
263 'desc' => "{export.desc}",
264 'args' => $arguments };
265
[9233]266my $listall_options = { 'name' => "export.pl",
267 'desc' => "{export.desc}",
268 'args' => [ $saveas_argument ] };
269
[14935]270
[8879]271&main();
272
273sub main {
[10340]274 # params
[14935]275 my ($language, $verbosity, $debug,
[17142]276 $collectdir, $importdir, $exportdir, $site, $manifest,
277 $incremental, $keepold, $removeold,
278 $saveas,
[14935]279 $OIDtype, $OIDmetadata,
280 $maxdocs, $statsfile,
[17142]281 $out, $faillog, $gli, $listall,
282 # plugout specific ones
283 $mapping_file, $xsltfile,
[14935]284 $xslt_mets, $xslt_txt, $fedora_namespace, $group_marc);
285
[8879]286 my $xml = 0;
[10340]287
288 # other vars
[17142]289 my ($configfilename, $collection, $collectcfg,
[18440]290 $expinfo_doc_filename, $export_info,
[17142]291 $gs_mode,
[14935]292 $processor, $pluginfo);
293
[8879]294 my $service = "export";
295
[10340]296 my $hashParsingResult = {};
297 # general options available to all plugins
298 my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
[12545]299
300 # If parse returns -1 then something has gone wrong
301 if ($intArgLeftinAfterParsing == -1)
302 {
303 &PrintUsage::print_txt_usage($options, "{export.params}");
304 die "\n";
305 }
306
[10340]307 foreach my $strVariable (keys %$hashParsingResult)
308 {
309 eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
[8879]310 }
311
[10340]312
313 # these are options used by other things - we just set default values
314 # undef means will be set from config file if there
315 my $gzip = undef;
[9233]316
[8879]317 # If $language has been specified, load the appropriate resource bundle
318 # (Otherwise, the default resource bundle will be loaded automatically)
[17142]319 if ($language && $language =~ /\S/) {
[8879]320 &gsprintf::load_language_specific_resource_bundle($language);
321 }
322
[9233]323 if ($listall) {
324 if ($xml) {
325 &PrintUsage::print_xml_usage($listall_options);
326 }
327 else
328 {
329 &PrintUsage::print_txt_usage($listall_options,"{export.params}");
330 }
331 die "\n";
332 }
[17142]333
334 if ($xml) {
[8879]335 &PrintUsage::print_xml_usage($options);
336 die "\n";
337 }
338
[17142]339 if ($gli) { # the gli wants strings to be in UTF-8
340 &gsprintf::output_strings_in_UTF8;
341 }
342
343 # now check that we had exactly one leftover arg, which should be
344 # the collection name. We don't want to do this earlier, cos
345 # -xml arg doesn't need a collection name
346 # Or if the user specified -h, then we output the usage also
347 if ($intArgLeftinAfterParsing != 1 || (@ARGV && $ARGV[0] =~ /^\-+h/))
348 {
[10340]349 &PrintUsage::print_txt_usage($options, "{export.params}");
350 die "\n";
351 }
352
[8879]353 my $close_out = 0;
354 if ($out !~ /^(STDERR|STDOUT)$/i) {
355 open (OUT, ">$out") ||
356 (&gsprintf(STDERR, "{common.cannot_open_output_file}\n", $out) && die);
357 $out = 'export::OUT';
358 $close_out = 1;
359 }
360 $out->autoflush(1);
361
[17142]362 # get and check the collection name
363 if (($collection = &colcfg::use_collection($site, @ARGV, $collectdir)) eq "") {
364 &PrintUsage::print_txt_usage($options, "{export.params}");
365 die "\n";
366 }
367 # add collection's perllib dir into include path in
368 # case we have collection specific modules
369 unshift (@INC, "$ENV{'GSDLCOLLECTDIR'}/perllib");
370
371 # check that we can open the faillog
372 if ($faillog eq "") {
373 $faillog = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "etc", "fail.log");
374 }
375 open (FAILLOG, ">$faillog") ||
376 (&gsprintf(STDERR, "{export.cannot_open_fail_log}\n", $faillog) && die);
377 my $faillogname = $faillog;
378 $faillog = 'export::FAILLOG';
379 $faillog->autoflush(1);
[12358]380
[17142]381 # Read in the collection configuration file.
382 ($configfilename, $gs_mode) = &colcfg::get_collect_cfg_name($out);
[9233]383
[17142]384
385 # Read in the collection configuration file.
386 ($configfilename, $gs_mode) = &colcfg::get_collect_cfg_name($out);
387
388 if ($gs_mode eq "gs2") {
389 $collectcfg = &colcfg::read_collect_cfg ($configfilename);
390 } elsif ($gs_mode eq "gs3") {
391 $collectcfg = &colcfg::read_collection_cfg_xml ($configfilename);
392 }
[14935]393
[17142]394 if (defined $collectcfg->{'importdir'} && $importdir eq "") {
395 $importdir = $collectcfg->{'importdir'};
396 }
397 if (defined $collectcfg->{'exportdir'} && $exportdir eq "") {
398 $exportdir = $collectcfg->{'exportdir'};
399 }
[14935]400
[17142]401 # fill in the default import and export directories if none
402 # were supplied, turn all \ into / and remove trailing /
403 $importdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
404 $importdir =~ s/[\\\/]+/\//g;
405 $importdir =~ s/\/$//;
406 if (!-e $importdir) {
407 &gsprintf($out, "{import.no_import_dir}\n\n", $importdir);
408 die "\n";
409 }
[14925]410
[17142]411 $exportdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "export") if $exportdir eq "";
412 $exportdir =~ s/[\\\/]+/\//g;
413 $exportdir =~ s/\/$//;
414
415 my $plugins = [];
416 if (defined $collectcfg->{'plugin'}) {
417 $plugins = $collectcfg->{'plugin'};
418 }
419 # some global options for the plugins
420 my @global_opts = ();
[14935]421
[17142]422 if ($verbosity !~ /\d+/) {
423 if (defined $collectcfg->{'verbosity'} && $collectcfg->{'verbosity'} =~ /\d+/) {
424 $verbosity = $collectcfg->{'verbosity'};
425 } else {
426 $verbosity = 2; # the default
427 }
428 }
429
430 if (defined $collectcfg->{'gzip'} && !$gzip) {
431 if ($collectcfg->{'gzip'} =~ /^true$/i) {
432 $gzip = 1;
433 }
434 }
435 if ($maxdocs !~ /\-?\d+/) {
436 if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) {
437 $maxdocs = $collectcfg->{'maxdocs'};
438 } else {
439 $maxdocs = -1; # the default
440 }
441 }
442
443 if (!defined $OIDtype || ($OIDtype !~ /^(hash|incremental|assigned|dirname)$/)) {
444 if (defined $collectcfg->{'OIDtype'} && $collectcfg->{'OIDtype'} =~ /^(hash|incremental|assigned|dirname)$/) {
445 $OIDtype = $collectcfg->{'OIDtype'};
446 } else {
447 $OIDtype = "hash"; # the default
448 }
449 }
[14935]450
[17142]451 if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) {
452 $debug = 1;
453 }
454 if (defined $collectcfg->{'gli'} && $collectcfg->{'gli'} =~ /^true$/i) {
455 $gli = 1;
456 }
457 $gli = 0 unless defined $gli;
[14935]458
[17142]459 # check keepold and removeold
460 ($removeold, $keepold, $incremental) = &scriptutil::check_removeold_and_keepold($removeold, $keepold, $incremental, "export", $collectcfg);
[10417]461
[17142]462 print STDERR "<export>\n" if $gli;
463
464 my $manifest_lookup = new manifest();
465 if ($manifest ne "") {
466 my $manifest_filename = $manifest;
[10417]467
[17142]468 if ($manifest_filename !~ m/^[\\\/]/) {
469 $manifest_filename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, $manifest_filename);
470 }
[9233]471
[17142]472 $manifest =~ s/[\\\/]+/\//g;
473 $manifest =~ s/\/$//;
474
475 $manifest_lookup->parse($manifest_filename);
476 }
477
478 # load all the plugins
479 $pluginfo = &plugin::load_plugins ($plugins, $verbosity, $out, $faillog, \@global_opts);
[9233]480
[17142]481 if (scalar(@$pluginfo) == 0) {
482 &gsprintf($out, "{import.no_plugins_loaded}\n");
483 die "\n";
484 }
485
486 # remove the old contents of the export directory if needed
487 if ($removeold && -e $exportdir) {
488 &gsprintf($out, "{export.removing_export}\n");
489 &util::rm_r ($exportdir);
490 }
491
492 # create the export dir if needed
493 &util::mk_all_dir($exportdir);
494
495 # read the export information file
496 # If saveas=DSpace, a "contents" file will be created, otherwise "export.inf"
497
498 # the plugouts should be doing this!!
499 if ($saveas eq "DSpace"){
[18440]500 $expinfo_doc_filename = &util::filename_cat ($exportdir, "contents");
[17142]501 } elsif ($saveas =~ m/^.*METS$/ || $saveas eq "MARC" ) {
[18440]502## $expinfo_doc_filename = &util::filename_cat ($exportdir, "export.inf");
503 my $db_ext = &util::is_little_endian() ? ".ldb" : ".bdb";
504 my $doc_db = "archiveinf-doc$db_ext";
505 $expinfo_doc_filename = &util::filename_cat ($exportdir, $doc_db);
[17142]506 }
[9233]507
[17142]508 $export_info = new arcinfo();
[18440]509 $export_info -> load_info ($expinfo_doc_filename);
[9233]510
[17142]511 my ($plugout);
512 if (defined $collectcfg->{'plugout'} && $collectcfg->{'plugout'} =~ /^(.*METS|DSpace|MARCXML)Plugout/) {
513 $plugout = $collectcfg->{'plugout'};
514 }
515 else{
516 if ($saveas !~ /^(.*METS|DSpace|MARCXML)$/) {
517 push @$plugout,"GreenstoneMETSPlugout";
518 }
519 else{
520 push @$plugout,$saveas."Plugout";
521 }
522 }
523
524 my $plugout_name = $plugout->[0];
[9233]525
[17142]526 push @$plugout,("-output_info",$export_info) if (defined $export_info);
527 push @$plugout,("-verbosity",$verbosity) if (defined $verbosity);
528 push @$plugout,("-debug") if ($debug);
529 push @$plugout,("-gzip_output",$gzip) if (defined $gzip);
530 push @$plugout,("-output_handle",$out) if (defined $out);
531 push @$plugout,("-xslt_file",$xsltfile) if (defined $xsltfile);
532 push @$plugout,("-group") if ($group_marc && $plugout_name =~ m/^MARCXMLPlugout$/);
533 push @$plugout,("-mapping_file",$mapping_file) if (defined $mapping_file && $plugout_name =~ m/^MARCXMLPlugout$/);
534 push @$plugout,("-xslt_mets",$xslt_mets) if (defined $xslt_mets && $plugout_name =~ m/^.*METSPlugout$/);
535 push @$plugout,("-xslt_txt",$xslt_txt) if (defined $xslt_txt && $plugout_name =~ m/^.*METSPlugout$/);
536 push @$plugout,("-fedora_namespace",$fedora_namespace) if (defined $fedora_namespace && $plugout_name eq "FedoraMETSPlugout");
537
538 $processor = &plugout::load_plugout($plugout);
539 $processor->setoutputdir ($exportdir);
[9233]540
[17142]541 $processor->set_OIDtype ($OIDtype, $OIDmetadata);
[13169]542
[17142]543 &plugin::begin($pluginfo, $importdir, $processor, $maxdocs, $gli);
[13169]544
[17142]545 if ($manifest eq "") {
546 # process the import directory
547 my $block_hash = {};
548 my $metadata = {};
549 # gobal blocking pass may set up some metadata
550 &plugin::file_block_read($pluginfo, $importdir, "", $block_hash, $metadata, $gli);
551 &plugin::read ($pluginfo, $importdir, "", $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
552 }
553 else {
554 # process any files marked for exporting
[18440]555 foreach my $file (keys %{$manifest_lookup->{'index'}}) {
[17142]556 &plugin::read ($pluginfo, $importdir, $file, {}, {}, $processor, $maxdocs, 0, $gli);
557 }
558 }
[14733]559
[17142]560 if ($saveas eq "FedoraMETS") {
561 # create collection "doc obj" for Fedora that contains
562 # collection-level metadata
563
564 my $doc_obj = new doc($configfilename,"nonindexed_doc");
565 $doc_obj->set_OID("collection");
566
567 my $col_name = undef;
568 my $col_meta = $collectcfg->{'collectionmeta'};
569
570 if (defined $col_meta) {
[9233]571
[17142]572 store_collectionmeta($col_meta,"collectionname",$doc_obj); # in GS3 this is a collection's name
573 store_collectionmeta($col_meta,"collectionextra",$doc_obj); # in GS3 this is a collection's description
[13169]574
[17142]575 }
576 $processor->process($doc_obj);
577 }
[13169]578
[17142]579 &plugin::end($pluginfo, $processor);
580
581 &plugin::deinit($pluginfo, $processor);
[13169]582
[17142]583 # write out the export information file
584 #$processor->close_file_output() if $groupsize > 1;
585 $processor->close_group_output() if $processor->is_group();
[18440]586
587 if (($saveas =~ m/^.*METS$/) || ($saveas eq "MARC")) {
588 # Not all export types need this (e.g. DSpace)
589 $export_info->save_info($expinfo_doc_filename);
[17142]590 }
[9233]591
[17142]592 # write out export stats
593 my $close_stats = 0;
594 if ($statsfile !~ /^(STDERR|STDOUT)$/i) {
595 if (open (STATS, ">$statsfile")) {
596 $statsfile = 'import::STATS';
597 $close_stats = 1;
598 } else {
599 &gsprintf($out, "{import.cannot_open_stats_file}", $statsfile);
600 &gsprintf($out, "{import.stats_backup}\n");
601 $statsfile = 'STDERR';
602 }
603 }
[14935]604
[17142]605 &gsprintf($out, "\n");
606 &gsprintf($out, "*********************************************\n");
607 &gsprintf($out, "{export.complete}\n");
608 &gsprintf($out, "*********************************************\n");
609
610 &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
611 if ($close_stats) {
612 close STATS;
613 }
614
615 close OUT if $close_out;
616 close FAILLOG;
617}
[16425]618
[14935]619
[17142]620sub store_collectionmeta
621{
622 my ($collectionmeta,$field,$doc_obj) = @_;
[10162]623
[17142]624 my $section = $doc_obj->get_top_section();
[9951]625
[17142]626 my $field_hash = $collectionmeta->{$field};
[9951]627
[17142]628 foreach my $k (keys %$field_hash)
629 {
630 my $val = $field_hash->{$k};
[9951]631
[17142]632 ### print STDERR "*** $k = $field_hash->{$k}\n";
[9951]633
[17142]634 my $md_label = "ex.$field";
[9951]635
[8879]636
[17142]637 if ($k =~ m/^\[l=(.*?)\]$/)
638 {
639
640 my $md_suffix = $1;
641 $md_label .= "^$md_suffix";
[9951]642 }
643
[9233]644
[17142]645 $doc_obj->add_utf8_metadata($section,$md_label, $val);
646
647 # see cfgread4gs3.pm: GS2's "collectionextra" is called "description" in GS3,
648 # while "collectionname" in GS2 is called "name" in GS3.
649 # Variable $nameMap variable in cfgread4gs3.pm maps between GS2 and GS3
650 if (($md_label eq "ex.collectionname^en") || ($md_label eq "ex.collectionname"))
651 {
652 $doc_obj->add_utf8_metadata($section,"dc.Title", $val);
653 }
[8879]654
[17142]655 }
[8879]656}
[17142]657
658
659
660
Note: See TracBrowser for help on using the repository browser.