Changeset 28034


Ignore:
Timestamp:
2013-08-13T14:28:29+12:00 (11 years ago)
Author:
kjdon
Message:

handling importOption and buildOption - they are not options in a importOptions list, just xxOptions at the top level

File:
1 edited

Legend:

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

    r27803 r28034  
    3434
    3535# A mapping hash to resolve name discrepancy between gs2 and gs3.
     36# the first item is the gs3 element name from collectionConfig, the second one
     37# is the internal name for the option
    3638my $nameMap = {"key" => "value",
    3739           "creator" => "creator",
     
    6062           "buildType" => "buildtype",
    6163           "orthogonalBuildTypes" => "orthogonalbuildtypes",
    62            "buildOption" => "buildOption"
    63            #"buildOptions" => "buildOptions", "importOptions" => "importOptions", no actual equivalents for importOptions and buildOptions in GS2
    6464           };
    6565# A hash structure which is returned by sub read_cfg_file.
    6666my $data = {};
    6767
    68 my $repeatedBlock = q/^(browse|pluginList)$/; #|buildOptionList)$/;
     68my $repeatedBlock = q/^(browse|pluginList)$/;
    6969
    7070# use those unique attribute values to locate the text within the elements
     
    7474my $displayItemNames = q/^(name|description)$/;
    7575 
     76# these options get set at top level
     77my $topleveloptionexp = q/^(importOption|buildOption)$/;
     78
    7679# For storing the attributes during the StartTag subroutine, so that
    7780# we can use it later in Text (or EndTag) subroutines
     
    8790my $hashexp = q/^(subcollection)$/; # add other element names that should be represented by hash expressions here
    8891my $hashhashexp = q/^(displayItem)$/; # add other (collectionmeta) element names that should be represented by hashes of hashes here.
    89 
    90 my $generalOptions = q/^(importOptions|buildOptions)$/; # becomes GS2 toplevel map of (name, value) pairs
    9192
    9293my $defaults = q/^(defaultIndex|defaultLevel|defaultIndexLanguage|languageMetadata)$/;
     
    200201    #@ Handle index|sort|facet|level|indexOption|indexSubcollection|indexLanguage
    201202    elsif ($element =~ /$arrayexp/) {
    202       my $key = $nameMap->{$element};   
     203      my $key = $nameMap->{$element};   #
    203204      if (!defined $data->{$key}) {
    204205    $data->{$key} = [];
     
    209210      }
    210211    }
    211 
    212     #*****************************************
    213     elsif ($element eq "buildOption") {
    214         print STDERR "**** BUILD OPTION PAIR $name $value\n";
    215         $data->{$name} = $value;
    216     }   
     212    # importOption and buildOption, just stored at top level, name=value,
     213    # as per gs2 version
     214    elsif ($element =~ /$topleveloptionexp/) {
     215    if (defined $name) {
     216        if (!defined $value) {
     217        # flag option, set to true
     218        $value = "true";
     219        }
     220        $data->{$name} = $value;
     221    }
     222    }
    217223
    218224    #@ plugout options
     
    287293    }
    288294
    289     #@ Handling each importOptions/buildOptions element
    290     elsif ($element =~ /$generalOptions/) {
    291         $currentLevel = $element;
    292         #my $key = $nameMap->{$element}; # importOptions and buildOptions map to themselves, no equivalents in GS2
    293 
    294     # define a map of string pairs
    295     if (!defined $data->{$element}) {
    296         $data->{$element} = {};
    297     }
    298     }
    299     #@ Handling the option elements in an importOptions/buildOptions element, which are of the form:
    300     # <importOptions><option name="n" value="v"/><option .../></importOptions>
    301     # these get stored in-memory at the top level as (n, v) pairs, just as in GS2
    302     elsif ($currentLevel =~ /$generalOptions/ and $element eq "option") {
    303     if (defined $name and $name =~ /\w/) {
    304 
    305         # if a flag's value is on or 1, set it to true. If the value is off or 0, set it to false. (GS2 expects true/false)
    306         # But such on/off flags (like -gli) need not be given a value, in which case the value defaults to 'true' again.
    307 
    308         if(defined $value and $value =~ /\w/) {     
    309 
    310         if ($value =~ m/^(on|1)$/) {
    311             $value = "true";
    312         } elsif ($value =~ m/^(off|0)$/) {
    313             $value = "false";
    314         } # else, use whatever value is provided
    315 
    316         }
    317         else {
    318         $value = "true";
    319         }
    320         $data->{$name} = $value; #$data->{$currentLevel}->{$name} = $value;
    321         #print "@@@@ Added $currentLevel option: $name=$value\n";
    322     }
    323     }
    324295
    325296}
     
    327298sub EndTag {
    328299    my ($expat, $element) = @_;
    329     my $endTags = q/^(browse|pluginList|displayItemList|indexOption|importOptions|buildOptions)$/; #|buildOptionList)$/;   
     300    my $endTags = q/^(browse|pluginList|displayItemList|indexOption)$/; #|buildOptionList)$/;   
    330301    if ($element =~ /$endTags/) {
    331302        $currentIndex = 0;
Note: See TracChangeset for help on using the changeset viewer.