[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 |
|
---|
[20616] | 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.
|
---|
[8879] | 30 |
|
---|
| 31 | package export;
|
---|
| 32 |
|
---|
| 33 | BEGIN {
|
---|
| 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");
|
---|
[22331] | 38 | # unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/perl-5.8");
|
---|
[8879] | 39 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
|
---|
[12333] | 40 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugouts");
|
---|
[14942] | 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");
|
---|
[17142] | 49 | unshift (@INC, "$ext_prefix/perllib/plugins");
|
---|
| 50 | unshift (@INC, "$ext_prefix/perllib/plugouts");
|
---|
[14942] | 51 | }
|
---|
| 52 | }
|
---|
[21292] | 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 |
|
---|
[8879] | 65 | }
|
---|
| 66 |
|
---|
[10340] | 67 | use strict;
|
---|
[22421] | 68 | #no strict 'refs'; # allow filehandles to be variables and vice versa
|
---|
| 69 | #no strict 'subs'; # allow barewords (eg STDERR) as function arguments
|
---|
[20616] | 70 | use inexport;
|
---|
[8879] | 71 |
|
---|
| 72 | my $oidtype_list =
|
---|
| 73 | [ { 'name' => "hash",
|
---|
[12691] | 74 | 'desc' => "{import.OIDtype.hash}" },
|
---|
[14935] | 75 | { 'name' => "assigned",
|
---|
| 76 | 'desc' => "{import.OIDtype.assigned}" },
|
---|
[8879] | 77 | { 'name' => "incremental",
|
---|
[12691] | 78 | 'desc' => "{import.OIDtype.incremental}" },
|
---|
| 79 | { 'name' => "dirname",
|
---|
| 80 | 'desc' => "{import.OIDtype.dirname}" } ];
|
---|
[8879] | 81 |
|
---|
[17142] | 82 | # what format to export as
|
---|
[8879] | 83 | my $saveas_list =
|
---|
[17142] | 84 | [ { 'name' => "GreenstoneMETS",
|
---|
[14935] | 85 | 'desc' => "{export.saveas.GreenstoneMETS}"},
|
---|
| 86 | { 'name' => "FedoraMETS",
|
---|
| 87 | 'desc' => "{export.saveas.FedoraMETS}"},
|
---|
[12333] | 88 | { 'name' => "MARCXML",
|
---|
[17142] | 89 | 'desc' => "{export.saveas.MARCXML}"},
|
---|
| 90 | { 'name' => "DSpace",
|
---|
| 91 | 'desc' => "{export.saveas.DSpace}" }
|
---|
[12333] | 92 | ];
|
---|
[8879] | 93 |
|
---|
| 94 |
|
---|
| 95 | # Possible attributes for each argument
|
---|
| 96 | # name: The name of the argument
|
---|
| 97 | # desc: A description (or more likely a reference to a description) for this argument
|
---|
[12361] | 98 | # type: The type of control used to represent the argument. Options include: string, int, flag, regexp, metadata, language, enum etc
|
---|
[8879] | 99 | # reqd: Is this argument required?
|
---|
| 100 | # hiddengli: Is this argument hidden in GLI?
|
---|
| 101 | # modegli: The lowest detail mode this argument is visible at in GLI
|
---|
| 102 |
|
---|
[14935] | 103 | my $saveas_argument =
|
---|
[9233] | 104 | { 'name' => "saveas",
|
---|
| 105 | 'desc' => "{export.saveas}",
|
---|
| 106 | 'type' => "enum",
|
---|
| 107 | 'list' => $saveas_list,
|
---|
[17142] | 108 | 'deft' => "GreenstoneMETS",
|
---|
[9233] | 109 | 'reqd' => "no",
|
---|
| 110 | 'modegli' => "3" };
|
---|
| 111 |
|
---|
| 112 |
|
---|
[8879] | 113 | my $arguments =
|
---|
[10340] | 114 | [
|
---|
| 115 | $saveas_argument,
|
---|
[22460] | 116 | { 'name' => "exportdir",
|
---|
[27140] | 117 | 'desc' => "{export.exportdir}",
|
---|
[8879] | 118 | 'type' => "string",
|
---|
| 119 | 'reqd' => "no",
|
---|
| 120 | 'hiddengli' => "yes" },
|
---|
[10340] | 121 | { 'name' => "importdir",
|
---|
| 122 | 'desc' => "{import.importdir}",
|
---|
| 123 | 'type' => "string",
|
---|
| 124 | 'reqd' => "no",
|
---|
| 125 | 'hiddengli' => "yes" },
|
---|
[8879] | 126 | { 'name' => "collectdir",
|
---|
| 127 | 'desc' => "{export.collectdir}",
|
---|
| 128 | 'type' => "string",
|
---|
[14925] | 129 | # parsearg left "" as default
|
---|
| 130 | #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
|
---|
[14935] | 131 | 'deft' => "",
|
---|
| 132 | 'reqd' => "no",
|
---|
| 133 | 'hiddengli' => "yes" },
|
---|
[17142] | 134 | { 'name' => "site",
|
---|
| 135 | 'desc' => "{import.site}",
|
---|
| 136 | 'type' => "string",
|
---|
| 137 | 'deft' => "",
|
---|
| 138 | 'reqd' => "no",
|
---|
| 139 | 'hiddengli' => "yes" },
|
---|
| 140 | { 'name' => "manifest",
|
---|
[14935] | 141 | 'desc' => "{import.manifest}",
|
---|
| 142 | 'type' => "string",
|
---|
| 143 | 'deft' => "",
|
---|
| 144 | 'reqd' => "no",
|
---|
[8879] | 145 | 'hiddengli' => "yes" },
|
---|
| 146 | { 'name' => "debug",
|
---|
| 147 | 'desc' => "{export.debug}",
|
---|
| 148 | 'type' => "flag",
|
---|
| 149 | 'reqd' => "no",
|
---|
| 150 | 'hiddengli' => "yes" },
|
---|
| 151 | { 'name' => "faillog",
|
---|
| 152 | 'desc' => "{export.faillog}",
|
---|
| 153 | 'type' => "string",
|
---|
[10340] | 154 | 'deft' => "",
|
---|
[8879] | 155 | 'reqd' => "no",
|
---|
[18590] | 156 | 'modegli' => "3" },
|
---|
[17142] | 157 | # does this make sense?
|
---|
[20616] | 158 | { 'name' => "incremental",
|
---|
| 159 | 'desc' => "{import.incremental}",
|
---|
| 160 | 'type' => "flag",
|
---|
| 161 | 'hiddengli' => "yes" },
|
---|
[8879] | 162 | { 'name' => "keepold",
|
---|
| 163 | 'desc' => "{export.keepold}",
|
---|
| 164 | 'type' => "flag",
|
---|
| 165 | 'reqd' => "no",
|
---|
[14935] | 166 | 'hiddengli' => "yes" },
|
---|
[10340] | 167 | { 'name' => "removeold",
|
---|
| 168 | 'desc' => "{export.removeold}",
|
---|
| 169 | 'type' => "flag",
|
---|
| 170 | 'reqd' => "no",
|
---|
[20616] | 171 | 'hiddengli' => "yes" },
|
---|
[8879] | 172 | { 'name' => "language",
|
---|
| 173 | 'desc' => "{scripts.language}",
|
---|
| 174 | 'type' => "string",
|
---|
| 175 | 'reqd' => "no",
|
---|
[20616] | 176 | 'hiddengli' => "yes" },
|
---|
[8879] | 177 | { 'name' => "maxdocs",
|
---|
| 178 | 'desc' => "{export.maxdocs}",
|
---|
| 179 | 'type' => "int",
|
---|
| 180 | 'reqd' => "no",
|
---|
| 181 | 'range' => "1,",
|
---|
| 182 | 'modegli' => "1" },
|
---|
[12691] | 183 | { 'name' => "OIDtype",
|
---|
| 184 | 'desc' => "{import.OIDtype}",
|
---|
| 185 | 'type' => "enum",
|
---|
| 186 | 'list' => $oidtype_list,
|
---|
| 187 | # parsearg left "" as default
|
---|
| 188 | #'deft' => "hash",
|
---|
| 189 | 'reqd' => "no",
|
---|
[18590] | 190 | 'modegli' => "2" },
|
---|
[12691] | 191 | { 'name' => "OIDmetadata",
|
---|
| 192 | 'desc' => "{import.OIDmetadata}",
|
---|
[19625] | 193 | 'type' => "string",
|
---|
| 194 | #'type' => "metadata", #doesn't work properly in GLI
|
---|
[12691] | 195 | 'deft' => "dc.Identifier",
|
---|
| 196 | 'reqd' => "no",
|
---|
[18590] | 197 | 'modegli' => "2" },
|
---|
[8879] | 198 | { 'name' => "out",
|
---|
| 199 | 'desc' => "{export.out}",
|
---|
| 200 | 'type' => "string",
|
---|
| 201 | 'deft' => "STDERR",
|
---|
| 202 | 'reqd' => "no",
|
---|
| 203 | 'hiddengli' => "yes" },
|
---|
[9951] | 204 | { 'name' => "statsfile",
|
---|
| 205 | 'desc' => "{export.statsfile}",
|
---|
| 206 | 'type' => "string",
|
---|
| 207 | 'deft' => "STDERR",
|
---|
| 208 | 'reqd' => "no",
|
---|
| 209 | 'hiddengli' => "yes" },
|
---|
[12333] | 210 | { 'name' => "xsltfile",
|
---|
| 211 | 'desc' => "{BasPlugout.xslt_file}",
|
---|
| 212 | 'type' => "string",
|
---|
| 213 | 'reqd' => "no",
|
---|
| 214 | 'hiddengli' => "yes" },
|
---|
| 215 | { 'name' => "xslt_txt",
|
---|
| 216 | 'desc' => "{METSPlugout.xslt_txt}",
|
---|
| 217 | 'type' => "string",
|
---|
| 218 | 'reqd' => "no",
|
---|
| 219 | 'hiddengli' => "no" },
|
---|
| 220 | { 'name' => "xslt_mets",
|
---|
| 221 | 'desc' => "{METSPlugout.xslt_mets}",
|
---|
| 222 | 'type' => "string",
|
---|
| 223 | 'reqd' => "no",
|
---|
| 224 | 'hiddengli' => "no" },
|
---|
[14935] | 225 | { 'name' => "fedora_namespace",
|
---|
[20690] | 226 | 'desc' => "{FedoraMETSPlugout.fedora_namespace} (-saveas FedoraMETS)",
|
---|
[14935] | 227 | 'type' => "string",
|
---|
| 228 | 'deft' => "greenstone",
|
---|
| 229 | 'reqd' => "no",
|
---|
| 230 | 'hiddengli' => "no" },
|
---|
[12598] | 231 | { 'name' => "mapping_file",
|
---|
[20690] | 232 | 'desc' => "{MARCXMLPlugout.mapping_file} (-saveas MARCXML)",
|
---|
[12598] | 233 | 'type' => "string",
|
---|
| 234 | 'reqd' => "no",
|
---|
| 235 | 'hiddengli' => "no" },
|
---|
[12333] | 236 | { 'name' => "group_marc",
|
---|
[20690] | 237 | 'desc' => "{MARCXMLPlugout.group} (-saveas MARCXML)",
|
---|
[12333] | 238 | 'type' => "flag",
|
---|
| 239 | 'reqd' => "no",
|
---|
| 240 | 'hiddengli' => "no" },
|
---|
[23828] | 241 | { 'name' => "metadata_prefix",
|
---|
| 242 | 'desc' => "{DSpacePlugout.metadata_prefix} (-saveas DSpace)}",
|
---|
| 243 | 'type' => "string",
|
---|
| 244 | 'reqd' => "no",
|
---|
| 245 | 'hiddengli' => "no" },
|
---|
[8879] | 246 | { 'name' => "verbosity",
|
---|
| 247 | 'desc' => "{export.verbosity}",
|
---|
| 248 | 'type' => "int",
|
---|
| 249 | 'range' => "0,3",
|
---|
| 250 | 'deft' => "2",
|
---|
| 251 | 'reqd' => "no",
|
---|
[18590] | 252 | 'modegli' => "3" },
|
---|
[10340] | 253 | { 'name' => "gli",
|
---|
[17142] | 254 | 'desc' => "{scripts.gli}",
|
---|
[10340] | 255 | 'type' => "flag",
|
---|
| 256 | 'reqd' => "no",
|
---|
| 257 | 'hiddengli' => "yes" },
|
---|
[20616] | 258 | { 'name' => "listall",
|
---|
| 259 | 'desc' => "{export.listall}",
|
---|
| 260 | 'type' => "flag",
|
---|
| 261 | 'reqd' => "no" },
|
---|
[10340] | 262 | { 'name' => "xml",
|
---|
| 263 | 'desc' => "{scripts.xml}",
|
---|
| 264 | 'type' => "flag",
|
---|
| 265 | 'reqd' => "no",
|
---|
| 266 | 'hiddengli' => "yes" }
|
---|
| 267 | ];
|
---|
[8879] | 268 |
|
---|
| 269 | my $options = { 'name' => "export.pl",
|
---|
| 270 | 'desc' => "{export.desc}",
|
---|
| 271 | 'args' => $arguments };
|
---|
| 272 |
|
---|
[9233] | 273 | my $listall_options = { 'name' => "export.pl",
|
---|
| 274 | 'desc' => "{export.desc}",
|
---|
| 275 | 'args' => [ $saveas_argument ] };
|
---|
| 276 |
|
---|
[14935] | 277 |
|
---|
[8879] | 278 |
|
---|
[22421] | 279 | sub main
|
---|
| 280 | {
|
---|
| 281 | my $inexport = new inexport("export",\@ARGV,$options,$listall_options);
|
---|
[10340] | 282 |
|
---|
[22421] | 283 | my $collection = $inexport->get_collection();
|
---|
[22459] | 284 |
|
---|
| 285 | if (defined $collection) {
|
---|
| 286 | my ($config_filename,$collect_cfg)
|
---|
| 287 | = $inexport->read_collection_cfg($collection,$options);
|
---|
| 288 |
|
---|
| 289 | $inexport->set_collection_options($collect_cfg);
|
---|
[12545] | 290 |
|
---|
[22459] | 291 | my $pluginfo = $inexport->process_files($config_filename,$collect_cfg);
|
---|
| 292 |
|
---|
| 293 | $inexport->generate_statistics($pluginfo);
|
---|
| 294 | }
|
---|
[17142] | 295 | }
|
---|
[16425] | 296 |
|
---|
[14935] | 297 |
|
---|
[22421] | 298 | &main();
|
---|
[10162] | 299 |
|
---|
[9951] | 300 |
|
---|