Changeset 26451 for main/trunk
- Timestamp:
- 2012-11-08T17:19:02+13:00 (11 years ago)
- Location:
- main/trunk/greenstone2/perllib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/collConfigxml.pm
r26450 r26451 59 59 "orthogonalBuildTypes" => "orthogonalbuildtypes", 60 60 "buildOption" => "buildOption" 61 #"buildOptions" => "buildOptions", "importOptions" => "importOptions", no actual equivalents for importOptions and buildOptions in GS2 61 62 }; 62 63 # A hash structure which is returned by sub read_cfg_file. … … 75 76 my $currentAttrRef = undef; 76 77 77 # for storing plugin options if of type importOptions or buildOptions78 my $currentPluginOptionsType = undef; # can be import or build79 80 78 my $currentLevel = ""; 81 79 … … 83 81 # ("plugin", "option") 84 82 my $currentIndex = 0; 85 my $arrayexp = q/^(index|level|index Option|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/;86 my $arrayarrayexp = q/^(plugin|classifier)$/; #|buildOption)$/;83 my $arrayexp = q/^(index|level|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/; # |indexOption 84 my $arrayarrayexp = q/^(plugin|classifier)$/; #|buildOption)$/; 87 85 my $hashexp = q/^(subcollection)$/; # add other element names that should be represented by hash expressions here 88 86 my $hashhashexp = q/^(displayItem)$/; # add other (collectionmeta) element names that should be represented by hashes of hashes here. 87 88 my $generalOptions = q/^(importOptions|buildOptions)$/; # becomes GS2 toplevel map of (name, value) pairs 89 89 90 90 my $defaults = q/^(defaultIndex|defaultLevel|defaultIndexLanguage|languageMetadata)$/; … … 196 196 #} 197 197 198 #@ Handle index|level|index Option|indexSubcollection|indexLanguage198 #@ Handle index|level|indexSubcollection|indexLanguage #|indexOption 199 199 elsif ($element =~ /$arrayexp/) { 200 200 my $key = $nameMap->{$element}; … … 214 214 215 215 #@ 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 226 233 #@ plugout options 227 234 elsif ($element eq "plugout") { … … 265 272 # find the gs2 mapping name 266 273 $currentLevel = $element; 267 my $key = $nameMap->{$element}; 268 274 my $key = $nameMap->{$element}; 275 269 276 # define an array of array of strings foreach $k (@{$data->{$key}}) { 270 277 if (!defined $data->{$key}) { 271 $data->{$key} = []; 272 } 278 $data->{$key} = []; 279 } 280 273 281 # Push classifier/plugin name (e.g. AZList) into $data as the first string 274 275 276 277 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 } 279 287 #print $currentIndex."indexup\n"; 280 }281 282 # need to process the options of any build- and importOptions lists inside a plugin283 # <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 }291 288 } 292 289 … … 302 299 push (@{$data->{$key}->[$currentIndex]}, $value); 303 300 } 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 312 325 } 313 326 314 327 sub EndTag { 315 328 my ($expat, $element) = @_; 316 my $endTags = q/^(browse|pluginList|displayItemList )$/; #|buildOptionList)$/;329 my $endTags = q/^(browse|pluginList|displayItemList|indexOption|importOptions|buildOptions)$/; #|buildOptionList)$/; 317 330 if ($element =~ /$endTags/) { 318 331 $currentIndex = 0; 319 332 $currentLevel = ""; 320 }321 elsif ($element =~ m/^(importOptions|buildOptions)$/) { # can be nested inside a plugin of pluginList322 $currentPluginOptionsType = undef;323 333 } 324 334 -
main/trunk/greenstone2/perllib/inexport.pm
r26450 r26451 228 228 } 229 229 230 # if OIDtype and/or OIDmetadata args are specified on the commandline, they override what's231 # 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 hash235 }236 if (defined $self->{'OIDmetadata'} && $self->{'OIDmetadata'} =~ /\w/)237 {238 $collectcfg->{'OIDmetadata'} = $self->{'OIDmetadata'}; # store in the in-memory collectcfg hash239 }240 241 230 if (defined $collectcfg->{'importdir'} && $importdir eq "") { 242 231 $importdir = $collectcfg->{'importdir'};
Note:
See TracChangeset
for help on using the changeset viewer.