root/main/trunk/greenstone2/perllib/buildConfigxml.pm @ 25758

Revision 25758, 21.9 KB (checked in by sjm84, 8 years ago)

Some fixes for Solr

  • Property svn:keywords set to Author Date Id Revision
Line 
1###########################################################################
2#
3# buildConfigxml.pm --
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26# reads in buildConfig.xml
27# Note, only implemented the bits that are currently used, eg by incremental
28# build code.
29# The resulting data is not a full representation on buildConfig.xml.
30
31package buildConfigxml;
32
33use strict;
34no strict 'refs';
35no strict 'subs';
36
37use XMLParser;
38
39
40# A mapping hash to resolve name discrepancy between gs2 and gs3.
41my $nameMap = {"numDocs" => "numdocs",
42           "buildType" => "buildtype",
43           "orthogonalBuildTypes" => "orthogonalbuildtypes"
44           };
45
46
47# A hash structure which is returned by sub read_cfg_file.
48my $data = {};
49
50# use those unique attribute values to locate the text within the elements
51my $currentLocation = "";
52my $stringexp = q/^(buildType|numDocs)$/;
53my $arrayexp = q/^(orthogonalBuildTypes)$/;
54
55my $indexmap_name = "";
56my $haveindexfields = 0;
57
58# Reads in the model collection configuration file, collectionConfig.xml,
59# into a structure which complies with the one used by gs2 (i.e. one read
60# in by &cfgread::read_cfg_file).
61sub read_cfg_file {
62    my ($filename) = @_;
63    $data = {};
64    if ($filename !~ /buildConfig\.xml$/ || !-f $filename) {
65        return undef;
66    }
67
68    # Removed ProtocolEncoding (see MetadataXMLPlugin for details)
69
70    # create XML::Parser object for parsing metadata.xml files
71    my $parser = new XML::Parser('Style' => 'Stream',
72                 'Pkg' => 'buildConfigxml',
73                 'Handlers' => {'Char' => \&Char,
74                         'Doctype' => \&Doctype
75                         });
76
77    if (!open (COLCFG, $filename)) {
78    print STDERR "buildConfigxml::read_cfg_file couldn't read the cfg file $filename\n";
79    } else {
80
81      $parser->parsefile ($filename);# (COLCFG);
82      close (COLCFG);
83    }
84
85    #&Display;
86    return $data;
87}
88
89sub StartTag {
90# Those marked with #@ will not be executed at the same time when this sub is being called
91# so that if/elsif is used to avoid unnecessary tests
92    my ($expat, $element) = @_;
93   
94    my $name = $_{'name'};
95    my $shortname = $_{'shortname'};
96
97   
98    #@ handling block metadataList
99    if (defined $name && (($name =~ m/$stringexp/) || ($name =~ m/$arrayexp/))) {
100      $currentLocation = $name;
101      # the value will be retrieved later in Text sub
102    }
103
104    #@ handle indexes - store indexmap (mg) or indexfields and indexfieldmap (mgpp/lucene/solr)
105    elsif ($element =~ /^indexList$/) {
106    # set up the data arrays
107    # this assumes that the build type has been read already, which is
108    # currently the order we save the file in.
109    if ($data->{'buildtype'} eq "mg") {
110        $indexmap_name = "indexmap";
111        if (!defined $data->{"indexmap"}) {
112        $data->{"indexmap"} = [];
113        }
114    }
115    else {
116        # mgpp, lucene or solr
117        $indexmap_name = "indexfieldmap";
118        $haveindexfields = 1;
119        if (!defined $data->{"indexfieldmap"}) {
120        $data->{"indexfieldmap"} = [];
121        }
122        if (!defined $data->{"indexfields"}) {
123        $data->{"indexfields"} = [];
124        }
125
126    }
127   
128    }
129   
130    elsif ($element =~ /index/) {
131    # store each index in the map
132    if (defined $name && defined $shortname) {
133        push @{$data->{$indexmap_name}}, "$name->$shortname";
134        if ($haveindexfields) {
135        push @{$data->{'indexfields'}}, $name;
136        }
137    }
138    }
139
140
141}
142
143sub EndTag {
144    my ($expat, $element) = @_;
145}
146
147sub Text {
148    if (defined $currentLocation) {
149    #@ Handling block metadataList(numDocs, buildType)
150    if ($currentLocation =~ /$stringexp/) {
151        #print $currentLocation;
152        my $key = $nameMap->{$currentLocation};
153        $data->{$key} = $_;
154        undef $currentLocation;
155    }   
156    elsif ($currentLocation =~ /$arrayexp/) {
157        #print $currentLocation;
158        my $key = $nameMap->{$currentLocation};
159        push(@{$data->{$key}},$_);
160        undef $currentLocation;
161    }   
162
163    }   
164}
165
166# This sub is for debugging purposes
167sub Display {
168
169    print "NumDocs = ".$data->{'numdocs'}."\n" if (defined $data->{'numdocs'});
170    print "BuildType = ".$data->{'buildtype'}."\n" if (defined $data->{'buildtype'});
171    print "OrthogonalBuildTypes = ".join(",",@{$data->{'orthogonalbuildtypes'}})."\n" if (defined $data->{'orthogonalbuildtypes'});
172    print  "IndexMap = ". join(" ",@{$data->{'indexmap'}})."\n" if (defined $data->{'indexmap'});
173    print  "IndexFieldMap = ". join(" ",@{$data->{'indexfieldmap'}})."\n" if (defined $data->{'indexfieldmap'});
174    print  "IndexFields = ". join(" ",@{$data->{'indexfields'}})."\n" if (defined $data->{'indexfields'});
175
176}
177
178# is this actually used??
179sub Doctype {
180    my ($expat, $name, $sysid, $pubid, $internal) = @_;
181
182    die if ($name !~ /^buildConfig$/);
183}
184
185# This Char function overrides the one in XML::Parser::Stream to overcome a
186# problem where $expat->{Text} is treated as the return value, slowing
187# things down significantly in some cases.
188sub Char {
189    if ($]<5.008) {
190    use bytes;  # Necessary to prevent encoding issues with XML::Parser 2.31+ and Perl 5.6
191    }
192    $_[0]->{'Text'} .= $_[1];
193    return undef;
194}
195
196
197
198sub write_line {
199    my ($filehandle, $line) = @_;
200    print $filehandle join ("", @$line), "\n";
201}
202
203sub search_and_retrieve_settings
204{
205    my ($buildcfg,$collectcfg) = @_;
206
207    my $settings = {};
208
209    if (defined $buildcfg->{"buildtype"}) {
210    $settings->{'buildtype'} = $buildcfg->{"buildtype"};
211    } else {
212    $settings->{'buildtype'} = "mgpp";
213    }
214    my $buildtype = $settings->{'buildtype'};
215
216    if (defined $collectcfg->{"orthogonalbuildtypes"}) {
217    # Note the use of collectcfg, not bulidcfg
218    $settings->{'orthogonalbuildtypes'} = $collectcfg->{"orthogonalbuildtypes"};
219    } else {
220    $settings->{'orthogonalbuildtypes '}= [];
221    }
222
223    if (defined $buildcfg->{"numdocs"}) {
224    $settings->{'numdocs'} = $buildcfg->{"numdocs"};
225    }
226    else {
227    $settings->{'numdocs'} = 0;
228    }
229
230    my $service_type = "MGPP";
231    if ($buildtype eq "mg") {
232    $service_type = "MG";
233    } elsif ($buildtype eq "lucene") {
234    $service_type = "Lucene";
235    } elsif ($buildtype eq "solr") {
236    $service_type = "Solr";
237    }
238    $settings->{'service_type'} = $service_type;
239
240
241    if (defined $buildcfg->{"infodbtype"}) {
242    $settings->{'infodbtype'} = $buildcfg->{'infodbtype'};
243    }
244    else {
245    $settings->{'infodbtype'} = "gdbm";
246    }
247
248
249    #--
250    # indexes
251    #--
252   
253    my $indexmap = {};  # maps index name to shortname
254    my $indexlist = []; # keeps the order for indexes
255    my $defaultindex = "";
256    my $maptype = ($buildtype eq "mg")  ? "indexmap" : "indexfieldmap";
257
258    if (defined $buildcfg->{$maptype}) {
259    my $first = 1;
260    my $indexmap_t = $buildcfg->{$maptype};
261    foreach my $i (@$indexmap_t) {
262        my ($k, $v) = $i =~ /^(.*)\-\>(.*)$/;
263        $indexmap->{$k} = $v;
264        push @$indexlist, $k;
265        if ($first) {
266        $defaultindex = $v;
267        $first = 0;
268        }
269    }
270       # now if the user has assigned a default index, we use it
271    if (defined $collectcfg->{"defaultindex"}) {
272        $defaultindex = $indexmap->{$collectcfg->{"defaultindex"}};
273    }
274    } else {
275    print STDERR "$maptype not defined";
276    }
277
278    $settings->{'defaultindex'} = $defaultindex;
279    $settings->{'indexmap'} = $indexmap;
280    $settings->{'indexlist'} = $indexlist;
281
282    #--
283    # default lang
284    #--
285    $settings->{'default_lang'} = "";
286    $settings->{'default_lang_short'} = "";
287
288    if (defined $buildcfg->{"languagemap"}) {
289      my $langmap_t = $buildcfg->{"languagemap"};
290      if ((defined $langmap_t) && (scalar(@$langmap_t)>=1)) {
291      my $l = $langmap_t->[0];
292      my ($k, $v) = $l =~ m/^(.*)\-\>(.*)$/;
293      $settings->{'default_lang'} = $k; #name
294      $settings->{'default_lang_short'} = $v; #short name
295      }
296
297      # now if the user has assigned a default language (as "en", "ru" etc.)
298      if (defined $collectcfg->{"defaultlanguage"}) {
299    $settings->{'default_lang'} = $collectcfg->{"defaultlanguage"};
300    # what about default_lang_short ?? ####
301      }
302    }
303
304    # default subcol
305    $settings->{'default_subcol'} = "";
306    if (defined $buildcfg->{'subcollectionmap'}) {
307    my $subcolmap_t = $buildcfg->{'subcollectionmap'};
308    if ((defined $subcolmap_t) && (scalar(@$subcolmap_t)>=1)) {
309        my $l = $subcolmap_t->[0];
310        my ($k, $v) = $l =~ m/^(.*)\-\>(.*)$/;
311
312        $settings->{'default_subcol'} = $v;
313    }
314    }
315
316
317    #--
318    # indexstem
319    #--
320    if (defined $buildcfg->{'indexstem'}) {
321    $settings->{'indexstem'} = $buildcfg->{'indexstem'};
322    }
323
324    #--
325    # levelList
326    #--
327
328    my $levelmap = {};
329    my $levellist = [];
330    my $default_search_level = "Doc";
331    my $default_retrieve_level = "Doc";
332    my $default_db_level = "Doc";
333
334    if ($buildtype eq "mgpp" || $buildtype eq "lucene" || $buildtype eq "solr") {
335    if (defined $buildcfg->{'levelmap'}) {
336        my $first = 1;
337
338        my $levelmap_t = $buildcfg->{'levelmap'};
339        foreach my $l (@$levelmap_t) {
340        my ($key, $val) = $l =~ /^(.*)\-\>(.*)$/;
341        $levelmap->{$key} = $val;
342        push @$levellist, $key;
343        if ($first) {
344            # let default search level follow the first level in the level list
345            $default_search_level = $val;
346            # retrieve/database levels may get modified later if text level is defined
347            $default_retrieve_level = $val;
348            $default_db_level = $val;
349            $first = 0;
350        }
351        }
352    }
353    # the default level assigned by the user is no longer ignored [Shaoqun], but the retrievel level stays the same.
354        #if (defined $collectcfg->{"defaultlevel"}) {
355    $default_search_level = $levelmap->{$collectcfg->{"defaultlevel"}};
356        #  $default_retrieve_level = $default_search_level;
357    #}
358   
359    if (defined $buildcfg->{'textlevel'}) {
360       # let the retrieve/database levels always follow the textlevel
361           $default_retrieve_level = $buildcfg->{'textlevel'};
362       $default_db_level = $buildcfg->{'textlevel'};
363         
364    }
365    }
366    $settings->{'levelmap'} = $levelmap;
367    $settings->{'levellist'} = $levellist;
368    $settings->{'default_search_level'} = $default_search_level;
369    $settings->{'default_retrieve_level'} = $default_retrieve_level;
370    $settings->{'default_db_level'} = $default_db_level;
371
372   
373    return $settings;
374}
375
376
377sub write_search_servicerack
378{
379    my ($buildcfg,$settings) = @_;
380
381    my $buildtype    = $settings->{'buildtype'};
382    my $infodbtype   = $settings->{'infodbtype'};
383    my $service_type = $settings->{'service_type'};
384
385    # do the search service
386    &write_line('COLCFG', ["<serviceRack name=\"GS2", $service_type, "Search\">"]);
387    if (defined $buildcfg->{'indexstem'}) {
388      my $indexstem = $buildcfg->{'indexstem'};
389      &write_line('COLCFG', ["<indexStem name=\"", $indexstem, "\" />"]);     
390    }
391    if (defined $buildcfg->{'infodbtype'}) {
392        &write_line('COLCFG', ["<databaseType name=\"", $infodbtype, "\" />"]);     
393    }
394
395    #indexes
396    my $indexmap = $settings->{'indexmap'};
397    my $indexlist = $settings->{'indexlist'};
398    my $defaultindex = $settings->{'defaultindex'};
399
400    #for each index in indexList, write them out
401    &write_line('COLCFG', ["<indexList>"]);
402    foreach my $i (@$indexlist) {
403    my $index = $indexmap->{$i};
404    &write_line('COLCFG', ["<index name=\"", $i, "\" ", "shortname=\"", $index, "\" />"]);
405    }   
406    &write_line('COLCFG', ["</indexList>"]);
407
408   
409    #$defaultindex = "ZZ" if (!$defaultindex); # index allfields by default
410    if ($defaultindex) {
411    &write_line('COLCFG', ["<defaultIndex shortname=\"", $defaultindex, "\" />"]);
412    }
413
414
415    # do indexOptionList
416    if ($buildtype eq "mg" || $buildtype eq "mgpp") {
417        &write_line('COLCFG', ["<indexOptionList>"]);
418    my $stemindexes = 3; # default is stem and casefold
419    if (defined $buildcfg->{'stemindexes'} && $buildcfg->{'stemindexes'} =~ /^\d+$/ ) {
420        $stemindexes = $buildcfg->{'stemindexes'};
421    }
422    &write_line('COLCFG', ["<indexOption name=\"stemIndexes\" value=\"", $stemindexes, "\" />"]);
423   
424    my $maxnumeric = 4; # default
425    if (defined $buildcfg->{'maxnumeric'} && $buildcfg->{'maxnumeric'} =~ /^\d+$/) {
426        $maxnumeric = $buildcfg->{'maxnumeric'};
427    }
428    &write_line('COLCFG', ["<indexOption name=\"maxnumeric\" value=\"", $maxnumeric, "\" />"]);
429        &write_line('COLCFG', ["</indexOptionList>"]);
430    }
431
432    #--
433    # levelList
434    #--
435    my $levelmap = $settings->{'levelmap'};
436    my $levellist = $settings->{'levellist'};
437    my $default_search_level = $settings->{'default_search_level'};
438    my $default_retrieve_level = $settings->{'default_retrieve_level'};
439    my $default_db_level = $settings->{'default_db_level'};
440
441    #for each level in levelList, write them out
442    if ($buildtype ne "mg") {
443    &write_line('COLCFG', ["<levelList>"]);
444    foreach my $lv (@$levellist) {
445        my $level = $levelmap->{$lv};
446        &write_line('COLCFG', ["<level name=\"", $lv, "\" shortname=\"", $level, "\" />"]);
447    }   
448    &write_line('COLCFG', ["</levelList>"]);
449    }
450    # add in defaultLevel as the same level as indexLevelList, making the reading job easier
451    if ($buildtype eq "lucene" || $buildtype eq "mgpp" || $buildtype eq "solr") {
452    &write_line('COLCFG', ["<defaultLevel shortname=\"", $default_search_level, "\" />"]);
453    }
454    if ($buildtype eq "lucene" || $buildtype eq "mgpp" || $buildtype eq "solr") {
455        &write_line('COLCFG', ["<defaultDBLevel shortname=\"", $default_db_level, "\" />"]);
456    }
457    # do searchTypeList
458    if ($buildtype eq "mgpp" || $buildtype eq "lucene" || $buildtype eq "solr") {
459      &write_line('COLCFG', ["<searchTypeList>"]);
460     
461      if (defined $buildcfg->{"searchtype"}) {
462      my $searchtype_t = $buildcfg->{"searchtype"};
463      foreach my $s (@$searchtype_t) {
464      &write_line('COLCFG', ["<searchType name=\"", $s, "\" />"]);
465    }
466      } else {
467      &write_line('COLCFG', ["<searchType name=\"plain\" />"]);
468      &write_line('COLCFG', ["<searchType name=\"form\" />"]);
469      }
470      &write_line('COLCFG', ["</searchTypeList>"]);
471    }
472
473    # do indexLanguageList [in collect.cfg: languages; in build.cfg: languagemap]
474    my $default_lang = $settings->{'default_lang'};
475    my $default_lang_short = $settings->{'default_lang_short'};
476    if (defined $buildcfg->{"languagemap"}) {
477      &write_line('COLCFG', ["<indexLanguageList>"]);
478
479      my $langmap_t = $buildcfg->{"languagemap"};
480      foreach my $l (@$langmap_t) {
481    my ($k, $v) = $l =~ /^(.*)\-\>(.*)$/;
482
483    &write_line('COLCFG', ["<indexLanguage name=\"", $k, "\" shortname=\"", $v, "\" />"]);
484      }
485
486      &write_line('COLCFG', ["</indexLanguageList>"]);
487
488      &write_line('COLCFG', ["<defaultIndexLanguage name=\"", $default_lang, "\" shortname=\"", $default_lang_short, "\" />"]);
489    }
490
491    # do indexSubcollectionList
492    my $default_subcol = $settings->{'default_subcol'};
493
494    if (defined $buildcfg->{'subcollectionmap'}) {
495      &write_line('COLCFG', ["<indexSubcollectionList>"]);
496      my $subcolmap = {};
497      my @subcollist = ();
498
499      my $subcolmap_t = $buildcfg->{'subcollectionmap'};
500      foreach my $l (@$subcolmap_t) {
501    my ($k, $v) = $l =~ /^(.*)\-\>(.*)$/;
502    $subcolmap->{$k} = $v;
503    push @subcollist, $k;
504      }
505
506      foreach my $sl (@subcollist) {
507    my $subcol = $subcolmap->{$sl};
508    &write_line('COLCFG', ["<indexSubcollection name=\"", $sl, "\" shortname=\"", $subcol, "\" />"]);
509      }
510
511      &write_line('COLCFG', ["</indexSubcollectionList>"]);
512      &write_line('COLCFG', ["<defaultIndexSubcollection shortname=\"", $default_subcol, "\" />"]);
513    }
514     
515    # close off search service
516    &write_line('COLCFG', ["</serviceRack>"]);
517
518}
519
520
521sub write_orthogonalsearch_serviceracks
522{
523    my ($buildcfg,$settings) = @_;
524
525    my $infodbtype   = $settings->{'infodbtype'};
526
527    my $orthogonalbuildtypes = $settings->{'orthogonalbuildtypes'};
528
529    foreach my $obt (@$orthogonalbuildtypes) {
530    $obt =~ s/^(.)/\u$1/; # capitialize initial letter
531    $obt =~ s/-(.)/\u$1/g; # change any hyphenated words to cap next letter
532
533    &write_line('COLCFG', ["<serviceRack name=\"GS2", $obt, "Search\">"]);
534
535    &write_line('COLCFG',["<databaseType name=\"",$infodbtype,"\" />"]); 
536    &write_line('COLCFG', ["</serviceRack>"]);
537    }
538}
539
540
541
542sub write_retrieve_servicerack
543{
544    my ($buildcfg,$settings) = @_;
545
546    my $buildtype      = $settings->{'buildtype'};
547    my $infodbtype     = $settings->{'infodbtype'};
548   
549    my $service_type   = $settings->{'service_type'};
550
551    # do the retrieve service
552    &write_line('COLCFG', ["<serviceRack name=\"GS2", $service_type, "Retrieve\">"]);
553
554    # do default index
555    if (defined $buildcfg->{"languagemap"}) {
556    my $default_lang   = $settings->{'default_lang'};
557    &write_line('COLCFG', ["<defaultIndexLanguage shortname=\"", $default_lang, "\" />"]);
558    }
559    if (defined $buildcfg->{'subcollectionmap'}) {
560    my $default_subcol = $settings->{'default_subcol'};
561    &write_line('COLCFG', ["<defaultIndexSubcollection shortname=\"", $default_subcol, "\" />"]);
562    }
563    if ($buildtype eq "mg") {
564    my $defaultindex   = $settings->{'defaultindex'};
565      &write_line('COLCFG', ["<defaultIndex shortname=\"", $defaultindex, "\" />"]);
566    }
567
568    if (defined $buildcfg->{'indexstem'}) {
569      my $indexstem = $buildcfg->{'indexstem'};
570      &write_line('COLCFG', ["<indexStem name=\"", $indexstem, "\" />"]);     
571    }
572    if ($buildtype eq "mgpp" || $buildtype eq "lucene" || $buildtype eq "solr") {
573    my $default_retrieve_level = $settings->{'default_retrieve_level'};
574      &write_line('COLCFG', ["<defaultLevel shortname=\"", $default_retrieve_level, "\" />"]);
575    }
576    if (defined $buildcfg->{'infodbtype'}) {
577        &write_line('COLCFG', ["<databaseType name=\"", $infodbtype, "\" />"]);     
578    }
579
580    &write_line('COLCFG', ["</serviceRack>"]);
581
582}
583
584
585# Create the buildConfig.xml file for a specific collection
586sub write_cfg_file {
587    # this sub is called in make_auxiliary_files() in basebuilder.pm
588    # the received args: $buildoutfile - destination file: buildConfig.xml
589    #                    $buildcfg - all build options,
590    #                    $collectcfg - contents of collectionConfig.xml read in by read_cfg_file sub in buildConfigxml.pm.
591    my ($buildoutfile, $buildcfg, $collectcfg) = @_;
592    my $line = [];
593
594    if (!open (COLCFG, ">$buildoutfile")) {
595    print STDERR "buildConfigxml::write_cfg_file couldn't write the build config file $buildoutfile\n";
596    die;
597    }
598
599    my $settings = search_and_retrieve_settings($buildcfg,$collectcfg);
600
601    my $buildtype = $settings->{'buildtype'};
602    my $orthogonalbuildtypes = $settings->{'orthogonalbuildtypes'};
603    my $numdocs = $settings->{'numdocs'};
604
605    &write_line('COLCFG', ["<buildConfig xmlns:gsf=\"http://www.greenstone.org/greenstone3/schema/ConfigFormat\">"]); 
606
607    # output building metadata to build config file
608    &write_line('COLCFG', ["<metadataList>"]);
609    &write_line('COLCFG', ["<metadata name=\"numDocs\">", $numdocs, "</metadata>"]);
610    &write_line('COLCFG', ["<metadata name=\"buildType\">", $buildtype, "</metadata>"]);
611    foreach my $obt (@$orthogonalbuildtypes) {
612    &write_line('COLCFG', ["<metadata name=\"orthogonalBuildTypes\">", $obt, "</metadata>"]);
613    }
614
615    if (defined $buildcfg->{'indexstem'}) {
616    &write_line('COLCFG', ["<metadata name=\"indexStem\">", $buildcfg->{"indexstem"}, "</metadata>"]);
617    }
618    if (defined $buildcfg->{'infodbtype'}) {
619    &write_line('COLCFG', ["<metadata name=\"infodbType\">", $buildcfg->{"infodbtype"}, "</metadata>"]);
620    }
621    if (defined $buildcfg->{'earliestdatestamp'}) {
622    &write_line('COLCFG', ["<metadata name=\"earliestdatestamp\">", $buildcfg->{"earliestdatestamp"}, "</metadata>"]);
623    }
624
625    &write_line('COLCFG', ["</metadataList>"]);
626
627    # output serviceRackList
628    &write_line('COLCFG', ["<serviceRackList>"]);
629
630    write_search_servicerack($buildcfg,$settings);
631
632    # add in orthogonalbuildtypes
633    write_orthogonalsearch_serviceracks($buildcfg,$settings);
634
635    write_retrieve_servicerack($buildcfg,$settings);
636
637    # do the browse service
638    my $count = 1;
639    my $phind = 0;
640    my $started_classifiers = 0;
641
642    my $classifiers = $collectcfg->{"classify"};
643    foreach my $cl (@$classifiers) {
644      my $name = "CL$count";
645      $count++;
646      my ($classname) = @$cl[0];
647      if ($classname =~ /^phind$/i) {
648    $phind=1;
649    #should add it into coll config classifiers
650    next;
651      }
652     
653      if (not $started_classifiers) {
654    &write_line('COLCFG', ["<serviceRack name=\"GS2Browse\">"]);
655    if (defined $buildcfg->{'indexstem'}) {
656      my $indexstem = $buildcfg->{'indexstem'};
657      &write_line('COLCFG', ["<indexStem name=\"", $indexstem, "\" />"]);     
658    }
659    if (defined $buildcfg->{'infodbtype'}) {
660        my $infodbtype = $buildcfg->{'infodbtype'};
661        &write_line('COLCFG', ["<databaseType name=\"", $infodbtype, "\" />"]);     
662    }
663    &write_line('COLCFG', ["<classifierList>"]);       
664    $started_classifiers = 1;
665      }
666      my $content = ''; #use buttonname first, then metadata
667      if ($classname eq "DateList") {
668    $content = "Date";
669      } else {
670    for (my $j=0; $j<scalar(@$cl); $j++) {
671      my $arg = @$cl[$j];
672      if ($arg eq "-buttonname"){
673        $content = @$cl[$j+1];
674        last;
675      } elsif ($arg eq "-metadata") {
676        $content = @$cl[$j+1];
677      }
678     
679    }
680      }
681      &write_line('COLCFG', ["<classifier name=\"", $name, "\" content=\"", $content, "\" />"]);
682    }     
683    if ($started_classifiers) {
684      # end the classifiers
685      &write_line('COLCFG', ["</classifierList>"]);
686      # close off the Browse service
687      &write_line('COLCFG', ["</serviceRack>"]);
688    }
689   
690    # the phind classifier is a separate service
691    if ($phind) {
692    # if phind classifier
693    &write_line('COLCFG', ["<serviceRack name=\"PhindPhraseBrowse\" />"]);
694    }
695
696   
697    &write_line('COLCFG', ["</serviceRackList>"]);
698    &write_line('COLCFG', ["</buildConfig>"]);
699
700    close (COLCFG);
701  }
702
703
704#########################################################
705
7061;
Note: See TracBrowser for help on using the browser.