source: main/trunk/greenstone2/bin/script/export.pl@ 30499

Last change on this file since 30499 was 28704, checked in by kjdon, 10 years ago

got rid of all plugout specific options - these are now all specified in -saveas_options, which gets passed directly to the plugout. added GreenstoneXML format to list of saveas options. added an option include_auxiliary_database_files - if set, export will generate the archivesinf databases, otherwise you'll only get the document files. args can set their defaults in the data structure - we now use default_argname variable to test whether value was set by the user or parse function. can put saveas_options into collect.cfg

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
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#
10# Copyright (C) 2004 New Zealand Digital Library Project
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) by importing then saving as a different format.
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/cpan/perl-5.8");
39 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
40 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugouts");
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 unshift (@INC, "$ext_prefix/perllib/plugins");
50 unshift (@INC, "$ext_prefix/perllib/plugouts");
51 }
52 }
53 if (defined $ENV{'GSDL3EXTS'}) {
54 my @extensions = split(/:/,$ENV{'GSDL3EXTS'});
55 foreach my $e (@extensions) {
56 my $ext_prefix = "$ENV{'GSDL3SRCHOME'}/ext/$e";
57
58 unshift (@INC, "$ext_prefix/perllib");
59 unshift (@INC, "$ext_prefix/perllib/cpan");
60 unshift (@INC, "$ext_prefix/perllib/plugins");
61 unshift (@INC, "$ext_prefix/perllib/plugouts");
62 }
63 }
64
65}
66
67use strict;
68#no strict 'refs'; # allow filehandles to be variables and vice versa
69#no strict 'subs'; # allow barewords (eg STDERR) as function arguments
70use inexport;
71
72
73
74# what format to export as
75my $saveas_list =
76 [ { 'name' => "GreenstoneXML",
77 'desc' => "{export.saveas.GreenstoneXML}"},
78 { 'name' => "GreenstoneMETS",
79 'desc' => "{export.saveas.GreenstoneMETS}"},
80 { 'name' => "FedoraMETS",
81 'desc' => "{export.saveas.FedoraMETS}"},
82 { 'name' => "MARCXML",
83 'desc' => "{export.saveas.MARCXML}"},
84 { 'name' => "DSpace",
85 'desc' => "{export.saveas.DSpace}" }
86 ];
87
88
89# Possible attributes for each argument
90# name: The name of the argument
91# desc: A description (or more likely a reference to a description) for this argument
92# type: The type of control used to represent the argument. Options include: string, int, flag, regexp, metadata, language, enum etc
93# reqd: Is this argument required?
94# hiddengli: Is this argument hidden in GLI?
95# modegli: The lowest detail mode this argument is visible at in GLI
96
97my $saveas_argument =
98 { 'name' => "saveas",
99 'desc' => "{export.saveas}",
100 'type' => "enum",
101 'list' => $saveas_list,
102 'deft' => "GreenstoneMETS",
103 'reqd' => "no",
104 'modegli' => "3" };
105
106
107my $arguments =
108 [
109 $saveas_argument,
110 { 'name' => "saveas_options",
111 'desc' => "{import.saveas_options}",
112 'type' => "string",
113 'reqd' => "no" },
114 { 'name' => "include_auxiliary_database_files",
115 'desc' => "{export.include_auxiliary_database_files}",
116 'type' => "flag",
117 'reqd' => "no" },
118 { 'name' => "exportdir",
119 'desc' => "{export.exportdir}",
120 'type' => "string",
121 'reqd' => "no",
122 'deft' => "export",
123 'hiddengli' => "yes" },
124 @$inexport::directory_arguments,
125 { 'name' => "xsltfile",
126 'desc' => "{BasPlugout.xslt_file}",
127 'type' => "string",
128 'reqd' => "no",
129 'hiddengli' => "yes" },
130 { 'name' => "listall",
131 'desc' => "{export.listall}",
132 'type' => "flag",
133 'reqd' => "no" },
134 @$inexport::arguments
135 ];
136
137my $options = { 'name' => "export.pl",
138 'desc' => "{export.desc}",
139 'args' => $arguments };
140
141my $listall_options = { 'name' => "export.pl",
142 'desc' => "{export.desc}",
143 'args' => [ $saveas_argument ] };
144
145
146
147sub main
148{
149 my $inexport = new inexport("export",\@ARGV,$options,$listall_options);
150
151 my $collection = $inexport->get_collection();
152
153 if (defined $collection) {
154 my ($config_filename,$collect_cfg)
155 = $inexport->read_collection_cfg($collection,$options);
156
157 &set_collection_options($inexport, $collect_cfg);
158
159 my $pluginfo = $inexport->process_files($config_filename,$collect_cfg);
160
161 $inexport->generate_statistics($pluginfo);
162 }
163
164 $inexport->deinit();
165}
166
167sub set_collection_options
168{
169 my ($inexport, $collectcfg) = @_;
170
171 if (defined $inexport->{'default_saveas'}) {
172 # we had set the value from the arg default, not from the user
173 if (defined $collectcfg->{'saveas'}
174 && $collectcfg->{'saveas'} =~ /^(GreenstoneXML|GreenstoneMETS|FedoraMETS|MARCXML|DSPace)$/) {
175 $inexport->{'saveas'} = $collectcfg->{'saveas'};
176 } else {
177 $inexport->{'saveas'} = "GreenstoneMETS"; # the default
178 }
179 }
180
181 if (!defined $inexport->{'saveas_options'} || $inexport->{'saveas_options'} eq "") {
182 if (defined $collectcfg->{'saveas_options'} ){
183 $inexport->{'saveas_options'} = $collectcfg->{'saveas_options'};
184 }
185 }
186
187 $inexport->set_collection_options($collectcfg);
188}
189&main();
190
191
192
193
Note: See TracBrowser for help on using the repository browser.