Changeset 14184

Show
Ignore:
Timestamp:
18.06.2007 08:33:27 (12 years ago)
Author:
xiao
Message:

change the default retrieve level to follow the text level

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/cfgread4gs3.pm

    r14105 r14184  
    3030no strict 'refs'; 
    3131no strict 'subs'; 
     32 
    3233# Wrapper that ensures the right version of XML::Parser is loaded given 
    3334# the version of Perl being used.  Need to distinguish between Perl 5.6 and 
    3435# Perl 5.8 
    35  
    36  
    3736sub BEGIN { 
    3837    my $perl_dir; 
     
    5958} 
    6059 
    61 #use XML::Parser; 
    62    
     60use XML::Parser; 
     61 
    6362# A mapping hash to resolve name descrepency between gs2 and gs3. 
    6463my $nameMap = {"key" => "value", 
     
    350349} 
    351350 
     351# Create the buildConfig.xml file for a specific collection 
    352352sub write_cfg_file { 
    353     # information needed from $collectcfg: defaultindex, defaultlevel, classifiers,  
    354     # the rest is from $buildcfg 
     353    # this sub is called make_auxiliary_files() in basebuilder.pm 
     354    # the received args: $buildoutfile - destination file: buildConfig.xml 
     355    #                    $buildcfg - all build options, eg, disable_OAI 
     356    #                    $collectcfg - contents of collectionConfig.xml read in by read_cfg_file sub in cfgread4gs3.pm. 
    355357    my ($buildoutfile, $buildcfg, $collectcfg) = @_; 
    356358    my $line = []; 
     
    389391    &write_line('COLCFG', ["<serviceRackList>"]); 
    390392 
     393    # This serviceRack enables the collection to provide the oai metadata retrieve service, which is served by the OAIPMH.java class 
     394    # For each collection, we write the following serviceRack in the collection's buildConfig.xml file as follows if the 'disable_OAI' argument is not ticked in GLI (or equivalently, a 'disable_OAI' flag is not specified on the command line). There are also other configurations in the OAIConfig.xml. 
     395    if ($buildcfg->{'disable_OAI'} == 0) { 
     396      &write_line('COLCFG', ["<serviceRack name=\"OAIPMH\">"]); 
     397      if (defined $buildcfg->{'indexstem'}) { 
     398        my $indexstem = $buildcfg->{'indexstem'}; 
     399        &write_line('COLCFG', ["<indexStem name=\"", $indexstem, "\" />"]);      
     400      } 
     401      &write_line('COLCFG', ["</serviceRack>"]); 
     402    }     
    391403    # do the search service  
    392404    &write_line('COLCFG', ["<serviceRack name=\"GS2", $service_type, "Search\">"]); 
     
    408420    $maptype = "indexmap"; 
    409421    } 
     422 
     423    map {print $_."\n"} keys %$buildcfg; 
     424 
    410425    if (defined $buildcfg->{$maptype}) { 
    411426    my $indexmap_t = $buildcfg->{$maptype}; 
    412     foreach my $i (@$indexmap_t) { 
     427       foreach my $i (@$indexmap_t) { 
     428    print "i=".$i; 
    413429        my ($k, $v) = $i =~ /^(.*)\-\>(.*)$/; 
    414430        $indexmap->{$k} = $v; 
     
    460476    my $levelmap = {}; 
    461477    my @levellist = (); 
    462     my $default_search_level = ""; 
    463     my $default_retrieve_level = "Doc";#this is defaultGDBMLevel (also for the retrieve service) 
     478    my $default_search_level = "Doc"; 
     479    my $default_retrieve_level = "Doc"; 
     480    my $default_gdbm_level = "Doc"; 
    464481    $first = 1; 
    465482    if ($buildtype eq "mgpp" || $buildtype eq "lucene") { 
     
    471488        push @levellist, $key; 
    472489        if ($first) { 
     490            # let default search level follow the first level in the level list 
    473491            $default_search_level = $val; 
     492            # retrieve/GDBM levels may get modified later if text level is defined 
     493            $default_retrieve_level = $val; 
     494            $default_gdbm_level = $val; 
    474495            $first = 0; 
    475496        } 
    476497        } 
    477498    } 
    478     # now if the user has assigned a default level, we use it  
    479     if (defined $collectcfg->{"defaultlevel"}) { 
    480       $default_search_level = $levelmap->{$collectcfg->{"defaultlevel"}}; 
    481           $default_retrieve_level = $default_search_level;      
    482     } 
    483     #if (defined $buildcfg->{'textlevel'}) { 
    484        # $default_retrieve_level = $buildcfg->{'textlevel'}; 
     499    # even if the user has assigned a default level, we ignore it. Why? 
     500    # I don't know, but it seems it's the way how the serving works 
     501    #if (defined $collectcfg->{"defaultlevel"}) { 
     502    #  $default_search_level = $levelmap->{$collectcfg->{"defaultlevel"}}; 
     503        #  $default_retrieve_level = $default_search_level; 
    485504    #} 
     505     
     506    if (defined $buildcfg->{'textlevel'}) { 
     507       # let the retrieve/gdbm levels always follow the textlevel 
     508           $default_retrieve_level = $buildcfg->{'textlevel'}; 
     509       $default_gdbm_level = $buildcfg->{'textlevel'}; 
     510          
     511    } 
    486512    } 
    487513    #for each level in levelList, write them out 
     
    490516    foreach my $lv (@levellist) { 
    491517    my $level = $levelmap->{$lv}; 
    492     &write_line('COLCFG', ["<level name=\"", $lv, "\" shortname=\"", $level, "\" />"]); 
     518        &write_line('COLCFG', ["<level name=\"", $lv, "\" shortname=\"", $level, "\" />"]); 
    493519    }    
    494520    &write_line('COLCFG', ["</levelList>"]); 
     
    498524    &write_line('COLCFG', ["<defaultLevel shortname=\"", $default_search_level, "\" />"]); 
    499525    } 
    500     &write_line('COLCFG', ["<defaultGDBMLevel shortname=\"", $default_retrieve_level, "\" />"]); 
     526     
     527    # make the GDBM level  
     528    &write_line('COLCFG', ["<defaultGDBMLevel shortname=\"", $default_gdbm_level, "\" />"]); 
    501529 
    502530    # do searchTypeList