Changeset 21661 for main/trunk
- Timestamp:
- 2010-01-27T14:15:47+13:00 (14 years ago)
- Location:
- main/trunk/greenstone2/perllib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/ClassifyTreeModel.pm
r21646 r21661 104 104 } 105 105 # /** getCollection() **/ 106 107 sub getInfoDBType() 108 { 109 my $self = shift(@_); 110 return $self->{'infodbtype'}; 111 } 106 112 107 113 # /** Retrieve a node from this tree based upon its CLID (OID). -
main/trunk/greenstone2/perllib/ClassifyTreeNode.pm
r21563 r21661 28 28 29 29 my $collection = $model->getCollection(); 30 $self->{'infodbtype'} = $model->getInfoDBType(); 30 31 31 32 my $index_text_directory_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "index", "text"); 32 $self->{'infodb_file_path'} = &dbutil::get_infodb_file_path( "gdbm", $collection, $index_text_directory_path);33 $self->{'infodb_file_path'} = &dbutil::get_infodb_file_path($self->{'infodbtype'}, $collection, $index_text_directory_path); 33 34 34 35 # Check if this node already exists in the database, and if not insert it 35 36 # now 36 my $text = &dbutil::read_infodb_entry( "gdbm", $self->{'infodb_file_path'}, $clid);37 my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 37 38 if($text !~ /\w+/ && $force_new) 38 39 { 39 my $infodb_file_handle = &dbutil::open_infodb_write_handle( "gdbm", $self->{'infodb_file_path'}, "append");40 &dbutil::write_infodb_entry( "gdbm", $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash("<doctype>classify\n<hastxt>0\n<childtype>VList\n<Title>\n<numleafdocs>0\n<contains>\n"));41 &dbutil::close_infodb_write_handle( "gdbm", $infodb_file_handle);40 my $infodb_file_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $self->{'infodb_file_path'}, "append"); 41 &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash("<doctype>classify\n<hastxt>0\n<childtype>VList\n<Title>\n<numleafdocs>0\n<contains>\n")); 42 &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $infodb_file_handle); 42 43 } 43 44 # Bless me father for I have sinned … … 122 123 123 124 # Create a new document with the correct CLID 124 my $infodb_file_handle = &dbutil::open_infodb_write_handle( "gdbm", $self->{'infodb_file_path'}, "append");125 &dbutil::write_infodb_entry( "gdbm", $infodb_file_handle, $new_clid, &dbutil::convert_infodb_string_to_hash($text));125 my $infodb_file_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $self->{'infodb_file_path'}, "append"); 126 &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_file_handle, $new_clid, &dbutil::convert_infodb_string_to_hash($text)); 126 127 # Remove the old document 127 &dbutil::delete_infodb_entry( "gdbm", $infodb_file_handle, $self->{'clid'});128 &dbutil::close_infodb_write_handle( "gdbm", $infodb_file_handle);128 &dbutil::delete_infodb_entry($self->{'infodbtype'}, $infodb_file_handle, $self->{'clid'}); 129 &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $infodb_file_handle); 129 130 130 131 # Finally, change the clid stored in this document … … 240 241 241 242 # Now determine if this node exists. 242 if (&dbutil::read_infodb_entry( "gdbm", $self->{'infodb_file_path'}, $next_clid) =~ /\w+/)243 if (&dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $next_clid) =~ /\w+/) 243 244 { 244 245 # And if so, create it. … … 491 492 } 492 493 # Now remove the node from the database 493 my $infodb_file_handle = &dbutil::open_infodb_write_handle( "gdbm", $self->{'infodb_file_path'}, "append");494 &dbutil::delete_infodb_entry( "gdbm", $infodb_file_handle, $self->{'clid'});495 &dbutil::close_infodb_write_handle( "gdbm", $infodb_file_handle);494 my $infodb_file_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $self->{'infodb_file_path'}, "append"); 495 &dbutil::delete_infodb_entry($self->{'infodbtype'}, $infodb_file_handle, $self->{'clid'}); 496 &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $infodb_file_handle); 496 497 497 498 # Return the leaf count (so we can adjust the numleafdocs at the root node … … 630 631 631 632 # Load the text of this node 632 my $text = &dbutil::read_infodb_entry( "gdbm", $self->{'infodb_file_path'}, $clid);633 my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 633 634 634 635 # Replace the contains … … 637 638 #rint STDERR "After: $text\n"; 638 639 # Store the changed text 639 my $infodb_file_handle = &dbutil::open_infodb_write_handle( "gdbm", $self->{'infodb_file_path'}, "append");640 &dbutil::write_infodb_entry( "gdbm", $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash($text));641 &dbutil::close_infodb_write_handle( "gdbm", $infodb_file_handle);640 my $infodb_file_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $self->{'infodb_file_path'}, "append"); 641 &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash($text)); 642 &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $infodb_file_handle); 642 643 } 643 644 # /** setContains() **/ … … 658 659 659 660 # Load the text of this node 660 my $text = &dbutil::read_infodb_entry( "gdbm", $self->{'infodb_file_path'}, $clid);661 my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 661 662 # Replace the numleafdocs 662 663 $text =~ s/<numleafdocs>\d*?\n+/<numleafdocs>$numleafdocs\n/; 663 664 # Store the changed text 664 my $infodb_file_handle = &dbutil::open_infodb_write_handle( "gdbm", $self->{'infodb_file_path'}, "append");665 &dbutil::write_infodb_entry( "gdbm", $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash($text));666 &dbutil::close_infodb_write_handle( "gdbm", $infodb_file_handle);665 my $infodb_file_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $self->{'infodb_file_path'}, "append"); 666 &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash($text)); 667 &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $infodb_file_handle); 667 668 } 668 669 # /** setNumLeafDocs() **/ … … 685 686 686 687 # Load the text of this node 687 my $text = &dbutil::read_infodb_entry( "gdbm", $self->{'infodb_file_path'}, $clid);688 my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 688 689 # Replace the title 689 690 $text =~ s/<Title>.*?\n+/<Title>$title\n/; 690 691 # Store the changed text 691 my $infodb_file_handle = &dbutil::open_infodb_write_handle( "gdbm", $self->{'infodb_file_path'}, "append");692 &dbutil::write_infodb_entry( "gdbm", $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash($text));693 &dbutil::close_infodb_write_handle( "gdbm", $infodb_file_handle);692 my $infodb_file_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $self->{'infodb_file_path'}, "append"); 693 &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_file_handle, $clid, &dbutil::convert_infodb_string_to_hash($text)); 694 &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $infodb_file_handle); 694 695 } 695 696 # /** setValue() **/ … … 708 709 my $clid = $self->{'clid'}; 709 710 710 my $text = &dbutil::read_infodb_entry( "gdbm", $self->{'infodb_file_path'}, $clid);711 my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $self->{'infodb_file_path'}, $clid); 711 712 return $text; 712 713 }
Note:
See TracChangeset
for help on using the changeset viewer.