Changeset 15702 for gsdl/trunk/perllib/classify.pm
- Timestamp:
- 2008-05-26T16:28:00+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/classify.pm
r14239 r15702 42 42 43 43 44 $next_classify_num = 1;45 44 $oid_to_clids = {}; 46 45 … … 295 294 } 296 295 296 297 297 # output_classify_info outputs all the info needed for the classification 298 # to the gdbm299 sub output_classify_info {300 my ($classifiers, $handle, $remove_empty_classifications, $gli) = @_; 301 # $handle = "main::STDOUT";298 # to the database 299 sub output_classify_info 300 { 301 my ($classifiers, $infodb_handle, $remove_empty_classifications, $gli) = @_; 302 302 303 303 $gli = 0 unless defined $gli; 304 304 305 305 # create a classification containing all the info 306 my $classifyinfo = { 'classifyOID'=>'browse',307 'contains'=>[]};306 my $classifyinfo = { 'classifyOID'=> 'browse', 307 'contains' => [] }; 308 308 309 309 # get each of the classifications 310 foreach $classobj (@$classifiers) { 311 my $tempinfo = $classobj->get_classify_info($gli); 312 my $classID = $tempinfo->{'classifyOID'}; 313 314 $tempinfo->{'classifyOID'} = "CL$next_classify_num" unless defined($tempinfo->{'classifyOID'}); 310 my $next_classify_num = 1; 311 foreach $classifier (@$classifiers) 312 { 313 my $classifier_info = $classifier->get_classify_info($gli); 314 $classifier_info->{'classifyOID'} = "CL$next_classify_num" unless defined($classifier_info->{'classifyOID'}); 315 print STDERR "*** outputting information for classifier: $classifier_info->{'classifyOID'}\n"; 316 317 push(@{$classifyinfo->{'contains'}}, $classifier_info); 315 318 $next_classify_num++; 316 317 print STDERR "*** outputting information for classifier: $tempinfo->{'classifyOID'}\n"; 318 319 push (@{$classifyinfo->{'contains'}}, $tempinfo); 320 } 321 322 &print_classify_info ($handle, $classifyinfo, "", $remove_empty_classifications); 323 } 324 325 sub print_classify_info { 326 my ($handle, $classifyinfo, $OID, $remove_empty_classifications) = @_; 319 } 320 321 &print_classify_info ($infodb_handle, $classifyinfo, "", $remove_empty_classifications); 322 } 323 324 325 sub print_classify_info 326 { 327 my ($infodb_handle, $classifyinfo, $OID, $remove_empty_classifications) = @_; 327 328 328 329 $OID =~ s/^\.+//; # just for good luck … … 335 336 336 337 $OID = $classifyinfo->{'classifyOID'} if defined ($classifyinfo->{'classifyOID'}); 337 338 my $outputtext = "[$OID]\n";339 $ outputtext .= "<doctype>classify\n";340 $ outputtext .= "<hastxt>0\n";341 $ outputtext .= "<childtype>$classifyinfo->{'childtype'}\n"338 339 my %classify_infodb = (); 340 $classify_infodb{"doctype"} = [ "classify" ]; 341 $classify_infodb{"hastxt"} = [ "0" ]; 342 $classify_infodb{"childtype"} = [ $classifyinfo->{'childtype'} ] 342 343 if defined $classifyinfo->{'childtype'}; 343 $ outputtext .= "<Title>$classifyinfo->{'Title'}\n"344 $classify_infodb{"Title"} = [ $classifyinfo->{'Title'} ] 344 345 if defined $classifyinfo->{'Title'}; 345 $ outputtext .= "<numleafdocs>$classifyinfo->{'numleafdocs'}\n"346 $classify_infodb{"numleafdocs"} = [ $classifyinfo->{'numleafdocs'} ] 346 347 if defined $classifyinfo->{'numleafdocs'}; 347 $ outputtext .= "<thistype>$classifyinfo->{'thistype'}\n"348 $classify_infodb{"thistype"} = [ $classifyinfo->{'thistype'} ] 348 349 if defined $classifyinfo->{'thistype'}; 349 $ outputtext .= "<parameters>$classifyinfo->{'parameters'}\n"350 $classify_infodb{"parameters"} = [ $classifyinfo->{'parameters'} ] 350 351 if defined $classifyinfo->{'parameters'}; 351 $ outputtext .= "<supportsmemberof>$classifyinfo->{'supportsmemberof'}\n"352 $classify_infodb{"supportsmemberof"} = [ $classifyinfo->{'supportsmemberof'} ] 352 353 if defined $classifyinfo->{'supportsmemberof'}; 353 354 354 my $contains_text = " <contains>";355 my $mdoffset_text = " <mdoffset>";355 my $contains_text = ""; 356 my $mdoffset_text = ""; 356 357 357 358 my $next_subOID = 1; 358 359 my $first = 1; 359 foreach $tempinfo (@{$classifyinfo->{'contains'}}) {360 foreach my $tempinfo (@{$classifyinfo->{'contains'}}) { 360 361 # empty contents were made undefined by clean_contents() 361 362 next unless defined $tempinfo; … … 386 387 #rint STDERR "Result: \"" . join(";", @{$clids}) . "\"\n"; 387 388 388 &print_classify_info ($ handle, $tempinfo, $tempinfo->{'classifyOID'},389 &print_classify_info ($infodb_handle, $tempinfo, $tempinfo->{'classifyOID'}, 389 390 $remove_empty_classifications); 390 391 } elsif (defined ($tempinfo->{'OID'})) { … … 431 432 #rint STDERR "Result: \"" . join(";", @{$clids}) . "\"\n"; 432 433 433 &print_classify_info ($ handle, $tempinfo, "$OID.$next_subOID",434 &print_classify_info ($infodb_handle, $tempinfo, "$OID.$next_subOID", 434 435 $remove_empty_classifications); 435 436 $next_subOID++; … … 437 438 } 438 439 439 $ outputtext .= "$contains_text\n";440 $ outputtext .= "<mdtype>$classifyinfo->{'mdtype'}\n"440 $classify_infodb{"contains"} = [ $contains_text ]; 441 $classify_infodb{"mdtype"} = [ $classifyinfo->{'mdtype'} ] 441 442 if defined $classifyinfo->{'mdtype'}; 442 $outputtext .= "$mdoffset_text\n" 443 if ($mdoffset_text !~ m/^<mdoffset>;+$/); 444 445 $outputtext .= '-' x 70 . "\n"; 446 447 print $handle $outputtext; 448 449 } 443 $classify_infodb{"mdoffset"} = [ $mdoffset_text ] 444 if ($mdoffset_text !~ m/^;+$/); 445 446 &dbutil::write_infodb_entry($infodb_handle, $OID, \%classify_infodb); 447 } 448 450 449 451 450 sub check_contents {
Note:
See TracChangeset
for help on using the changeset viewer.