com.sri.emo.dbobj.selectiontree
Class TreeDeletionSelector

java.lang.Object
  extended by com.sri.emo.dbobj.selectiontree.TreeDeletionSelector

public class TreeDeletionSelector
extends Object

Helps with the the selection of nodes in an association tree. Depends on all nodes having attributes set that indicate their immediate chilren, from TreeSlectionFactory. The general algorithm for selecting necessary nodes is this:

Step 1: Build Tree

Get a list of all nodes that belong in the tree via strong relations

Step 2: Trim Nodes with External Links

Trim the bulk of the tree by finding any nodes that are the destinations via any strong relations of nodes outside the tree.

The algorithm for this step is:

 for each node N in allNodesInTree
          if N is destination of strong relation not in allNodesTree
              save N (Mark as do not delete)
          end if
 end for
 

Step 3: save children of any parent that is saved.

The situation here arises when External Link -> Node B -> Node A Node A won't register any external links, and will be marked for deletion when it shouldn't be. We use the following algorithm to trim transitive associations, where "ROOT DOWN ORDER" means from the root of the tree to the leaves:

 for each node N IN ROOT DOWN ORDER
     if N is saved, and is parent of node to be deleted
         move child nodes from "To Delete" collection to "Save" collection
         recurse down from each child
     end if
 end for.
 

Author:
Michael Rimov, Larry Hamel

Constructor Summary
TreeDeletionSelector(Map allNodes)
          Build the selector with all nodes in the tree to delete.
 
Method Summary
 void determineDeletionTree(Node rootToDelete, Collection toSave, Collection toDelete)
          After step 1 is completed (see class-level javadoc), this function performs the remaining deletion steps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeDeletionSelector

public TreeDeletionSelector(Map allNodes)
Build the selector with all nodes in the tree to delete.

Parameters:
allNodes - Map
Method Detail

determineDeletionTree

public void determineDeletionTree(Node rootToDelete,
                                  Collection toSave,
                                  Collection toDelete)
                           throws DBException
After step 1 is completed (see class-level javadoc), this function performs the remaining deletion steps.

Parameters:
rootToDelete - The root of the tree to delete. It is best to use a collection that can have speedy iteration and deletions.
toSave - A collection to be built of objects to save. It is better to use a collection that can have speedy lookups and insertions.
toDelete - A collection to be built of objects to delete.
Throws:
DBException - upon Expresso database error.


Copyright © 2004-2006 Codeguild, Inc.. All Rights Reserved.