Changeset 27329


Ignore:
Timestamp:
05/14/13 11:11:21 (8 years ago)
Author:
kjdon
Message:

changes to match mgpp's shortname mapping stuff. Changed some util functions to FileUtil functions

Location:
main/trunk/greenstone2/perllib
Files:
2 edited

Legend:

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

    r27301 r27329  
    4747no strict 'refs';
    4848use util;
     49use FileUtils;
    4950
    5051sub BEGIN {
     
    6465    # If ENABLE_LUCENE was turned off during GS compilation, then we won't be able to
    6566    # continue. Check for existence of LuceneWrapper to see if Lucene was disabled.
    66     my $lucene = &util::filename_cat($ENV{'GSDLHOME'},"bin","java","LuceneWrapper.jar");
     67    my $lucene = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"bin","java","LuceneWrapper3.jar");
    6768    if (! -f $lucene) {
    6869    die "***** ERROR: $lucene does not exist\n";     
     
    7475
    7576    # So where is lucene_passes.pl anyway?
    76     my $lucene_passes_script = &util::filename_cat($scriptdir, "lucene_passes.pl");
     77    my $lucene_passes_script = &FileUtils::filenameConcatenate($scriptdir, "lucene_passes.pl");
    7778
    7879    # So tack perl on the beginning to ensure execution
     
    109110    if (defined $buildcfg->{'indexfields'}) {
    110111    foreach $field (@{$buildcfg->{'indexfields'}}) {
    111         $self->{'buildproc'}->{'indexfields'}->{$field} = 1;
     112        # extraindexfields is only supposed to have extra ones in it, not those already specified in indexes. And this list has all indexes in it. But we do a check before including things from extraindexfields whether it was specified in indexes, so it all ok.
     113        $self->{'buildproc'}->{'extraindexfields'}->{$field} = 1;
    112114    }
    113115    }
     
    116118    foreach $field (@{$buildcfg->{'indexfieldmap'}}) {
    117119        my ($f, $v) = $field =~ /^(.*)\-\>(.*)$/;
    118         $self->{'buildproc'}->{'indexfieldmap'}->{$f} = $v;
    119         $self->{'buildproc'}->{'indexfieldmap'}->{$v} = 1;
     120        $self->{'buildproc'}->{'fieldnamemap'}->{$f} = $v;
     121        $self->{'buildproc'}->{'fieldnamemap'}->{$v} = 1;
     122        $self->{'buildproc'}->{'allindexfields'}->{$f} = 1;
    120123    }
    121124    }       
     
    151154
    152155    # the text directory
    153     my $text_dir = &util::filename_cat($self->{'build_dir'}, "text");
    154     my $build_dir = &util::filename_cat($self->{'build_dir'},"");
    155     &util::mk_all_dir ($text_dir);
     156    my $text_dir = &FileUtils::filenameConcatenate($self->{'build_dir'}, "text");
     157    my $build_dir = &FileUtils::filenameConcatenate($self->{'build_dir'},"");
     158    &FileUtils::makeAllDirectories ($text_dir);
    156159
    157160    my $osextra = "";
     
    209212    $self->{'buildproc'}->set_index ($textindex);
    210213    $self->{'buildproc'}->set_indexing_text (0);
    211     #$self->{'buildproc'}->set_indexfieldmap ($self->{'indexfieldmap'});
    212214    $self->{'buildproc'}->set_levels ($levels);
    213215    $self->{'buildproc'}->set_db_level ($db_level);
     
    306308    # get the full index directory path and make sure it exists
    307309    my $indexdir = $self->{'index_mapping'}->{$index};
    308     &util::mk_all_dir (&util::filename_cat($build_dir, $indexdir));
     310    &FileUtils::makeAllDirectories (&FileUtils::filenameConcatenate($build_dir, $indexdir));
    309311
    310312    # get any os specific stuff
     
    433435
    434436    # Get info database file path
    435     my $text_directory_path = &util::filename_cat($self->{'build_dir'}, "text");
     437    my $text_directory_path = &FileUtils::filenameConcatenate($self->{'build_dir'}, "text");
    436438    my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'infodbtype'}, $self->{'collection'}, $text_directory_path);
    437439
     
    460462    #    don't expect to pipe anything to the database so we can do away with the
    461463    #    complex output handle.
    462     my $assocdir = &util::filename_cat($self->{'build_dir'}, "assoc");
    463     &util::mk_all_dir ($assocdir);
     464    my $assocdir = &FileUtils::filenameConcatenate($self->{'build_dir'}, "assoc");
     465    &FileUtils::makeAllDirectories ($assocdir);
    464466    $self->{'buildproc'}->set_mode ('incinfodb'); # Very Important
    465467    $self->{'buildproc'}->set_assocdir ($assocdir);
  • main/trunk/greenstone2/perllib/lucenebuildproc.pm

    r24460 r27329  
    9696    my $lsec_level = $levels->{'section'};
    9797
    98     # gs2_id should be depricated #####
    99     my $gs2_id = "";
    100     if ($ldoc_level)
    101     {
    102     if ($self->{'db_level'} eq 'document')
    103     {
    104         $gs2_id = $self->{'num_docs'};
    105     }
    106         else
    107     {
    108         # default is section level
    109         $gs2_id = $self->{'num_sections'} + 1;
    110     }
    111     }
    11298    my $gs2_docOID = $doc_obj->get_OID();
    11399    my $documenttag = undef;
    114100    my $documentendtag = undef;
    115101
    116     #$documenttag = "<$doc_tag_name xmlns:gs2=\"http://www.greenstone.org/gs2\" file=\"$file\" gs2:id=\"$gs2_id\" gs2:docOID=\"$gs2_docOID\" gs2:mode=\"$edit_mode\">\n";
    117102    $documenttag = "<$doc_tag_name xmlns:gs2=\"http://www.greenstone.org/gs2\" file=\"$file\"  gs2:docOID=\"$gs2_docOID\" gs2:mode=\"$edit_mode\">\n";
    118103    $documentendtag = "\n</$doc_tag_name>\n";
     
    146131    if (($indexed_doc == 0) || ($indexed_section ne "indexed_section" && $indexed_section ne "indexed_doc")) {
    147132        if ($sec_tag_name ne "") {
    148         #$text .= "\n<$sec_tag_name gs2:id=\"$sec_gs2_id\" gs2:docOID=\"$sec_gs2_docOID\" gs2:mode=\"ignore\">\n";
    149133        $text .= "\n<$sec_tag_name  gs2:docOID=\"$sec_gs2_docOID\" gs2:mode=\"ignore\">\n";
    150134        $text .= "\n</$sec_tag_name>\n"
     
    156140    if ($sec_tag_name ne "")
    157141    {
    158         #$text .= "\n<$sec_tag_name gs2:id=\"$sec_gs2_id\" gs2:docOID=\"$sec_gs2_docOID\" gs2:mode=\"$edit_mode\">\n";
    159142        $text .= "\n<$sec_tag_name  gs2:docOID=\"$sec_gs2_docOID\" gs2:mode=\"$edit_mode\">\n";
    160143    }
     
    200183        my $shortname="";
    201184        my $new_field = 0; # have we found a new field name?
    202         if (defined $self->{'indexfieldmap'}->{$real_field}) {
    203         $shortname = $self->{'indexfieldmap'}->{$real_field};
    204         }
    205         else {
     185        if (defined $self->{'fieldnamemap'}->{$real_field}) {
     186        $shortname = $self->{'fieldnamemap'}->{$real_field};
     187        } else {
    206188        $shortname = $self->create_shortname($real_field);
    207         $new_field = 1;
    208         }
    209 
     189        $self->{'fieldnamemap'}->{$real_field} = $shortname;
     190        $self->{'fieldnamemap'}->{$shortname} = 1;
     191        }
    210192        my @metadata_list = (); # put any metadata values in here
    211193        my $section_text = ""; # put the text in here
     
    260242            # add the tag
    261243            $new_text = "<$shortname index=\"1\">$new_text</$shortname>";
     244            $self->{'allindexfields'}->{$real_field} = 1;
    262245        }
    263246        # filter the text
     
    271254            # delete
    272255            $self->{'num_processed_bytes'} -= length ($new_text);
    273         }
    274        
    275 
    276         if ($self->{'indexing_text'} && $new_field) {
    277             # we need to add to the list in indexfields
    278            
    279             $self->{'indexfieldmap'}->{$real_field} = $shortname;
    280             $self->{'indexfieldmap'}->{$shortname} = 1;
    281         }
    282        
     256        }       
    283257        }
    284258       
     
    302276        &ghtml::htmlsafe($mvalue);
    303277       
    304         if (defined $self->{'indexfieldmap'}->{$mfield}) {
    305             $shortname = $self->{'indexfieldmap'}->{$mfield};
     278        if (defined $self->{'fieldnamemap'}->{$mfield}) {
     279            $shortname = $self->{'fieldnamemap'}->{$mfield};
    306280        }
    307281        else {
    308282            $shortname = $self->create_shortname($mfield);
    309             $self->{'indexfieldmap'}->{$mfield} = $shortname;
    310             $self->{'indexfieldmap'}->{$shortname} = 1;
    311         }     
     283            $self->{'fieldnamemap'}->{$mfield} = $shortname;
     284            $self->{'fieldnamemap'}->{$shortname} = 1;
     285        }
     286        $self->{'allindexfields'}->{$mfield} = 1;
    312287        $new_text .= "<$shortname index=\"1\">$mvalue</$shortname>\n";
    313288        if ($allfields_index) {
     
    315290        }
    316291
    317         if (!defined $self->{'indexfields'}->{$mfield}) {
    318             $self->{'indexfields'}->{$mfield} = 1;
     292        if (!defined $self->{'extraindexfields'}->{$mfield}) {
     293            $self->{'extraindexfields'}->{$mfield} = 1;
    319294        }                   
    320295       
     
    334309
    335310    if ($allfields_index) {
    336         # add the index name mapping
    337         $self->{'indexfieldmap'}->{"allfields"} = "ZZ";
    338         $self->{'indexfieldmap'}->{"ZZ"} = 1;
    339311       
    340312        my $new_text = "<ZZ index=\"1\">$allfields_text</ZZ>\n";
Note: See TracChangeset for help on using the changeset viewer.