Changeset 17087 for gsdl/trunk/perllib/ClassifyTreeNode.pm
- Timestamp:
- 2008-08-29T13:10:39+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/ClassifyTreeNode.pm
r15890 r17087 26 26 $self->{'model'} = $model; 27 27 $self->{'clid'} = $clid; 28 29 my $collection = $model->getCollection(); 30 28 31 # Check if this node already exists in the database, and if not insert it 29 32 # now 30 my $text = &GDBMUtils::gdbm Get($model->getCollection(), $clid);33 my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid); 31 34 if($text !~ /\w+/ && $force_new) 32 35 { 33 &GDBMUtils::gdbm Set($model->getCollection(), $clid,36 &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, 34 37 "<doctype>classify\n<hastxt>0\n<childtype>VList\n<Title>\n<numleafdocs>0\n<contains>\n"); 35 38 } … … 108 111 # CLID 109 112 my @child_nodes = $self->getChildren(); 113 110 114 # Retrieve the current document 111 115 my $text = $self->toString(); 116 117 my $collection = $self->{'model'}->getCollection(); 118 112 119 # Create a new document with the correct CLID 113 &GDBMUtils::gdbmSet($self->{'model'}->getCollection(), $new_clid, $text); 120 &GDBMUtils::gdbmCachedCollectionSet($collection, $new_clid, $text); 121 114 122 # Remove the old document 115 &GDBMUtils::gdbmSet($self->{'model'}->getCollection(), $self->{'clid'}); 123 &GDBMUtils::gdbmCachedCollectionSet($collection, $self->{'clid'}); 124 116 125 # Finally, change the clid stored in this document 117 126 $self->{'clid'} = $new_clid; 127 118 128 # Now go through this nodes children, and shift them too 119 129 foreach my $child_node (@child_nodes) … … 221 231 push(@clid_parts, $suffix); 222 232 my $next_clid = join(".", @clid_parts); 233 234 my $collection = $self->{'model'}->getCollection(); 235 223 236 # Now determine if this node exists. 224 if(&GDBMUtils::gdbm Get($self->{'model'}->getCollection(), $next_clid) =~ /\w+/)237 if(&GDBMUtils::gdbmCachedCollectionGet($collection, $next_clid) =~ /\w+/) 225 238 { 226 239 # And if so, create it. … … 474 487 # Now remove the node from the database. We do this calling set gdbm with 475 488 # no value argument. 476 &GDBMUtils::gdbmSet($self->{'model'}->getCollection(), $self->{'clid'}); 489 my $collection = $self->{'model'}->getCollection(); 490 &GDBMUtils::gdbmCachedCollectionSet($collection, $self->{'clid'}); 491 477 492 # Return the leaf count (so we can adjust the numleafdocs at the root node 478 493 # of this deletion. … … 605 620 # Replace any occurance of this nodes CLID with " 606 621 $contains =~ s/$self->{'clid'}/\"/g; 622 623 my $collection = $self->{'model'}->getCollection(); 624 my $clid = $self->{'clid'}; 625 607 626 # Load the text of this node 608 my $text = &GDBMUtils::gdbmGet($self->{'model'}->getCollection(), $self->{'clid'}); 627 my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid); 628 609 629 # Replace the contains 610 630 #rint STDERR "Before: $text\n"; … … 612 632 #rint STDERR "After: $text\n"; 613 633 # Store the changed text 614 &GDBMUtils::gdbm Set($self->{'model'}->getCollection(), $self->{'clid'}, $text);634 &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, $text); 615 635 } 616 636 # /** setContains() **/ … … 626 646 my ($self, $numleafdocs) = @_; 627 647 print STDERR "ClassifyTreeNode::setNumLeafDocs(numleafdocs)\n" unless !$self->{'debug'}; 648 649 my $collection = $self->{'model'}->getCollection(); 650 my $clid = $self->{'clid'}; 651 628 652 # Load the text of this node 629 my $text = &GDBMUtils::gdbm Get($self->{'model'}->getCollection(), $self->{'clid'});653 my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid); 630 654 # Replace the numleafdocs 631 655 $text =~ s/<numleafdocs>\d*?\n+/<numleafdocs>$numleafdocs\n/; 632 656 # Store the changed text 633 &GDBMUtils::gdbm Set($self->{'model'}->getCollection(), $self->{'clid'}, $text);657 &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, $text); 634 658 } 635 659 # /** setNumLeafDocs() **/ … … 647 671 my ($self, $title) = @_; 648 672 print STDERR "ClassifyTreeNode::setTitle(\"$title\")\n" unless !$self->{'debug'}; 673 674 my $collection = $self->{'model'}->getCollection(); 675 my $clid = $self->{'clid'}; 676 649 677 # Load the text of this node 650 my $text = &GDBMUtils::gdbm Get($self->{'model'}->getCollection(), $self->{'clid'});678 my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid); 651 679 # Replace the title 652 680 $text =~ s/<Title>.*?\n+/<Title>$title\n/; 653 681 # Store the changed text 654 &GDBMUtils::gdbm Set($self->{'model'}->getCollection(), $self->{'clid'}, $text);682 &GDBMUtils::gdbmCachedCollectionSet($collection, $clid, $text); 655 683 } 656 684 # /** setValue() **/ … … 666 694 my ($self) = @_; 667 695 print STDERR "ClassifyTreeNode::toString()\n" unless !$self->{'debug'}; 668 my $text = &GDBMUtils::gdbmGet($self->{'model'}->getCollection(), $self->{'clid'}); 696 my $collection = $self->{'model'}->getCollection(); 697 my $clid = $self->{'clid'}; 698 699 my $text = &GDBMUtils::gdbmCachedCollectionGet($collection, $clid); 669 700 return $text; 670 701 }
Note:
See TracChangeset
for help on using the changeset viewer.