Changeset 3639
- Timestamp:
- 2003-01-03T10:03:31+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/Hierarchy.pm
r3540 r3639 93 93 94 94 -metadata X Metadata field used for classification, 95 list will be sorted by this element. 95 list will be sorted by this element, 96 unless -sort is used. 96 97 97 98 -hfile X The classification structure file 98 99 99 -sort X Metadata field to sort by (defaults to none) 100 -sort X Metadata field to sort by (defaults to -metadata) 101 use '-sort nosort' for no sorting. 100 102 101 103 -hlist_at_top Display the first level of the classification … … 109 111 my $self = new BasClas($class, @_); 110 112 111 112 113 113 # 14-05-02 To allow for proper inheritance of arguments - John Thompson 114 my $option_list = $self->{'option_list'}; 115 push( @{$option_list}, $options ); 114 116 115 my $sortname = "Title"; 116 my ($hfile, $metadata, $title, $hlist_at_top); 117 117 my ($hfile, $metadata, $sortname, $title, $hlist_at_top); 118 118 119 if (!parsargv::parse(\@_, 119 120 q^buttonname/.*/^, \$title, 120 q^sort/.*/ nosort^, \$sortname,121 q^sort/.*/^, \$sortname, 121 122 q^hfile/.*/^, \$hfile, 122 123 q^metadata/.*/^, \$metadata, … … 124 125 "allow_extra_options")) { 125 126 126 127 $self->{'construction_error'} = "Incorrect options passed to $class, check your collect.cfg file."; 127 128 } 128 129 129 130 if (!$metadata) { 130 131 } 132 131 $self->{'construction_error'} = "Hierarchy error: no metadata supplied."; 132 } 133 133 134 $title = $metadata unless ($title); 134 135 # if no sortname specified, it defaults to metadata 136 $sortname = $metadata unless ($sortname); 135 137 $sortname = undef if $sortname =~ /^nosort$/; 136 137 my $subjectfile; 138 my $subjectfile; 138 139 139 140 if (!$hfile) { 140 141 $self->{'construction_error'} = "Hierarchy error: No -hfile supplied."; 141 142 } 142 143 else 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 144 { 145 $subjectfile = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"etc", $hfile); 146 if (!-e $subjectfile) { 147 my $collfile = $subjectfile; 148 $subjectfile = &util::filename_cat($ENV{'GSDLHOME'},"etc", $hfile); 149 if (!-e $subjectfile) { 150 my $outhandle = $self->{'outhandle'}; 151 &print_usage; 152 print STDERR "\nHierarchy Error: Can't locate subject file $hfile\n"; 153 print STDERR "This file should be in $collfile or $subjectfile\n"; 154 die "\n"; 155 } 156 } 157 } 158 158 159 $self->{'descriptorlist'} = {}; # first field in subject file 159 160 $self->{'locatorlist'} = {}; # second field in subject file … … 169 170 sub init { 170 171 my $self = shift (@_); 171 172 173 174 175 176 177 172 173 if(defined $self->{'construction_error'} || !defined $self->{'metaname'} || !defined $self->{'subjectfile'}) { 174 print STDERR "Error: " , $self->{'construction_error'} , "\n"; 175 &print_usage; 176 die "\n"; 177 } 178 178 179 # read in the subject file 179 180 my $list = &cfgread::read_cfg_file ($self->{'subjectfile'}, undef, '^[^#]?\w'); … … 194 195 my $self = shift (@_); 195 196 my ($doc_obj) = @_; 196 197 197 198 my $doc_OID = $doc_obj->get_OID(); 198 199 199 200 my $metadata = $doc_obj->get_metadata ($doc_obj->get_top_section(), 200 201 $self->{'metaname'}); 201 202 202 203 my $sortmeta = ""; 203 204 if (defined $self->{'sortname'}) { … … 217 218 $sortmeta = "" unless defined $sortmeta; 218 219 } 219 220 220 221 foreach $metaelement (@$metadata) { 221 222 if ((defined $self->{'descriptorlist'}->{$metaelement}) && … … 231 232 232 233 my $list = $self->{'locatorlist'}; 233 234 234 235 my ($classifyinfo); 235 236 if ($self->{'hlist_at_top'}) { … … 238 239 $classifyinfo = $self->get_entry ($self->{'title'}, "VList", "Invisible"); 239 240 } 240 241 foreach $OID (keys (%$list)) { 242 241 # sorted the keys - otherwise funny things happen - kjdon 03/01/03 242 foreach $OID (sort keys (%$list)) { 243 243 my $tempinfo = $self->get_OID_entry ($OID, $classifyinfo, $list->{$OID}->{'title'}, "VList"); 244 244 245 245 if (defined $self->{'sortname'}) { 246 246 foreach $subOID (sort {$a->[1] cmp $b->[1];} @{$list->{$OID}->{'contents'}}) {
Note:
See TracChangeset
for help on using the changeset viewer.