Changeset 7588


Ignore:
Timestamp:
2004-06-11T11:41:29+12:00 (20 years ago)
Author:
kjdon
Message:

made a lot of changes to this but apparently it still doesn't work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/unbuildv2.pl

    r3324 r7588  
    33###########################################################################
    44#
    5 # unindex.pl --
     5# unbuildv2.pl --
    66# A component of the Greenstone digital library software
    77# from the New Zealand Digital Library Project at the
     
    3333# updated. It probably needs some work done before using.
    3434
     35# Katherine updated this but apparently it still doesn't work.
     36
    3537BEGIN {
    3638    die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
     
    4042}
    4143
     44use unbuildutil;
    4245use doc;
    4346use docsave;
     
    127130    &get_toplevel_OID ($gdbmfile); # puts a list of the top level document OIDs into $toplevelinfo
    128131
    129     tie (%infodb, "GDBM_File", $gdbmfile, 1, 0);
     132    #tie (%infodb, "GDBM_File", $gdbmfile, 1, 0);
     133   
     134    #read ldb file into %infodb
     135    &unbuildutil::read_gdbm($gdbmfile, \%infodb);
    130136
    131137    #this makes the files specifying the hierarchy of subjects, titles etc
    132138    foreach $classify (@$classifyinfo) {
    133139   
    134         &make_info_file($classify);
    135 
    136     }
    137 
    138    
     140    &make_info_file($classify);
     141
     142    }
     143
    139144   
    140145    #write out the collect.cfg
     
    237242    next if ($key =~ /^CL/); #ignore classification entries
    238243    next if ($value =~ /<section>/); #ignore docnum->OID entries
     244    next if ($value =~ /<docoid>/); #ignore strange s133->OID entries
    239245    next if ($key !~ /\d/); #ignore collection, browse entries
    240246
     
    245251    $/ = "\n";
    246252    #print STDERR "toplevel sections are: ", join ("\n", @$toplevelinfo);
     253    #print STDERR "\n";
    247254}
    248255   
     
    251258   
    252259    my ($gdb_str_ref, $hashref) = @_;
    253    
    254260    my @entries = split(/\n/, $gdb_str_ref);
    255261    foreach $entry (@entries) {
     
    257263    $$hashref{$key} .= '@' if defined $$hashref{$key};
    258264    $$hashref{$key} .= $value;
    259     #print STDERR "key: $key, value: $value\n";
     265   
    260266    }
    261267   
     
    295301    if (defined ($childs)) {
    296302    $childs =~ s/\@$//;  #remove trailing @
    297     if ($childs =~ s/^\"//) { #remove initial " if there
    298         @items = split /\;\"/, $childs; #split into .1 .2 .3 etc
    299         foreach $item (@items) {
    300         push (@$children, "$parentoid$item");
    301         }
    302     }
    303     else { # whole id is already present. split on ; and dont put parentoid in front
    304         @items = split /\;/, $childs;
    305         foreach $item (@items) {
    306         push (@$children, "$item");
    307         }
    308     }
    309     #print STDERR "children are: ", join ("\n", @$children);
    310 
     303    @items = split /\;/, $childs; #split on ;
     304    foreach $item (@items) {
     305        $item =~ s/^\"/$parentoid/; # replace " with parentoid
     306        push (@$children, "$item");
     307    }
    311308    }
    312309    else {
    313310      $children = [];
    314311      }
    315 
    316 
    317 }   
     312}
     313
     314   
    318315sub recurse_sections {
    319316    my ($doc_obj, $children, $parentoid, $parentsection, $olddir) = @_;
     
    482479    &mgcommand('.set query docnums');
    483480    &mgcommand('.set term_freq off');
     481    &mgcommand('.set briefstats off');
     482    &mgcommand('.set memstats off');
     483    &mgcommand('.set sizestats off');
     484    &mgcommand('.set timestats off');
    484485}
    485486
     
    567568
    568569    $/ = "\n";
    569     print STDERR "classifications are: ", join(", ", @$classifyinfo);
     570    #print STDERR "classifications are: ", join(", ", @$classifyinfo);
     571    #print STDERR "\n";
     572   
    570573}
    571574
     
    577580    my ($classifier) = @_;
    578581    my $info_file = "";
    579 
    580582    my $entry = $infodb{$classifier};
    581     #print STDERR "entry = $entry\n";
     583
    582584    my $hashref = {};
    583585    &get_metadata($entry, $hashref);
     
    586588    $classifier_name =~ s/\@$//; #remove trailing @
    587589   
    588     # check children - if all are documents at this level, dont need a
    589     # hierarchy so just put a AZList into config file
     590    # check children - if there is a classifier node at this level,
     591    # use a hierarchy, otherwise use an AZList.
    590592   
    591593    my $children=[];
    592     &get_whole_children($classifier, $hashref, $children);
    593     if (&is_document($$children[0])) {
     594    my $hierarchy = 0;
     595    &get_whole_children($classifier, $hashref, $children); #returns a list of the child ids
     596    foreach $child(@$children) {
     597    if(not &is_document($child)) {
     598        $hierarchy = 1;
     599        last;
     600    }
     601    }
     602
     603    if (!$hierarchy) {
    594604    &add_classify_cfg_list($classifier_name);
    595    
    596605    }else { #there is a hierarchy so create a file
    597 
    598606    $info_file = "./etc/$classifier_name.txt";
    599607
     
    615623sub process_entry {
    616624    my ($handle, $classifier_name, $classify_id) = @_;
    617 
    618625    my $value = $infodb{$classify_id};
    619626   
    620627    my $hashref={};
    621    
    622628    &get_metadata($value, $hashref);
    623629    my $title = $hashref->{'Title'};
     
    631637        &add_doc_metadata($child, $classifier_name, $title);
    632638    }else {
    633         process_entry($handle, $classifier_name, $child);
     639        &process_entry($handle, $classifier_name, $child);
    634640    }
    635641    }
     
    660666    my ($handle, $classify_id, $title) = @_;
    661667    #print STDERR "classify id= $classify_id, title= $title\n";
    662     $title = &unicode::ascii2utf8($title);
    663 
     668    $title = &unicode::ascii2utf8(\$title);
    664669    my ($num) = $classify_id =~ /^CL\d\.(.*)$/; #remove the CL1. from the front
    665670   
     
    687692    $collect_cfg->{'creator'}="$username\@cs.waikato.ac.nz";
    688693    $collect_cfg->{'maintainer'}="$username\@cs.waikato.ac.nz";
    689     $collect_cfg->{'public'}="false";
     694    $collect_cfg->{'public'}="true";
    690695    $collect_cfg->{'beta'}="true";
    691696   
    692697    $collect_cfg->{'plugin'}=[];
    693     push (@{$collect_cfg->{'plugin'}}, ["GMLPlug"]);
     698    push (@{$collect_cfg->{'plugin'}}, ["GAPlug"]);
    694699    push (@{$collect_cfg->{'plugin'}}, ["ArcPlug"]);
    695700    push (@{$collect_cfg->{'plugin'}}, ["RecPlug"]);
     
    704709    $collect_cfg->{'collectionmeta'}={};
    705710    $collect_cfg->{'collectionmeta'}->{'collectionname'}="\"$collection\"";
    706     $collect_cfg->{'collectionmeta'}->{'iconcollection'}="\"http://www.nzdl.org/gsdl/collect/$collection/images/$collection.gif\"";
    707     $collect_cfg->{'collectionmeta'}->{'iconcollectionsmall'}="\"http://www.nzdl.org/gsdl/collect/$collection/images/${collection}sm.gif\"";
     711    $collect_cfg->{'collectionmeta'}->{'iconcollection'}="\"_httpprefix_/collect/$collection/images/$collection.gif\"";
     712    $collect_cfg->{'collectionmeta'}->{'iconcollectionsmall'}="\"_httpprefix_/collect/$collection/images/${collection}sm.gif\"";
    708713    $collect_cfg->{'collectionmeta'}->{'collectionextra'} = "\"This is a collection rebuilt from CDROM.\"";
    709 
    710      
    711 
    712714
    713715}
     
    751753    my ($title) = $classifier_name =~ /^CL(.*)$/;
    752754    my ($filename) = $file =~ /\/([^\/]*)$/;
    753     my $entry = "Hierarchy hfile=$filename metadata=$classifier_name title=$title sort=Title";
     755    my $entry = "Hierarchy -hfile $filename -metadata $classifier_name -buttonname $title -sort Title";
    754756    push (@{$collect_cfg->{'classify'}},[$entry]);
    755757   
     
    762764    $collect_cfg->{'classify'} = [] unless defined $collect_cfg->{'classify'};
    763765    my ($title) = $classifier =~ /^CL(.*)$/;
    764     my $entry = "AZList metadata=$classifier title=$title";
     766    my $entry = "AZList -metadata $classifier -buttonname $title";
    765767    push (@{$collect_cfg->{'classify'}},[$entry]);
    766768}   
Note: See TracChangeset for help on using the changeset viewer.