Changeset 4969
- Timestamp:
- 2003-07-17T12:10:26+12:00 (21 years ago)
- Location:
- trunk/gsdl3/bin/script
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/bin/script/convert_coll_from_gs2.pl
r4888 r4969 20 20 21 21 print STDOUT " -collectdir Directory where collection lives.\n"; 22 print STDOUT " -verbosity Controls the amount of output.\n\n"; 22 print STDOUT " -verbosity Controls the amount of output.\n"; 23 print STDOUT " -defaultlang The language that is considered the default (for display text etc). defaults to 'en'\n\n"; 23 24 } 24 25 25 26 sub main { 26 27 27 my $defaultlang = 'en'; 28 my ($collectdir); 28 my ($defaultlang, $verbosity, $collectdir); 29 29 # note that no defaults are passed for most options as they're set 30 30 # later (after we check the collect.cfg file) 31 if (!parsargv::parse(\@ARGV, 32 'verbosity/\d+/', \$verbosity, 33 'collectdir/.*/', \$collectdir)) { 31 if (!&parsargv::parse(\@ARGV, 32 'verbosity/\d+/', \$verbosity, 33 'collectdir/.*/', \$collectdir, 34 'defaultlang/.*/', \$defaultlang)) { 34 35 &print_usage(); 35 36 die "\n"; … … 37 38 38 39 # get and check the collection name 39 if (($collection = &util::use_collection(@ARGV, $collectdir)) eq "") { 40 &print_usage(); 41 die "\n"; 42 } 43 44 $collconfigfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg"); 40 my ($collection) = @ARGV; 41 if (!defined($collection) || $collection eq "") { 42 die "No collection specified\n"; 43 } 44 if ($collection eq "gs2model") { 45 die "You cant convert the model collection\n"; 46 } 47 48 if (!defined $collectdir || $collectdir eq "") { 49 $collectdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect"); 50 } 51 52 if (!defined $defaultlang || $defaultlang eq "") { 53 $defaultlang = 'en'; 54 } 55 # add on the coll name 56 $collectdir = &util::filename_cat ($collectdir, $collection); 57 58 $collconfigfilename = &util::filename_cat ($collectdir, "etc", "collect.cfg"); 59 print STDOUT "coll config=$collconfigfilename\n"; 45 60 my $collectcfg; 46 61 if (-e $collconfigfilename) { … … 53 68 54 69 55 $buildconfigfilename = &util::filename_cat ($ ENV{'GSDLCOLLECTDIR'}, "index", "build.cfg");70 $buildconfigfilename = &util::filename_cat ($collectdir, "index", "build.cfg"); 56 71 my $buildcfg; 57 72 if (-e $buildconfigfilename) { … … 65 80 66 81 67 my $colloutfile = &util::filename_cat ($ ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");82 my $colloutfile = &util::filename_cat ($collectdir, "etc", "collectionConfig.xml"); 68 83 if (-e $colloutfile) { 69 84 print STDOUT "collectionConfig file already exists! overwriting it!\n"; … … 71 86 } 72 87 73 my $buildoutfile = &util::filename_cat ($ ENV{'GSDLCOLLECTDIR'}, "index", "buildConfig.xml");88 my $buildoutfile = &util::filename_cat ($collectdir, "index", "buildConfig.xml"); 74 89 if (-e $buildoutfile) { 75 90 print STDOUT "buildConfig file already exists! overwriting it!\n"; … … 92 107 my $collwriter = new XML::Writer(OUTPUT => $colloutput, NEWLINES => 1); 93 108 94 $collwriter->startTag('collectionConfig', 'xmlns:gsf'=>"http://www.greenstone.org/configformat" );109 $collwriter->startTag('collectionConfig', 'xmlns:gsf'=>"http://www.greenstone.org/configformat", 'xmlns:xsl'=>'http://www.w3.org/1999/XSL/Transform'); 95 110 96 111 #output the collection metadata to the collectionConfig file 112 $collwriter->startTag('metadataList'); 113 114 my $creator = $collectcfg->{'creator'}; 115 &output_metadata($collwriter, 'creator', $creator); 116 $collwriter->endTag('metadataList'); 117 118 #output the display collectionmeta to collectionConfig.xml 119 97 120 my $collectionmeta = $collectcfg->{'collectionmeta'}; 98 $collwriter->startTag('metadataList');99 100 %name_map = (101 'collectionname', 'colName',102 'collectionextra', 'colDescription',103 'iconcollection', 'colIcon',104 'iconcollectionsmall', 'colIconSmall');105 106 121 if (defined $collectionmeta) { 122 %name_map = ('collectionname', 'name', 123 'collectionextra', 'description', 124 'iconcollection', 'icon', 125 'iconcollectionsmall', 'smallicon'); 126 127 $collwriter->startTag('displayItemList'); 107 128 foreach $entry ( keys %$collectionmeta) { 108 129 if (defined $name_map{$entry}) { … … 113 134 $value = format_icon_value($value); 114 135 } 115 outputmetadata($collwriter, $name, $lang, $value); 116 } 117 } 118 } 136 &output_display($collwriter, $name, $lang, $value); 137 } 138 } 139 } 140 $collwriter->endTag('displayItemList'); 119 141 } 120 $collwriter->endTag('metadataList'); 121 122 # output building metadata to build config file 142 143 # output building metadata to build config file 123 144 my $numdocs = $buildcfg->{'numdocs'}; 124 145 $buildwriter->startTag('metadataList'); 125 $buildwriter->startTag('metadata', 'name'=>'numDocs'); 126 $buildwriter->characters($numdocs); 127 $buildwriter->endTag('metadata'); 146 &output_metadata($buildwriter, 'numDocs', $numdocs); 128 147 $buildwriter->endTag('metadataList'); 129 148 … … 167 186 168 187 #output the search stuff to coll cfg 169 $collwriter->startTag('search' , 'type'=>$buildtype);188 $collwriter->startTag('search'); 170 189 foreach $i (keys %$indexmap) { 171 190 $shortname = $indexmap->{$i}; 172 if ($buildtype eq 'mgpp') { 173 $collwriter->startTag('index', 'name'=>$shortname); 174 } elsif ($buildtype eq 'mg') { 175 $collwriter->startTag('index', 'name'=>$shortname); 176 } 191 $collwriter->startTag('index', 'name'=>$shortname); 177 192 #find the coll meta stuff 178 193 $indexdisplay = ".$i"; 179 194 foreach $lang (keys %{$collectionmeta->{$indexdisplay}}) { 180 195 $value = $collectionmeta->{$indexdisplay}->{$lang}; 181 output_display($collwriter, $lang, $value);196 output_display($collwriter, 'name', $lang, $value); 182 197 } 183 198 $collwriter->endTag('index'); … … 187 202 # add in the format stuff 188 203 if (defined $format->{'SearchVList'}) { 189 204 190 205 $collwriter->startTag('format'); 191 206 write_format($collwriter, $format->{'SearchVList'}); … … 199 214 my @levels = (); 200 215 my $defaultlevel; 201 216 202 217 #do the retrieve service 203 218 # assume mgpp or mg … … 207 222 push @levels, @{$buildcfg->{'indexlevels'}}; 208 223 209 $defaultlevel = $levels[0]; # the first one210 224 if (defined $buildcfg->{'textlevel'}) { 211 $ textlevel = $buildcfg->{'textlevel'};225 $defaultlevel = $buildcfg->{'textlevel'}; 212 226 } else { 213 $ textlevel = $defaultlevel;214 } 215 } else { 227 $defaultlevel = $levels[0]; 228 } 229 } else { #use levels from collet.cfg - must be an old collection 216 230 # should be there, but take a guess 217 @levels = ('Doc'); 218 $defaultlevel = 'Doc'; 219 $textlevel = 'Doc'; 231 @levels = ('Document'); 232 $defaultlevel = 'Document'; 233 if (defined $collectcfg->{'levels'}) { 234 foreach $l (@{$collectcfg->{'levels'}}) { 235 if ($l eq "Section") { 236 $defaultlevel = 'Section'; 237 } 238 push @levels, $l; 239 } 240 } 220 241 } 221 242 222 243 $buildwriter->startTag('serviceRack', 'name'=>'GS2MGPPRetrieve'); 223 $buildwriter->emptyTag('defaultLevel', 'name'=>$ textlevel);244 $buildwriter->emptyTag('defaultLevel', 'name'=>$defaultlevel); 224 245 225 246 … … 248 269 } 249 270 250 my $nodelinks = 0;251 271 my $horizontalAtTop = "false"; 252 272 if ($classname eq "AZList" || $classname eq "AZCompactList") { #there may be others 253 273 $horizontalAtTop = "true"; 254 $nodelinks = 1;255 274 } 256 275 if (not $started_classifiers) { … … 258 277 $started_classifiers = 1; 259 278 } 260 my $content = ''; #use buttonn mae first, then metadata279 my $content = ''; #use buttonname first, then metadata 261 280 if ($classname eq "DateList") { 262 281 $content = "Date"; … … 287 306 $dlist = "DateList"; 288 307 } 289 if ( $nodelinks ||defined $format->{$vlist} || defined $format->{$hlist} || defined $format->{$dlist}) {308 if (defined $format->{$vlist} || defined $format->{$hlist} || defined $format->{$dlist}) { 290 309 $collwriter->startTag('format'); 291 if ($nodelinks) {292 write_nodelinks_format($collwriter);293 }294 295 310 if (defined $format->{$vlist}) { 296 311 write_format($collwriter, $format->{$vlist}); … … 305 320 } 306 321 $collwriter->endTag('classifier'); 307 322 } #foreach classifier 308 323 if ($started_classifiers) { 309 324 # end the classifiers … … 326 341 327 342 $buildwriter->startTag('serviceRack', 'name'=>'GS2MGPPSearch'); 328 $buildwriter->emptyTag('defaultLevel', 'name'=>$ textlevel);343 $buildwriter->emptyTag('defaultLevel', 'name'=>$defaultlevel); 329 344 $buildwriter->startTag('levelList'); 330 345 foreach $level (@levels) { … … 370 385 371 386 $buildwriter->endTag('serviceRack'); 372 387 373 388 $buildwriter->endTag('serviceRackList'); 374 389 $buildwriter->endTag('buildConfig'); 375 390 $collwriter->endTag('collectionConfig'); 391 $collwriter->end(); 376 392 $buildwriter->end(); 377 393 $buildoutput->close(); … … 380 396 381 397 382 sub outputmetadata { 383 my ($writer, $metaname, $lang, $metavalue) = @_; 398 sub output_metadata { 399 my ($writer, $metaname, $metavalue) = @_; 400 $writer->startTag('metadata', 'name'=>$metaname); 401 $writer->characters($metavalue); 402 $writer->endTag('metadata'); 403 } 404 405 sub output_display { 406 my ($writer, $name, $lang, $value) = @_; 384 407 $lang = 'en' if $lang eq 'default'; 385 408 if ($lang =~ /^\[/) { 386 409 ($lang) = $lang =~ /\[l=(.*)\]/; 387 410 } 388 $writer->startTag('metadata', 'name'=>$metaname, 'lang'=>$lang); 389 $writer->characters($metavalue); 390 $writer->endTag('metadata'); 391 } 392 393 sub output_display { 394 my ($writer, $lang, $value) = @_; 395 $lang = 'en' if $lang eq 'default'; 396 if ($lang =~ /^\[/) { 397 ($lang) = $lang =~ /\[l=(.*)\]/; 398 } 399 $writer->startTag('displayName', 'lang'=>$lang); 411 $writer->startTag('displayItem', 'name'=>$name, 'lang'=>$lang); 400 412 $writer->characters($value); 401 $writer->endTag('display Name');413 $writer->endTag('displayItem'); 402 414 } 403 415 sub format_icon_value { … … 428 440 $old_format =~ s/\[srcicon\]/\<gsf:icon type=\'source\'\/\>/g; 429 441 430 #now do the rest of the {}which are assumed to be metadata442 #now do the rest of the [] which are assumed to be metadata 431 443 $old_format =~ s/\[([^\]]*\:)?([^\]\:]*)\]/\<gsf:metadata name=\'$2\' select=\'$1\'\/\>/g; 432 444 #do the parent stuff … … 452 464 } 453 465 454 455 sub write_nodelinks_format {456 457 my ($writer) = @_;458 459 $writer->startTag('gsf:template', 'match'=>'classifierNode');460 $writer->startTag('td');461 $writer->startTag('gsf:link', 'type'=>'classifier');462 $writer->emptyTag('gsf:metadata', 'name'=>'Title');463 $writer->endTag('gsf:link');464 $writer->endTag('td');465 $writer->endTag('gsf:template');466 467 }468 466 #$writer->startTag(''); 469 467 #$writer->endTag(''); -
trunk/gsdl3/bin/script/gs2_mkcol.pl
r4884 r4969 246 246 # get the strings to include. 247 247 $pluginstring = ""; 248 $xmlpluginstring = "";249 248 foreach $plugin (@plugin) { 250 249 if ($plugin eq RecPlug) { 251 250 $pluginstring .= "plugin $plugin -use_metadata_files\n"; 252 $xmlpluginstring .= "<plugin name='$plugin'><option name='use_metadata_files'/></plugin>\n";253 251 } else { 254 252 $pluginstring .= "plugin $plugin\n"; 255 $xmlpluginstring .= "<plugin name='$plugin'/>\n";256 253 } 257 254 } … … 284 281 $defaultindex = "defaultindex document:text"; 285 282 $indexmeta = "collectionmeta .document:text \"text\"\ncollectionmeta .document:Title \"titles\"\ncollectionmeta .document:Source \"filenames\"\n"; 286 287 $xmlindexes = "<index name='dtx'><displayName lang='en'>text</displayName></index>\n<index name='dtt'><displayName lang='en'>titles</displayName></index>\n<index name='dsr'><displayName lang='en'>filenames</displayName></index>";288 283 } elsif ($buildtype eq "mgpp") { 289 284 $indexes = "allfields text metadata"; 290 285 $defaultindex = ""; 291 286 $indexmeta = "collectionmeta .text \"text\"\ncollectionmeta .allfields \"entire documents\"\n"; 292 $xmlindexes = "<index name='idx'><displayName lang='en'>documents</displayName></index>";293 287 } else { 294 288 print STDOUT "Error: buildtype should be mg or mgpp, but its $buildtype\n";
Note:
See TracChangeset
for help on using the changeset viewer.