[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 |
|
---|
[28639] | 73 |
|
---|
[17142] | 74 | # what format to export as
|
---|
[8879] | 75 | my $saveas_list =
|
---|
[28704] | 76 | [ { 'name' => "GreenstoneXML",
|
---|
| 77 | 'desc' => "{export.saveas.GreenstoneXML}"},
|
---|
| 78 | { 'name' => "GreenstoneMETS",
|
---|
[14935] | 79 | 'desc' => "{export.saveas.GreenstoneMETS}"},
|
---|
| 80 | { 'name' => "FedoraMETS",
|
---|
| 81 | 'desc' => "{export.saveas.FedoraMETS}"},
|
---|
[12333] | 82 | { 'name' => "MARCXML",
|
---|
[17142] | 83 | 'desc' => "{export.saveas.MARCXML}"},
|
---|
| 84 | { 'name' => "DSpace",
|
---|
| 85 | 'desc' => "{export.saveas.DSpace}" }
|
---|
[12333] | 86 | ];
|
---|
[8879] | 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
|
---|
[12361] | 92 | # type: The type of control used to represent the argument. Options include: string, int, flag, regexp, metadata, language, enum etc
|
---|
[8879] | 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 |
|
---|
[14935] | 97 | my $saveas_argument =
|
---|
[9233] | 98 | { 'name' => "saveas",
|
---|
| 99 | 'desc' => "{export.saveas}",
|
---|
| 100 | 'type' => "enum",
|
---|
| 101 | 'list' => $saveas_list,
|
---|
[17142] | 102 | 'deft' => "GreenstoneMETS",
|
---|
[9233] | 103 | 'reqd' => "no",
|
---|
| 104 | 'modegli' => "3" };
|
---|
| 105 |
|
---|
| 106 |
|
---|
[8879] | 107 | my $arguments =
|
---|
[10340] | 108 | [
|
---|
| 109 | $saveas_argument,
|
---|
[28639] | 110 | { 'name' => "saveas_options",
|
---|
| 111 | 'desc' => "{import.saveas_options}",
|
---|
| 112 | 'type' => "string",
|
---|
| 113 | 'reqd' => "no" },
|
---|
[28704] | 114 | { 'name' => "include_auxiliary_database_files",
|
---|
| 115 | 'desc' => "{export.include_auxiliary_database_files}",
|
---|
| 116 | 'type' => "flag",
|
---|
| 117 | 'reqd' => "no" },
|
---|
[22460] | 118 | { 'name' => "exportdir",
|
---|
[27140] | 119 | 'desc' => "{export.exportdir}",
|
---|
[8879] | 120 | 'type' => "string",
|
---|
| 121 | 'reqd' => "no",
|
---|
[28704] | 122 | 'deft' => "export",
|
---|
[8879] | 123 | 'hiddengli' => "yes" },
|
---|
[28639] | 124 | @$inexport::directory_arguments,
|
---|
[12333] | 125 | { 'name' => "xsltfile",
|
---|
| 126 | 'desc' => "{BasPlugout.xslt_file}",
|
---|
| 127 | 'type' => "string",
|
---|
| 128 | 'reqd' => "no",
|
---|
| 129 | 'hiddengli' => "yes" },
|
---|
[20616] | 130 | { 'name' => "listall",
|
---|
| 131 | 'desc' => "{export.listall}",
|
---|
| 132 | 'type' => "flag",
|
---|
| 133 | 'reqd' => "no" },
|
---|
[28639] | 134 | @$inexport::arguments
|
---|
[10340] | 135 | ];
|
---|
[8879] | 136 |
|
---|
| 137 | my $options = { 'name' => "export.pl",
|
---|
| 138 | 'desc' => "{export.desc}",
|
---|
| 139 | 'args' => $arguments };
|
---|
| 140 |
|
---|
[9233] | 141 | my $listall_options = { 'name' => "export.pl",
|
---|
| 142 | 'desc' => "{export.desc}",
|
---|
| 143 | 'args' => [ $saveas_argument ] };
|
---|
| 144 |
|
---|
[14935] | 145 |
|
---|
[8879] | 146 |
|
---|
[22421] | 147 | sub main
|
---|
| 148 | {
|
---|
| 149 | my $inexport = new inexport("export",\@ARGV,$options,$listall_options);
|
---|
[10340] | 150 |
|
---|
[22421] | 151 | my $collection = $inexport->get_collection();
|
---|
[22459] | 152 |
|
---|
| 153 | if (defined $collection) {
|
---|
| 154 | my ($config_filename,$collect_cfg)
|
---|
| 155 | = $inexport->read_collection_cfg($collection,$options);
|
---|
| 156 |
|
---|
[28639] | 157 | &set_collection_options($inexport, $collect_cfg);
|
---|
[12545] | 158 |
|
---|
[22459] | 159 | my $pluginfo = $inexport->process_files($config_filename,$collect_cfg);
|
---|
| 160 |
|
---|
| 161 | $inexport->generate_statistics($pluginfo);
|
---|
| 162 | }
|
---|
[28639] | 163 |
|
---|
| 164 | $inexport->deinit();
|
---|
[17142] | 165 | }
|
---|
[16425] | 166 |
|
---|
[28639] | 167 | sub set_collection_options
|
---|
| 168 | {
|
---|
| 169 | my ($inexport, $collectcfg) = @_;
|
---|
[14935] | 170 |
|
---|
[28704] | 171 | if (defined $inexport->{'default_saveas'}) {
|
---|
| 172 | # we had set the value from the arg default, not from the user
|
---|
[28639] | 173 | if (defined $collectcfg->{'saveas'}
|
---|
[28704] | 174 | && $collectcfg->{'saveas'} =~ /^(GreenstoneXML|GreenstoneMETS|FedoraMETS|MARCXML|DSPace)$/) {
|
---|
[28639] | 175 | $inexport->{'saveas'} = $collectcfg->{'saveas'};
|
---|
| 176 | } else {
|
---|
| 177 | $inexport->{'saveas'} = "GreenstoneMETS"; # the default
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
| 180 |
|
---|
[28704] | 181 | if (!defined $inexport->{'saveas_options'} || $inexport->{'saveas_options'} eq "") {
|
---|
[28639] | 182 | if (defined $collectcfg->{'saveas_options'} ){
|
---|
[28704] | 183 | $inexport->{'saveas_options'} = $collectcfg->{'saveas_options'};
|
---|
[28639] | 184 | }
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | $inexport->set_collection_options($collectcfg);
|
---|
| 188 | }
|
---|
[22421] | 189 | &main();
|
---|
[10162] | 190 |
|
---|
[9951] | 191 |
|
---|
[28639] | 192 |
|
---|
| 193 |
|
---|