Changeset 3872


Ignore:
Timestamp:
2003-03-13T12:16:00+13:00 (21 years ago)
Author:
kjdon
Message:

modified to reflect the use of collectionConfig.xml as well as buildConfig.xml

Location:
trunk/gsdl3/bin/script
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/bin/script/convert_coll_from_gs2.pl

    r3771 r3872  
    2323    print STDOUT "Usage: convert_coll_from_gs2.pl [options] coll-name\n";
    2424    print STDOUT "options:\n";
     25   
     26    print STDOUT "   -collectdir         Directory where collection lives.\n";
    2527   
    2628}
     
    5153
    5254    }
     55    $xmlcollconfigfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");
     56    my $xmlcollectcfg;
     57    if (-e $collconfigfilename) {
     58    $collectcfg = &colcfg::read_collect_cfg ($collconfigfilename);
     59
     60    }
     61   
     62
    5363    $buildconfigfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "building", "build.cfg");
    5464    my $buildcfg;
     
    7585
    7686    $writer->startTag('buildConfig');
    77  
    78     if (defined $collectcfg->{'collectionmeta'}) {
    79     my $collmeta = $collectcfg->{'collectionmeta'};
    80     $writer->startTag('metadataList');
    81     #just do collname for now
    82     my $collnames = $collmeta->{'collectionname'};
    83     foreach $lang (keys %$collnames) {
    84         my $short_lang;
    85         if ($lang eq 'default') {
    86         $short_lang = 'en';
    87         } else {
    88             ($short_lang) = $lang =~ /^\[l=(..)\]/;
    89         }
    90         $writer->startTag('metadata', 'lang'=>$short_lang, 'name'=>'collName');
    91         $writer->characters($collnames->{$lang});
    92         $writer->endTag('metadata');
    93     }
    94     my $collabouts = $collmeta->{'collectionextra'};
    95     foreach $lang (keys %$collabouts) {
    96         my $short_lang;
    97         if ($lang eq 'default') {
    98         $short_lang = 'en';
    99         } else {
    100             ($short_lang) = $lang =~ /^\[l=(..)\]/;
    101         }
    102         $writer->startTag('metadata', 'lang'=>$short_lang, 'name'=>'collDescript');
    103         $writer->characters($collabouts->{$lang});
    104         $writer->endTag('metadata');
    105     }
    106     $writer->endTag('metadataList');
    107     }
    108 
    109    
     87
     88#num docs
     89    my $numdocs = $buildcfg->{'numdocs'};
     90    $writer->startTag('metadataList');
     91    $writer->startTag('metadata',  'name'=>'numDocs');
     92    $writer->characters($numdocs);
     93    $writer->endTag('metadata');
     94    $writer->endTag('metadataList');
     95   
     96   
    11097    #indexes
    11198    my $indexmap = {};
     
    156143       
    157144            #fieldlist
     145        print STDOUT "trying fields\n";
     146        my $fieldmap = {};
     147        if (defined $buildcfg->{'indexfieldmap'}) {
     148        print STDOUT "doing fields\n";
     149        $fieldmap_t = $buildcfg->{'indexfieldmap'};
     150        foreach $f (@$fieldmap_t) {
     151            my ($k, $v) = $f =~ /^(.*)\-\>(.*)$/;
     152            $fieldmap->{$k} = $v;
     153        }
     154       
     155        $writer->startTag('fieldList');
     156        foreach $f (keys %$fieldmap) {
     157            $field = $fieldmap->{$f};
     158            $writer->emptyTag('field', 'shortname'=>$field, 'name'=>$f);
     159        }   
     160        $writer->endTag('fieldList');
     161        } else {
     162        print STDERR "indexfieldmap not defined";
     163        }
    158164       
    159165    } elsif ($buildtype eq 'mg') {
     
    198204        $started_classifiers = 1;
    199205        }
    200         my $title = ''; #use buttonname if defined, otherwise use metadata
     206        my $content = ''; #use metadata
    201207       
    202208        for ($i=0; $i<scalar(@$cl); $i++) {
    203209        $arg = @$cl[$i];
    204         if ($arg eq "-buttonname") {
    205             $title = @$cl[$i+1];
     210        if ($arg eq "-metadata") {
     211            $content = @$cl[$i+1];
    206212            last;
    207213        }
    208         if ($arg eq "-metadata") {
    209             $title = @$cl[$i+1];
    210         }
    211         }
    212 
    213         $writer->startTag('classifier', 'name'=>$name);
    214         $writer->startTag('metadataList');
    215         #title meta
    216         $writer->startTag('metadata', 'name'=>'Title');
    217         $writer->characters($title);
    218         $writer->endTag('metadata');
    219         $writer->endTag('metadataList');
    220         $writer->endTag('classifier');
    221        
     214        }
     215
     216        $writer->emptyTag('classifier', 'name'=>$name, 'content'=>$content);
    222217       
    223218    } #foreach classifier
  • trunk/gsdl3/bin/script/gs2_mkcol.pl

    r3771 r3872  
    125125        $line =~ s/\*\*defaultindex\*\*/$defaultindex/g;
    126126        $line =~ s/\*\*indexmeta\*\*/$indexmeta/g;
    127 
     127        $line =~ s/\*\*xmlindexes\*\*/$xmlindexes/g;
     128        $line =~ s/\*\*xmlplugins\*\*/$xmlpluginstring/g;
     129       
    128130        print OUTFILE $line;
    129131        }
     
    239241    # get the strings to include.
    240242    $pluginstring = "";
     243    $xmlpluginstring = "";
    241244    foreach $plugin (@plugin) {
    242245    if ($plugin eq RecPlug) {
    243246        $pluginstring .= "plugin         $plugin -use_metadata_files\n";
     247        $xmlpluginstring .= "<plugin name='$plugin'><option name='use_metadata_files'/></plugin>\n";
    244248    } else {
    245249        $pluginstring .= "plugin         $plugin\n";
     250        $xmlpluginstring .= "<plugin name='$plugin'/>\n";
    246251    }
    247252    }
     
    269274
    270275    # set up the default indexes - this could be a command line option at some stage
     276    # the names are added in here for the xml ones, but they should be added after building once the names are known.
    271277    if ($buildtype eq "mg") {
    272278    $indexes = "document:text document:Title document:Source";
     
    274280    $indexmeta = "collectionmeta .document:text    \"text\"\ncollectionmeta .document:Title  \"titles\"\ncollectionmeta .document:Source  \"filenames\"\n";
    275281
     282    $xmlindexes = "<index name='dtx' content='text' level='Document'><displayName lang='en'>text</displayName></index>\n<index name='dtt' content='Title' level='Document'><displayName lang='en'>titles</displayName></index>\n<index name='dsr' content='Source' level='Document'><displayName lang='en'>filenames</displayName></index>";
    276283    } elsif ($buildtype eq "mgpp") {
    277284    $indexes = "text,metadata";
    278285    $defaultindex = "text,metadata";
    279286    $indexmeta = "collectionmeta .text,metadata    \"text\"\n";
     287    $xmlindexes = "<index name='tm' content='text,metadata' level='Document'><displayName lang='en'>text</displayName></index>";
    280288    } else {
    281289    print STDOUT "Error: buildtype should be mg or mgpp, but its $buildtype\n";
Note: See TracChangeset for help on using the changeset viewer.