Changeset 15709


Ignore:
Timestamp:
2008-05-27T11:44:00+12:00 (16 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Updated the output_collection_meta() functions to use dbutil::write_infodb_entry(), so it isn't GDBM-specific.

Location:
gsdl/trunk/perllib
Files:
2 edited

Legend:

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

    r15700 r15709  
    3232use cfgread;
    3333use colcfg;
     34use dbutil;
    3435use plugin;
    3536use util;
    36 use FileHandle;
     37
    3738
    3839BEGIN {
     
    564565
    565566
    566 
    567 sub output_collection_meta_start {
     567sub get_collection_meta_sets
     568{
    568569    my $self = shift(@_);
    569     my ($handle) = @_;
    570    
    571     print $handle "[collection]\n";
    572 
    573 
    574 
    575 sub output_collection_meta_sets {
    576     my $self = shift(@_);
    577     my ($handle) = @_;
     570    my $collection_infodb = shift(@_);
    578571
    579572    my $mdprefix_fields = $self->{'buildproc'}->{'mdprefix_fields'};
    580 
    581573    foreach my $prefix (keys %$mdprefix_fields)
    582574    {
    583     print $handle "<metadataset>$prefix\n";
     575    push(@{$collection_infodb->{"metadataset"}}, $prefix);
    584576
    585577    foreach my $field (keys %{$mdprefix_fields->{$prefix}})
    586578    {
     579        push(@{$collection_infodb->{"metadatalist-$prefix"}}, $field);
     580
    587581        my $val = $mdprefix_fields->{$prefix}->{$field};
    588 
    589         print $handle "<metadatalist-$prefix>$field\n";
    590         print $handle "<metadatafreq-$prefix-$field>$val\n";
    591     }
    592 
    593     }
    594 
    595 
    596 
    597 sub output_collection_meta_end {
     582        push(@{$collection_infodb->{"metadatafreq-$prefix-$field"}}, $val);
     583    }
     584    }
     585}
     586
     587
     588# default is to output the metadata sets (prefixes) used in collection
     589sub output_collection_meta
     590{
    598591    my $self = shift(@_);
    599     my ($handle) = @_;
    600    
    601     print $handle ('-' x 70) . "\n";;
    602 
    603 
    604 
    605 
    606 # default is to output the metadata sets (prefixes) used in collection
    607 
    608 sub output_collection_meta {
    609     my $self = shift(@_);
    610     my ($handle) = @_;
    611 
    612     $self->output_collection_meta_start($handle);
    613     $self->output_collection_meta_sets($handle);
    614     $self->output_collection_meta_end($handle);
    615 
    616 
     592    my $infodb_handle = shift(@_);
     593
     594    my %collection_infodb = ();
     595    $self->get_collection_meta_sets(\%collection_infodb);
     596    &dbutil::write_infodb_entry($infodb_handle, "collection", \%collection_infodb);
     597}
     598
    617599
    618600sub print_stats {
  • gsdl/trunk/perllib/mgppbuilder.pm

    r15687 r15709  
    626626}   
    627627
    628 # now only outputs stuff if you can't generate it from collectionmeta - e.g. if someone has specified 'metadata' as an index.
    629 sub output_collection_meta {
     628
     629sub get_collection_meta_indexes
     630{
    630631    my $self = shift(@_);
    631     my ($handle) = @_;
     632    my $collection_infodb = shift(@_);
    632633
    633634    # define the indexed field mapping if not already done so (ie if infodb called separately from build_index)
     
    635636    $self->read_final_field_list();
    636637    }
    637 
    638     # do the collection info
    639     $self->output_collection_meta_start($handle);
    640     $self->output_collection_meta_sets($handle);
    641638
    642639    # first do the collection meta stuff - everything without a dot
     
    651648    #    <SU>Subject
    652649    # these now come from collection meta. if that is not defined, usses the metadata name
    653     my $field_entry="";
    654650    my $collmeta = "";
    655651    foreach my $longfield (@{$self->{'build_cfg'}->{'indexfields'}}){
     
    662658    if (!$collmetadefined || !defined $self->{'collect_cfg'}->{'collectionmeta'}->{$collmeta}) {
    663659        if ($longfield eq "allfields") {
    664         $field_entry .= "<$shortfield>_query:textallfields_\n";
     660        $collection_infodb->{$shortfield} = [ "_query:textallfields_" ];
    665661        } elsif ($longfield eq "text") {
    666         $field_entry .= "<$shortfield>_query:texttextonly_\n";
     662        $collection_infodb->{$shortfield} = [ "_query:texttextonly_" ];
    667663        } else {
    668         $field_entry .= "<$shortfield>$longfield\n";
    669         }
    670     }
    671     }
    672     print $handle $field_entry;
     664        $collection_infodb->{$shortfield} = [ $longfield ];
     665        }
     666    }
     667    }
    673668   
    674669    # now add the level names
     
    680675    if (!$collmetadefined || !defined $self->{'collect_cfg'}->{'collectionmeta'}->{$collmeta}) {
    681676        # use the default macro
    682         $level_entry .= "<$levelid>" . $level_map{$levelid} . "\n";
    683     }
    684     }
    685     print $handle $level_entry;
     677        $collection_infodb->{$levelid} = [ $level_map{$levelid} ];
     678    }
     679    }
    686680   
    687681    # now add subcoll meta
     
    692686    $shortname = $self->{'index_mapping'}->{$subcoll};
    693687    if (!$collmetadefined || !defined $self->{'collect_cfg'}->{'collectionmeta'}->{".$subcoll"}) {
    694         $subcoll_entry .= "<$shortname>$subcoll\n";
    695     }
    696     }
    697     print $handle $subcoll_entry;
     688        $collection_infodb->{$shortname} = [ $subcoll ];
     689    }
     690    }
    698691
    699692    # now add language meta
     
    702695    $shortname = $self->{'index_mapping'}->{$lang};
    703696    if (!$collmetadefined || !defined $self->{'collect_cfg'}->{'collectionmeta'}->{".$lang"}) {
    704         $lang_entry .= "<$shortname>$lang\n";
    705     }
    706     }
    707     print $handle "$lang_entry\n";
    708 
    709     $self->output_collection_meta_end($handle);
    710 }
     697        $collection_infodb->{$shortname} = [ $lang ];
     698    }
     699    }
     700}
     701
     702
     703# default is to output the metadata sets (prefixes) used in collection
     704sub output_collection_meta
     705{
     706    my $self = shift(@_);
     707    my $infodb_handle = shift(@_);
     708
     709    my %collection_infodb = ();
     710    $self->get_collection_meta_sets(\%collection_infodb);
     711    $self->get_collection_meta_indexes(\%collection_infodb);
     712    &dbutil::write_infodb_entry($infodb_handle, "collection", \%collection_infodb);
     713}
     714
    711715
    712716# at the end of building, we have an indexfieldmap with all the mappings,
Note: See TracChangeset for help on using the changeset viewer.