Ignore:
Timestamp:
2012-11-08T17:19:02+13:00 (11 years ago)
Author:
ak19
Message:
  1. Fixed processing of the collectionconfig's indexOption element. 2. Correct set of changes for processing the new toplevel importOptions and buildOptions elements of collectionConfig.xml (which can contain such options as specify OIDtype, OIDmetadata, verbosity). 3. Undoing previous commits, since the importOptions and buildOptions elememts are not nested inside plugins but are one of the toplevel elements of collectionConfig.xml. And do not need the recently-committed changes to inexport.pm either, since any command line args for import and buildOptions will override what's in collectionConfig.xml anyway.
Location:
main/trunk/greenstone2/perllib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/collConfigxml.pm

    r26450 r26451  
    5959           "orthogonalBuildTypes" => "orthogonalbuildtypes",
    6060           "buildOption" => "buildOption"
     61           #"buildOptions" => "buildOptions", "importOptions" => "importOptions", no actual equivalents for importOptions and buildOptions in GS2
    6162           };
    6263# A hash structure which is returned by sub read_cfg_file.
     
    7576my $currentAttrRef = undef;
    7677
    77 # for storing plugin options if of type importOptions or buildOptions
    78 my $currentPluginOptionsType = undef; # can be import or build
    79 
    8078my $currentLevel = "";
    8179
     
    8381# ("plugin", "option")
    8482my $currentIndex = 0;
    85 my $arrayexp = q/^(index|level|indexOption|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/;
    86 my $arrayarrayexp= q/^(plugin|classifier)$/; #|buildOption)$/;
     83my $arrayexp = q/^(index|level|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/; # |indexOption
     84my $arrayarrayexp = q/^(plugin|classifier)$/; #|buildOption)$/;
    8785my $hashexp = q/^(subcollection)$/; # add other element names that should be represented by hash expressions here
    8886my $hashhashexp = q/^(displayItem)$/; # add other (collectionmeta) element names that should be represented by hashes of hashes here.
     87
     88my $generalOptions = q/^(importOptions|buildOptions)$/; # becomes GS2 toplevel map of (name, value) pairs
    8989
    9090my $defaults = q/^(defaultIndex|defaultLevel|defaultIndexLanguage|languageMetadata)$/;
     
    196196    #}
    197197 
    198     #@ Handle index|level|indexOption|indexSubcollection|indexLanguage
     198    #@ Handle index|level|indexSubcollection|indexLanguage #|indexOption
    199199    elsif ($element =~ /$arrayexp/) {
    200200      my $key = $nameMap->{$element};   
     
    214214
    215215    #@ indexoptions: accentfold/casefold/stem; arrayexp
    216  #   elsif ($element eq "indexOption") {
    217   #    $currentLevel = "indexOption";
    218    # }
    219    # if ($currentLevel eq "indexOption" and $element eq "option") {
    220     #  my $key = $nameMap->{$currentLevel};
    221      # if (!defined $data->{$key}) {
    222 #   $data->{$key} = [];
    223  #     }
    224   #    push (@{$data->{$key}},$name);
    225    # }
     216    # needs a separate section, since unlike other $arrayexp, indexOption has <option>s as child elements
     217    # but should be stored in-memory different from $generalOptions (<buildOptions> and <importOptions>)
     218    elsif ($element eq "indexOption") {
     219      $currentLevel = "indexOption";
     220      # find the gs2 mapping name
     221      my $key = $nameMap->{$currentLevel}; 
     222      if (!defined $data->{$key}) {
     223    $data->{$key} = [];
     224      }
     225    }
     226    elsif ($currentLevel eq "indexOption" and $element eq "option") {
     227      my $key = $nameMap->{$currentLevel}; 
     228      if (defined $name and $name =~ /\w/) {
     229      push (@{$data->{$key}},$name);
     230      }
     231    }
     232
    226233    #@ plugout options
    227234    elsif ($element eq "plugout") {
     
    265272    # find the gs2 mapping name
    266273        $currentLevel = $element;
    267         my $key = $nameMap->{$element}; 
    268 
     274        my $key = $nameMap->{$element};
     275   
    269276    # define an array of array of strings   foreach $k (@{$data->{$key}}) {
    270277    if (!defined $data->{$key}) {
    271       $data->{$key} = [];
    272     }
     278        $data->{$key} = [];
     279    }
     280   
    273281    # Push classifier/plugin name (e.g. AZList) into $data as the first string
    274     push (@{$data->{$key}->[$currentIndex]},$name);
    275     if (defined $value and $value =~ /\w/) {
    276         push (@{$data->{$key}->[$currentIndex]}, $value);
    277         print "$value\n";
    278     }
     282    push (@{$data->{$key}->[$currentIndex]},$name);
     283    if (defined $value and $value =~ /\w/) {
     284        push (@{$data->{$key}->[$currentIndex]}, $value);
     285        print "$value\n";
     286    }   
    279287    #print $currentIndex."indexup\n";
    280       }
    281    
    282     # need to process the options of any build- and importOptions lists inside a plugin
    283     # <pluginList><plugin><option.../><option.../><importOptions><option .../></importOptions></plugin></pluginList>
    284     elsif ($currentLevel eq "plugin" and $element =~ m/^(importOptions|buildOptions)$/) {
    285     if($element eq "importOptions") {
    286         $currentPluginOptionsType="import";
    287     }
    288     else {
    289         $currentPluginOptionsType="build";
    290     }
    291288    }
    292289
     
    302299            push (@{$data->{$key}->[$currentIndex]}, $value);
    303300    }
    304     # besides regular options, plugins can have buildOptions and importOptions
    305     #if (defined $currentPluginOptionsType and $currentPluginOptionsType =~ /\w/) {
    306             #push (@{$data->{$key}->[$currentIndex]}, $currentPluginOptionsType);
    307         ##print "@@@@ Found $currentPluginOptionsType option with name: $name and value: $value\n";
    308     #}
    309 
    310     }
    311    
     301
     302    }
     303
     304    #@ Handling each importOptions/buildOptions element
     305    elsif ($element =~ /$generalOptions/) {
     306        $currentLevel = $element;
     307        #my $key = $nameMap->{$element}; # importOptions and buildOptions map to themselves, no equivalents in GS2
     308
     309    # define a map of string pairs
     310    if (!defined $data->{$element}) {
     311        $data->{$element} = {};
     312    }
     313    }
     314    #@ Handling the option elements in an importOptions/buildOptions element, which are of the form:
     315    # <importOptions><option name="n" value="v"/><option .../></importOptions>
     316    # these get stored in memory at the top level as (n, v) pairs, as in GS2
     317    elsif ($currentLevel =~ /$generalOptions/ and $element eq "option") {
     318    if (defined $name and $name =~ /\w/ and defined $value and $value =~ /\w/) {
     319        #$data->{$currentLevel}->{$name} = $value;
     320        $data->{$name} = $value;
     321        print "@@@@ Added $currentLevel option: $name=$value\n";
     322    }
     323    }
     324
    312325}
    313326
    314327sub EndTag {
    315328    my ($expat, $element) = @_;
    316     my $endTags = q/^(browse|pluginList|displayItemList)$/; #|buildOptionList)$/;   
     329    my $endTags = q/^(browse|pluginList|displayItemList|indexOption|importOptions|buildOptions)$/; #|buildOptionList)$/;   
    317330    if ($element =~ /$endTags/) {
    318331        $currentIndex = 0;
    319332        $currentLevel = "";
    320     }
    321     elsif ($element =~ m/^(importOptions|buildOptions)$/) { # can be nested inside a plugin of pluginList
    322     $currentPluginOptionsType = undef;
    323333    }
    324334
  • main/trunk/greenstone2/perllib/inexport.pm

    r26450 r26451  
    228228    }
    229229
    230     # if OIDtype and/or OIDmetadata args are specified on the commandline, they override what's
    231     # in collectcfg but may not overwrite it (by writing it into the collectcfg file)
    232     if (defined $self->{'OIDtype'} && $self->{'OIDtype'} =~ /\w/)
    233     {
    234     $collectcfg->{'OIDtype'} = $self->{'OIDtype'}; # store in the in-memory collectcfg hash
    235     }
    236     if (defined $self->{'OIDmetadata'} && $self->{'OIDmetadata'} =~ /\w/)
    237     {
    238     $collectcfg->{'OIDmetadata'} = $self->{'OIDmetadata'}; # store in the in-memory collectcfg hash
    239     }   
    240 
    241230    if (defined $collectcfg->{'importdir'} && $importdir eq "") {
    242231    $importdir = $collectcfg->{'importdir'};
Note: See TracChangeset for help on using the changeset viewer.