wt.epm.retriever
Class ResultGraph

java.lang.Object
  extended bywt.epm.retriever.graph.AbstractGraph
      extended bywt.epm.retriever.ResultGraph
All Implemented Interfaces:
PopulatableResult

public class ResultGraph
extends AbstractGraph
implements PopulatableResult

Represents a graph of Iterated objects, interconnected by various BinaryLink links. Allows fast traversing of the network, as well as building other high-performance graph algorithms. Immutable. Can be built using a set of Iterated objects and BinaryLink links. Node and/or Link inner classes can be overwritten, along with the corresponding newNode() and/or newLink() "creator" methods, to allow graph nodes and links to carry any additional information beyond an EPM object reference.


Nested Class Summary
protected  class ResultGraph.GraphBuilder
          Convenience inner class to eliminate some code reduplication while initializing the graph.
static class ResultGraph.Link
          Represents a link (edge) of the graph.
static class ResultGraph.Node
          Represents a node of the graph.
protected  class ResultGraph.NodeInfo
          Auxiliary data structure for initialization.
 
Nested classes inherited from class wt.epm.retriever.graph.AbstractGraph
 
Field Summary
private static ResultGraph.Node[] EMPTY_NODES
           
private static Log log
           
protected  Map oidLinkMap
           
protected  Map oidNodeMap
           
 
Fields inherited from class wt.epm.retriever.graph.AbstractGraph
has_cycles, is_forest, is_inverted, links, LNK_INVERT, LNK_JOINT, LNK_TREE, LNK_UNKNOWN, nodes, rootNodes
 
Constructor Summary
ResultGraph()
          Creates an un-populated graph object.
ResultGraph(boolean isInverted)
          Creates an un-populated graph object.
 
Method Summary
 List getChildLinks(Iterated obj)
          Child links
 List getChildLinks(ObjectIdentifier oid)
          Child links
 List getChildren(Iterated obj)
          Children
 List getChildren(ObjectIdentifier oid)
          Children
 ResultGraph.Node[] getIncompleteNodes()
          An array of all Node objects with getIterated() == null.
 ResultGraph.Link getLink(BinaryLink lnk)
           
 ResultGraph.Link getLink(ObjectIdentifier oid)
           
 ResultGraph.Link[] getLinks()
          An array of all the Link objects.
 ResultGraph.Node getNode(Iterated obj)
           
 ResultGraph.Node getNode(ObjectIdentifier oid)
           
 ResultGraph.Node[] getNodes()
          An array of all the Node objects.
 Iterated getParent(Iterated obj)
          Parent
 Iterated getParent(ObjectIdentifier oid)
          Parent
 BinaryLink getParentLink(Iterated obj)
          Parent
 BinaryLink getParentLink(ObjectIdentifier oid)
          Parent link
 List getParentLinks(Iterated obj)
          Parent links
 List getParentLinks(ObjectIdentifier oid)
          Parent links
 List getParents(Iterated obj)
          Parents
 List getParents(ObjectIdentifier oid)
          Parents
 ResultGraph.Node[] getRootNodes()
          An array of nodes - roots of the spanning forest.
 ResultGraph.Node getTreeRoot()
          The top node of the tree.
protected  ResultGraph.Link newLink(BinaryLink bLink, ResultGraph.Node nodeA, ResultGraph.Node nodeB)
           
protected  ResultGraph.Node newNode(Persistable obj)
           
 void populate(WTCollection objList, WTCollection linkList)
          Takes collections of traced objects and links to build a graph structure.
 
Methods inherited from class wt.epm.retriever.graph.AbstractGraph
analyseGraph, getGraphEdges, getGraphNodes, getLinkCount, getNodeCount, getRootGraphNodes, getTreeRootNode, hasCycles, isEmpty, isForest, isInverted, isTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static Log log

oidNodeMap

protected final Map oidNodeMap

oidLinkMap

protected final Map oidLinkMap

EMPTY_NODES

private static final ResultGraph.Node[] EMPTY_NODES
Constructor Detail

ResultGraph

public ResultGraph()
Creates an un-populated graph object.


ResultGraph

public ResultGraph(boolean isInverted)
Creates an un-populated graph object.

Parameters:
isInverted - link from roleB to RoleA
Method Detail

populate

