Changeset 9899


Ignore:
Timestamp:
2005-05-17T13:26:57+12:00 (19 years ago)
Author:
kjdon
Message:

modified the classifier output - now checks the database to see if a classifier is horizontalAtTop or not

File:
1 edited

Legend:

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

    r9874 r9899  
    1414use FileHandle;
    1515use XML::Writer;
     16use GDBM_File;
    1617
    1718&main();
     
    9394    }
    9495
     96    my $db_file = &util::filename_cat ($collectdir, "index", "text", "$collection.ldb");
     97    my $database;
     98    if (-e $db_file) {
     99    $database = &open_database($db_file);
     100    } else {
     101    print STDERR "gdbm database file $db_file not found!!";
     102    die "\n";
     103    }
     104   
    95105    my $buildtype;
    96106    if (defined $buildcfg->{'buildtype'}) {
     
    264274        }
    265275       
    266         my $horizontalAtTop = "false";
    267         if ($classname eq "AZList" || $classname eq "AZCompactList") { #there may be others
    268         $horizontalAtTop = "true";
    269         }
     276        my $horizontalAtTop = &isHorizontalClassifier($database, $name);
    270277        if (not $started_classifiers) {
    271278        $buildwriter->startTag('serviceRack', 'name'=>'GS2Browse');
     
    288295        }
    289296        }
    290         if ($horizontalAtTop eq "false") {
     297        if ($horizontalAtTop) {
     298        $buildwriter->emptyTag('classifier', 'name'=>$name, 'content'=>$content, 'horizontalAtTop'=>'true');
     299        } else {
    291300        $buildwriter->emptyTag('classifier', 'name'=>$name, 'content'=>$content);
    292         } else {
    293         $buildwriter->emptyTag('classifier', 'name'=>$name, 'content'=>$content, 'horizontalAtTop'=>'true');
    294         }
     301        }
    295302       
    296303       
     
    404411    $buildoutput->close();
    405412    $colloutput->close();
     413    &close_database($database);
    406414}
    407415
     
    480488}
    481489
     490sub open_database {
     491    my ($db_file) = @_;
     492   
     493    my $database = ();
     494    tie (%database, GDBM_File, $db_file, &GDBM_READER, 0400) ||
     495    die "Couldn't open database $db_file\n";
     496
     497    return $database;
     498}
     499
     500sub close_database {
     501    my ($database) = @_;
     502    untie %database;
     503}
     504sub isHorizontalClassifier {
     505    my ($database, $name) = @_;
     506
     507    my $record = $database{$name};
     508    my ($childtype) = $record =~ /<childtype>(\w*)/;
     509    if ($childtype eq "HList") {
     510    return 1;
     511    }
     512    return 0;
     513}
    482514#$writer->startTag('');
    483515#$writer->endTag('');
Note: See TracChangeset for help on using the changeset viewer.