Changeset 19218


Ignore:
Timestamp:
2009-04-23T11:27:35+12:00 (15 years ago)
Author:
kjdon
Message:

do a bit more checking abotu whether indexes are assigned or not with mgpp, so we don't get empty indexes created when we hadn't asked for any

Location:
gsdl/trunk/perllib
Files:
2 edited

Legend:

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

    r18469 r19218  
    148148   
    149149    $self->generate_index_list();
    150  
    151     # sort out subcollection indexes
    152     if (defined $self->{'collect_cfg'}->{'indexsubcollections'}) {
    153     my $indexes = $self->{'collect_cfg'}->{'indexes'};
    154     $self->{'collect_cfg'}->{'indexes'} = [];
    155     foreach my $subcollection (@{$self->{'collect_cfg'}->{'indexsubcollections'}}) {
    156         foreach my $index (@$indexes) {
    157         push (@{$self->{'collect_cfg'}->{'indexes'}}, "$index:$subcollection");
    158         }
    159     }
    160     }
    161 
    162     # sort out language subindexes
    163     if (defined $self->{'collect_cfg'}->{'languages'}) {
    164     my $indexes = $self->{'collect_cfg'}->{'indexes'};
    165     $self->{'collect_cfg'}->{'indexes'} = [];
    166     foreach my $language (@{$self->{'collect_cfg'}->{'languages'}}) {
    167         foreach my $index (@$indexes) {
    168         if (defined ($self->{'collect_cfg'}->{'indexsubcollections'})) {
    169             push (@{$self->{'collect_cfg'}->{'indexes'}}, "$index:$language");
    170         }
    171         else { # add in an empty subcollection field
    172             push (@{$self->{'collect_cfg'}->{'indexes'}}, "$index\:\:$language");
     150    my $indexes = $self->{'collect_cfg'}->{'indexes'};
     151    if (defined $indexes) {
     152    # sort out subcollection indexes
     153    if (defined $self->{'collect_cfg'}->{'indexsubcollections'}) {
     154        $self->{'collect_cfg'}->{'indexes'} = [];
     155        foreach my $subcollection (@{$self->{'collect_cfg'}->{'indexsubcollections'}}) {
     156        foreach my $index (@$indexes) {
     157            push (@{$self->{'collect_cfg'}->{'indexes'}}, "$index:$subcollection");
    173158        }
    174159        }
    175160    }
    176     }
    177 
     161   
     162    # sort out language subindexes
     163    if (defined $self->{'collect_cfg'}->{'languages'}) {
     164        $indexes = $self->{'collect_cfg'}->{'indexes'};
     165        $self->{'collect_cfg'}->{'indexes'} = [];
     166        foreach my $language (@{$self->{'collect_cfg'}->{'languages'}}) {
     167        foreach my $index (@$indexes) {
     168            if (defined ($self->{'collect_cfg'}->{'indexsubcollections'})) {
     169            push (@{$self->{'collect_cfg'}->{'indexes'}}, "$index:$language");
     170            }
     171            else { # add in an empty subcollection field
     172            push (@{$self->{'collect_cfg'}->{'indexes'}}, "$index\:\:$language");
     173            }
     174        }
     175        }
     176    }
     177    }
     178   
    178179    if (defined($self->{'collect_cfg'}->{'indexes'})) {
    179180    # make sure that the same index isn't specified more than once
  • gsdl/trunk/perllib/mgppbuilder.pm

    r17574 r19218  
    9999    #indexes are specified with spaces, but we put them into one index
    100100    my $indexes = $self->{'collect_cfg'}->{'indexes'};
    101     $self->{'collect_cfg'}->{'indexes'} = [];
    102     push (@{$self->{'collect_cfg'}->{'indexes'}}, join(';', @$indexes).";");
     101    if (defined $indexes) {
     102    $self->{'collect_cfg'}->{'indexes'} = [];
     103    push (@{$self->{'collect_cfg'}->{'indexes'}}, join(';', @$indexes).";");
     104    }
    103105}
    104106
     
    282284    my %mapping = ();
    283285
     286    return \%mapping if !(scalar @$indexes);
     287
    284288    $mapping{'indexmaporder'} = [];
    285289    $mapping{'subcollectionmaporder'} = [];
     
    615619    # these now come from collection meta. if that is not defined, uses the metadata name
    616620    my $collmeta = "";
    617     foreach my $longfield (@{$self->{'build_cfg'}->{'indexfields'}}){
    618     my $shortfield = $self->{'buildproc'}->{'indexfieldmap'}->{$longfield};
    619     next if $shortfield eq 1;
    620    
    621     # we need to check if some coll meta has been defined - don't output
    622     # any that have
    623     $collmeta = ".$longfield";
    624     if (!$collmetadefined || !defined $self->{'collect_cfg'}->{'collectionmeta'}->{$collmeta}) {
    625         if ($longfield eq "allfields") {
    626         $collection_infodb->{$shortfield} = [ "_query:textallfields_" ];
    627         } elsif ($longfield eq "text") {
    628         $collection_infodb->{$shortfield} = [ "_query:texttextonly_" ];
    629         } else {
    630         $collection_infodb->{$shortfield} = [ $longfield ];
    631         }
    632     }
    633     }
    634    
     621    if (defined $self->{'build_cfg'}->{'indexfields'}) {
     622    foreach my $longfield (@{$self->{'build_cfg'}->{'indexfields'}}){
     623        my $shortfield = $self->{'buildproc'}->{'indexfieldmap'}->{$longfield};
     624        next if $shortfield eq 1;
     625       
     626        # we need to check if some coll meta has been defined - don't output
     627        # any that have
     628        $collmeta = ".$longfield";
     629        if (!$collmetadefined || !defined $self->{'collect_cfg'}->{'collectionmeta'}->{$collmeta}) {
     630        if ($longfield eq "allfields") {
     631            $collection_infodb->{$shortfield} = [ "_query:textallfields_" ];
     632        } elsif ($longfield eq "text") {
     633            $collection_infodb->{$shortfield} = [ "_query:texttextonly_" ];
     634        } else {
     635            $collection_infodb->{$shortfield} = [ $longfield ];
     636        }
     637        }
     638    }
     639    }
     640
    635641    # now add the level names
    636642    my $level_entry = "";
     
    747753    }
    748754
    749     $self->{'build_cfg'}->{'indexfieldmap'} = \@indexfieldmap;
    750     $self->{'build_cfg'}->{'indexfields'} = \@indexfields;
    751    
     755    if (scalar @indexfieldmap) {
     756    $self->{'build_cfg'}->{'indexfieldmap'} = \@indexfieldmap;
     757    }
     758    if (scalar @indexfields) {
     759    $self->{'build_cfg'}->{'indexfields'} = \@indexfields;
     760    }
    752761}
    753762
Note: See TracChangeset for help on using the changeset viewer.