Changeset 33171

Show
Ignore:
Timestamp:
20.06.2019 22:39:48 (4 weeks ago)
Author:
wy59
Message:

First part of commit: following Dr Bainbridge's suggestion for how best to determine what phase of building we're in from within doc.pm. Needs a package level variable, used existing coding pattern in the file that used the our keyword.

Location:
main/trunk/greenstone2
Files:
4 modified

Legend:

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

    r31753 r33171  
    9191use FileUtils; 
    9292use util; 
     93use doc; # for the variable our $cmd_line_mode ($doc::cmd_line_mode) 
    9394 
    9495# Globals 
     
    304305sub main 
    305306{ 
     307    $doc::cmd_line_mode = "buildcol"; 
     308 
    306309  # Dynamically include arguments from any subclasses of buildcolutils we find 
    307310  # in the extensions directory 
  • main/trunk/greenstone2/bin/script/export.pl

    r28704 r33171  
    6969#no strict 'subs'; # allow barewords (eg STDERR) as function arguments 
    7070use inexport; 
     71use doc; # for the variable our $cmd_line_mode ($doc::cmd_line_mode) 
    7172 
    7273 
     
    147148sub main  
    148149{ 
     150    $doc::cmd_line_mode = "export"; 
     151 
    149152    my $inexport = new inexport("export",\@ARGV,$options,$listall_options); 
    150153     
  • main/trunk/greenstone2/bin/script/import.pl

    r32541 r33171  
    8080use util; 
    8181use gsprintf 'gsprintf'; 
     82use doc; # for the variable our $cmd_line_mode ($doc::cmd_line_mode) 
    8283 
    8384 
     
    170171sub main 
    171172{ 
     173    $doc::cmd_line_mode = "import"; 
     174 
    172175  # Dynamically include arguments from any subclasses of inexport we find 
    173176  # in the extensions directory 
  • main/trunk/greenstone2/perllib/doc.pm

    r33139 r33171  
    5252 
    5353our $OIDcount = 0; 
     54 
     55 
     56# Declare the Package (level) Variable that will tell us whether we're in the import or buildcol phase. 
     57# This var will be set by import.pl, buildcol.pl and export.pl to the then appropriate value. 
     58# https://perlmaven.com/package-variables-and-lexical-variables-in-perl 
     59# But: https://stackoverflow.com/questions/7542120/perl-how-to-make-variables-from-requiring-script-available-in-required-script 
     60# https://stackoverflow.com/questions/33230015/how-do-i-use-a-variable-in-another-perl-script 
     61#$doc::cmd_line_mode = undef; 
     62# Decided to follow the usage of $OIDcount above to declare the necessary package-level variables 'globally' accessible 
     63# actually accessible only for those packages that import this one (with 'use doc') 
     64our $cmd_line_mode = undef; 
    5465 
    5566# rename_method can be 'url', 'none', 'base64' 
     
    10671078    my ($section, $field, $value) = @_; 
    10681079     
    1069     #    my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(1); 
     1080    #    my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(1); 
    10701081    #    my ($lcfilename) = ($cfilename =~ m/([^\\\/]*)$/); 
    10711082    #    print STDERR "** Calling method: $lcfilename:$cline $cpackage->$csubr\n"; 
     
    11581169        # and therefore skip converting the GPS.mapOverlay meta into Coordinate meta! What to dooooo? 
    11591170        # So the return statement immediately below is a temporary solution, until we find a better one that will always work. 
    1160       my $metaMap = $self->get_metadata_hashmap($section); 
    1161       if(!$metaMap->{'Coordinate'}) { 
    1162              
     1171      if($cmd_line_mode eq "buildcol") { 
     1172       #my $metaMap = $self->get_metadata_hashmap($section); ## TODO: Check if necessary to avoid duplication of <Coordinate> meta in index\text\<coll>.jdb 
     1173       
     1174       #if(!$metaMap->{'Coordinate'}) { 
     1175        #print STDERR "@@@@@@@@@@@@@@ cmd line mode (build phase) is now: $doc::cmd_line_mode\n"; 
     1176     
     1177         
    11631178        print STDERR "GPS.mapOverlay before val: " . $value . "\n"; 
    11641179         
     
    12471262            elsif ($type eq "rectangle") { 
    12481263         
    1249                 my $bounds = $shape->{"bounds"};                 
    1250              
     1264                my $bounds = $shape->{"bounds"}; 
    12511265                $self->processCoordinate($section, $bounds->{"north"}, $bounds->{"east"}); 
    12521266                $self->processCoordinate($section, $bounds->{"south"}, $bounds->{"east"}); 
     
    12561270         
    12571271        } # end for on each shape in GPS.mapOverlay 
     1272       #} 
    12581273      } 
    12591274    } # end GPS.mapOverlay meta