Changeset 28639


Ignore:
Timestamp:
11/19/13 11:14:59 (7 years ago)
Author:
kjdon
Message:

moving common import/export args into inexport.pm. added set_collection_options into import/export.pl so that these files handle their own specific options, while inexport handles the common ones

Location:
main/trunk/greenstone2/bin/script
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/export.pl

    r27140 r28639  
    7070use inexport;
    7171
    72 my $oidtype_list =
    73     [ { 'name' => "hash",
    74         'desc' => "{import.OIDtype.hash}" },
    75       { 'name' => "assigned",
    76         'desc' => "{import.OIDtype.assigned}" },
    77       { 'name' => "incremental",
    78         'desc' => "{import.OIDtype.incremental}" },
    79       { 'name' => "dirname",
    80         'desc' => "{import.OIDtype.dirname}" } ];
     72
    8173
    8274# what format to export as
     
    114106    [
    115107      $saveas_argument,
     108      { 'name' => "saveas_options",
     109    'desc' => "{import.saveas_options}",
     110    'type' => "string",
     111    'reqd' => "no" },
    116112      { 'name' => "exportdir",
    117113    'desc' => "{export.exportdir}",
     
    119115    'reqd' => "no",
    120116        'hiddengli' => "yes" },
    121       { 'name' => "importdir",
    122     'desc' => "{import.importdir}",
    123     'type' => "string",
    124     'reqd' => "no",
    125         'hiddengli' => "yes" },
    126       { 'name' => "collectdir",
    127     'desc' => "{export.collectdir}",
    128     'type' => "string",
    129     # parsearg left "" as default
    130     #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
    131     'deft' => "",
    132     'reqd' => "no",
    133     'hiddengli' => "yes" },
    134       { 'name' => "site",
    135     'desc' => "{import.site}",
    136     'type' => "string",
    137     'deft' => "",
    138     'reqd' => "no",
    139         'hiddengli' => "yes" },
    140      { 'name' => "manifest",
    141     'desc' => "{import.manifest}",
    142     'type' => "string",
    143     'deft' => "",
    144     'reqd' => "no",
    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",
    154     'deft' => "",
    155     'reqd' => "no",
    156         'modegli' => "3" },
    157       # does this make sense?
    158       { 'name' => "incremental",
    159     'desc' => "{import.incremental}",
    160     'type' => "flag",
    161     'hiddengli' => "yes" },
    162       { 'name' => "keepold",
    163     'desc' => "{export.keepold}",
    164     'type' => "flag",
    165     'reqd' => "no",
    166     'hiddengli' => "yes" },
    167       { 'name' => "removeold",
    168     'desc' => "{export.removeold}",
    169     'type' => "flag",
    170     'reqd' => "no",
    171     'hiddengli' => "yes" },
    172       { 'name' => "language",
    173     'desc' => "{scripts.language}",
    174     'type' => "string",
    175     'reqd' => "no",
    176     'hiddengli' => "yes" },
    177       { 'name' => "maxdocs",
    178     'desc' => "{export.maxdocs}",
    179     'type' => "int",
    180     'reqd' => "no",
    181     'range' => "1,",
    182     'modegli' => "1" },
    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",
    190     'modegli' => "2" },
    191       { 'name' => "OIDmetadata",
    192     'desc' => "{import.OIDmetadata}",
    193     'type' => "string",
    194     #'type' => "metadata", #doesn't work properly in GLI
    195     'deft' => "dc.Identifier",
    196     'reqd' => "no",
    197     'modegli' => "2" },
    198       { 'name' => "out",
    199     'desc' => "{export.out}",
    200     'type' => "string",
    201     'deft' => "STDERR",
    202     'reqd' => "no",
    203         'hiddengli' => "yes" },
    204       { 'name' => "statsfile",
    205     'desc' => "{export.statsfile}",
    206     'type' => "string",
    207     'deft' => "STDERR",
    208     'reqd' => "no",
    209         'hiddengli' => "yes" },
     117      @$inexport::directory_arguments,
    210118      { 'name' => "xsltfile",
    211119    'desc' => "{BasPlugout.xslt_file}",
     
    244152    'reqd' => "no",
    245153        'hiddengli' => "no" },
    246       { 'name' => "verbosity",
    247     'desc' => "{export.verbosity}",
    248     'type' => "int",
    249     'range' => "0,3",
    250     'deft' => "2",
    251     'reqd' => "no",
    252     'modegli' => "3" },
    253       { 'name' => "gli",
    254     'desc' => "{scripts.gli}",
    255     'type' => "flag",
    256     'reqd' => "no",
    257     'hiddengli' => "yes" },
    258154      { 'name' => "listall",
    259155    'desc' => "{export.listall}",
    260156    'type' => "flag",
    261157    'reqd' => "no" },
    262       { 'name' => "xml",
    263     'desc' => "{scripts.xml}",
    264     'type' => "flag",
    265     'reqd' => "no",
    266     'hiddengli' => "yes" }
     158      @$inexport::arguments
    267159      ];
    268160
     
    287179        = $inexport->read_collection_cfg($collection,$options);   
    288180
    289     $inexport->set_collection_options($collect_cfg);
     181    &set_collection_options($inexport, $collect_cfg);
    290182   
    291183    my $pluginfo = $inexport->process_files($config_filename,$collect_cfg);
     
    293185    $inexport->generate_statistics($pluginfo);
    294186    }
     187   
     188    $inexport->deinit();
    295189}
    296190
    297 
     191sub set_collection_options
     192{
     193    my ($inexport, $collectcfg) = @_;
     194
     195    if (!defined $inexport->{'saveas'}) {
     196    if (defined $collectcfg->{'saveas'}
     197        && $collectcfg->{'saveas'} =~ /^(GreenstoneMETS|FedoraMETS|MARCXML|DSPace)$/) {
     198        $inexport->{'saveas'} = $collectcfg->{'saveas'};
     199    } else {
     200        $inexport->{'saveas'} = "GreenstoneMETS"; # the default
     201    }
     202    }
     203
     204    if (!defined $inexport->{'saveas_options'}) {
     205    if (defined $collectcfg->{'saveas_options'} ){
     206        $inexport->{'saveas'} = $collectcfg->{'saveas_options'};
     207    }
     208    }
     209
     210    $inexport->set_collection_options($collectcfg);
     211}
    298212&main();
    299213
    300214
     215
     216 
  • main/trunk/greenstone2/bin/script/import.pl

    r28077 r28639  
    7979use util;
    8080
    81 my $oidtype_list =
    82     [ { 'name' => "hash",
    83         'desc' => "{import.OIDtype.hash}" },
    84       { 'name' => "hash_on_full_filename",
    85         'desc' => "{import.OIDtype.hash_on_full_filename}" },
    86       { 'name' => "assigned",
    87         'desc' => "{import.OIDtype.assigned}" },
    88       { 'name' => "incremental",
    89         'desc' => "{import.OIDtype.incremental}" },
    90       { 'name' => "filename",
    91         'desc' => "{import.OIDtype.filename}" },
    92       { 'name' => "dirname",
    93         'desc' => "{import.OIDtype.dirname}" },
    94       { 'name' => "full_filename",
    95         'desc' => "{import.OIDtype.full_filename}" } ];
    9681
    9782
     
    126111    [
    127112      $saveas_argument,
    128       { 'name' => "archivedir",
    129     'desc' => "{import.archivedir}",
    130     'type' => "string",
    131     'reqd' => "no",
    132         'hiddengli' => "yes" },
    133       { 'name' => "importdir",
    134     'desc' => "{import.importdir}",
    135     'type' => "string",
    136     'reqd' => "no",
    137         'hiddengli' => "yes" },
    138       { 'name' => "collectdir",
    139     'desc' => "{import.collectdir}",
    140     'type' => "string",
    141     # parsearg left "" as default
    142     #'deft' => &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect"),
    143     'deft' => "",
    144     'reqd' => "no",
    145         'hiddengli' => "yes" },
    146       { 'name' => "site",
    147     'desc' => "{import.site}",
    148     'type' => "string",
    149     'deft' => "",
    150     'reqd' => "no",
    151         'hiddengli' => "yes" },
    152       { 'name' => "manifest",
    153     'desc' => "{import.manifest}",
    154     'type' => "string",
    155     'deft' => "",
    156     'reqd' => "no",
    157         'hiddengli' => "yes" },
    158       { 'name' => "debug",
    159     'desc' => "{import.debug}",
    160     'type' => "flag",
    161     'reqd' => "no",
    162         'hiddengli' => "yes" },
    163       { 'name' => "faillog",
    164     'desc' => "{import.faillog}",
    165     'type' => "string",
    166     # parsearg left "" as default
    167     #'deft' => &FileUtils::filenameConcatenate("<collectdir>", "colname", "etc", "fail.log"),
    168     'deft' => "",
    169     'reqd' => "no",
    170         'modegli' => "3" },
    171       { 'name' => "incremental",
    172     'desc' => "{import.incremental}",
    173     'type' => "flag",
    174     'hiddengli' => "yes" },
    175       { 'name' => "keepold",
    176     'desc' => "{import.keepold}",
    177     'type' => "flag",
    178     'reqd' => "no",
    179     'hiddengli' => "yes" },
    180       { 'name' => "removeold",
    181     'desc' => "{import.removeold}",
    182     'type' => "flag",
    183     'reqd' => "no",
    184     'hiddengli' => "yes" },
    185       { 'name' => "language",
    186     'desc' => "{scripts.language}",
    187     'type' => "string",
    188     'reqd' => "no",
    189     'hiddengli' => "yes" },
    190       { 'name' => "maxdocs",
    191     'desc' => "{import.maxdocs}",
    192     'type' => "int",
    193     'reqd' => "no",
    194     # parsearg left "" as default
    195     #'deft' => "-1",
    196     'range' => "1,",
    197     'modegli' => "1" },
    198       # don't set the default to hash - want to allow this to come from
    199       # entry in collect.cfg but want to override it here
    200       { 'name' => "OIDtype",
    201     'desc' => "{import.OIDtype}",
    202     'type' => "enum",
    203     'list' => $oidtype_list,
    204     # parsearg left "" as default
    205     #'deft' => "hash",
    206     'reqd' => "no",
    207     'modegli' => "2" },
    208       { 'name' => "OIDmetadata",
    209     'desc' => "{import.OIDmetadata}",
    210     'type' => "string",
    211      #'type' => "metadata", #doesn't work properly in GLI
    212     # parsearg left "" as default
    213     #'deft' => "dc.Identifier",
    214     'reqd' => "no",
    215     'modegli' => "2" },
    216       { 'name' => "out",
    217     'desc' => "{import.out}",
    218     'type' => "string",
    219     'deft' => "STDERR",
    220     'reqd' => "no",
    221         'hiddengli' => "yes" },
    222       { 'name' => "sortmeta",
     113    { 'name' => "sortmeta",
    223114    'desc' => "{import.sortmeta}",
    224115    'type' => "string",
     
    244135    'reqd' => "no",
    245136    'modegli' => "2" },
     137      { 'name' => "archivedir",
     138    'desc' => "{import.archivedir}",
     139    'type' => "string",
     140    'reqd' => "no",
     141        'hiddengli' => "yes" },
     142      @$inexport::directory_arguments,
    246143      { 'name' => "gzip",
    247144    'desc' => "{import.gzip}",
     
    249146    'reqd' => "no",
    250147    'modegli' => "3" },
    251       { 'name' => "statsfile",
    252     'desc' => "{import.statsfile}",
    253     'type' => "string",
    254     'deft' => "STDERR",
    255     'reqd' => "no",
    256         'hiddengli' => "yes" },
    257       { 'name' => "verbosity",
    258     'desc' => "{import.verbosity}",
    259     'type' => "int",
    260     'range' => "0,",
    261     # parsearg left "" as default
    262     # 'deft' => "2",
    263     'reqd' => "no",
    264     'modegli' => "3" },
    265       { 'name' => "gli",
    266     'desc' => "{scripts.gli}",
    267     'type' => "flag",
    268     'reqd' => "no",
    269     'hiddengli' => "yes" },
    270       { 'name' => "xml",
    271     'desc' => "{scripts.xml}",
    272     'type' => "flag",
    273     'reqd' => "no",
    274     'hiddengli' => "yes" }];
     148     @$inexport::arguments
     149];
    275150
    276151my $options = { 'name' => "import.pl",
     
    337212    my ($config_filename,$collect_cfg) = $inexport->read_collection_cfg($collection,$options);
    338213
    339     $inexport->set_collection_options($collect_cfg);
     214    #$inexport->set_collection_options($collect_cfg);
     215    &set_collection_options($inexport, $collect_cfg);
    340216
    341217    my $pluginfo = $inexport->process_files($config_filename,$collect_cfg);
     
    400276# _scanForInExportModules()
    401277
     278# look up collect.cfg for import options, then all inexport version for the
     279# common ones
     280sub set_collection_options
     281{
     282
     283    my ($inexport, $collectcfg) = @_;
     284
     285    #groupsize can (currently) only be defined for import, not export, and
     286    # will be set to 1 if the user has not set it
     287    if ((defined $inexport->{'groupsize'}) && ($inexport->{'groupsize'} == 1)) {
     288    if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/) {
     289        $inexport->{'groupsize'} = $collectcfg->{'groupsize'};
     290    }
     291    }
     292
     293    if (!defined $inexport->{'saveas'}) {
     294    if (defined $collectcfg->{'saveas'}
     295        && $collectcfg->{'saveas'} =~ /^(GreenstoneXML|GreenstoneMETS)$/) {
     296        $inexport->{'saveas'} = $collectcfg->{'saveas'};
     297    } else {
     298        $inexport->{'saveas'} = "GreenstoneXML"; # the default
     299    }
     300    }
     301   
     302    my $sortmeta = $inexport->{'sortmeta'};
     303    if (defined $collectcfg->{'sortmeta'} && (!defined $sortmeta || $sortmeta eq "")) {
     304    $sortmeta = $collectcfg->{'sortmeta'};
     305    }
     306    # sortmeta cannot be used with group size
     307    $sortmeta = undef unless defined $sortmeta && $sortmeta =~ /\S/;
     308    if (defined $sortmeta && $inexport->{'groupsize'} > 1) {
     309    &gsprintf($out, "{import.cannot_sort}\n\n");
     310    $sortmeta = undef;
     311    }
     312    if (defined $sortmeta) {
     313    &gsprintf($out, "{import.sortmeta_paired_with_ArchivesInfPlugin}\n\n");
     314    }
     315    $inexport->{'sortmeta'} = $sortmeta;
     316
     317    if (defined $collectcfg->{'removeprefix'} && $inexport->{'removeprefix'} eq "") {
     318    $inexport->{'removeprefix'} = $collectcfg->{'removeprefix'};
     319    }
     320   
     321    if (defined $collectcfg->{'removesuffix'} && $inexport->{'removesuffix'} eq "") {
     322    $inexport->{'removesuffix'} = $collectcfg->{'removesuffix'};
     323    }
     324
     325    $inexport->set_collection_options($collectcfg);
     326 
     327}
    402328&main();
Note: See TracChangeset for help on using the changeset viewer.