public void populate(WTCollection objList,
                     WTCollection linkList)
              throws WTException
Takes collections of traced objects and links to build a graph structure. Checks consistency of the input data upon initialization. NB! While tracing Iterated-Mastered links, the retriever looks for an appropriate iteration according to the provided ConfigSpec(s). If (and only if) no iteration was found for a given master, the Mastered object itself will be included in the "nodes" collection. In the last case Node.getIterated() will return null, and Node.getNodeObject() - Mastered object.

Specified by:
populate in interface PopulatableResult
Parameters:
objList - Collection of Iterated or Mastered objects. May be empty, but not null.
linkList - Collection of BinaryLink objects. May be empty, but not null.
Throws:
WTException - - up to an implementation
NullPointerException - if any one of the parameters is null.
ClassCastException - if a node object is not Iterated (or Mastered), or a link object is not a BinaryLink.
IllegalArgumentException - if: 1) Not an Iterated/Mastered object found in the objList; 2) Not a BinaryLink found in the LinkList; 3) Linked object (role A or B) is not in the objList.
IllegalStateException - if more than one Iterated found for a particular master.

newNode

protected ResultGraph.Node newNode(Persistable obj)

newLink

protected ResultGraph.Link newLink(BinaryLink bLink,
                                   ResultGraph.Node nodeA,
                                   ResultGraph.Node nodeB)

getNodes

public final ResultGraph.Node[] getNodes()
An array of all the Node objects.

Returns:
Node[] never null, but may be empty

getLinks

public final ResultGraph.Link[] getLinks()
An array of all the Link objects.

Returns:
Link[] never null, but may be empty

getIncompleteNodes

public final ResultGraph.Node[] getIncompleteNodes()
An array of all Node objects with getIterated() == null.

Returns:
Node[] never null, but may be empty in most cases

getRootNodes

public final ResultGraph.Node[] getRootNodes()
An array of nodes - roots of the spanning forest.

Returns:
Node[] - has at least one element

getTreeRoot

public final ResultGraph.Node getTreeRoot()
The top node of the tree. If the graph actually has more than one connectivity component, just returns the root of the first of them, so check isTree() for more information.

Returns:
Node getRootNodes()[0], never null

getNode

public final ResultGraph.Node getNode(ObjectIdentifier oid)

getNode

public final ResultGraph.Node getNode(Iterated obj)

getLink

public final ResultGraph.Link getLink(ObjectIdentifier oid)

getLink

public final ResultGraph.Link getLink(BinaryLink lnk)

getParents

public final List getParents(ObjectIdentifier oid)
Parents

Parameters:
oid - ObjectIdentifier
Returns:
List of Iterated objects

getParents

public final List getParents(Iterated obj)
Parents

Parameters:
obj - Iterated
Returns:
List of Iterated objects

getParent

public final Iterated getParent(ObjectIdentifier oid)
Parent

Parameters:
oid - ObjectIdentifier
Returns:
Iterated object

getParent

public final Iterated getParent(Iterated obj)
Parent

Parameters:
obj - Iterated
Returns:
Iterated object

getChildren

public final List getChildren(ObjectIdentifier oid)
Children

Parameters:
oid - ObjectIdentifier
Returns:
List of Iterated objects

getChildren

public final List getChildren(Iterated obj)
Children

Parameters:
obj - Iterated
Returns:
List of Iterated objects

getParentLinks

public final List getParentLinks(ObjectIdentifier oid)
Parent links

Parameters:
oid - ObjectIdentifier
Returns:
List of BinaryLink objects

getParentLinks

public final List getParentLinks(Iterated obj)
Parent links

Parameters:
obj - Iterated
Returns:
List of BinaryLink objects

getParentLink

public final BinaryLink getParentLink(ObjectIdentifier oid)
Parent link

Parameters:
oid - ObjectIdentifier
Returns:
BinaryLink object

getParentLink

public final BinaryLink getParentLink(Iterated obj)
Parent

Parameters:
obj - Iterated
Returns:
Iterated object

getChildLinks

public final List getChildLinks(ObjectIdentifier oid)
Child links

Parameters:
oid - ObjectIdentifier
Returns:
List of BinaryLink objects

getChildLinks

public final List getChildLinks(Iterated obj)
Child links

Parameters:
obj - Iterated
Returns:
List of BinaryLink objects