ca.sqlpower.wabit
Class WorkspaceGraphModel

java.lang.Object
  extended by ca.sqlpower.wabit.WorkspaceGraphModel
All Implemented Interfaces:
ca.sqlpower.graph.GraphModel<WabitObject,WorkspaceGraphModelEdge>

public class WorkspaceGraphModel
extends java.lang.Object
implements ca.sqlpower.graph.GraphModel<WabitObject,WorkspaceGraphModelEdge>

This graph takes a WabitObject for its root and makes a graph model that represents all of the root's dependencies. The root is included in the dependencies. The children can be included or the graph can just be of the dependencies. If the children are not included in the graph then the parents will replace their children when adding edges.

Example:
If we have a workspace with a report, chart, query, and 2 data sources the parent tree would look like the following

                       Workspace
                           |
    ---------------------------------------------
   /     |       |             |                 \
 DS1    DS2    Query         Chart             Report
                               |                 |
                           ---------             |
                          /    |    \            |
                       Col1  Col2  Col3         Page
                                                 |
                                            -----------
                                           /     |     \
                                          CB1   CB2   CB3
                                           |     |
                                          CR1   CR2
 
Where a DS is a data source, a CB is a content box and a CR is a content renderer.
If we said the Query was based on DS1, the Chart was based on the Query, and the Report was displaying the Chart in CB1 and the Query in CB2 we would have dependencies between the WabitObjects. With dependencies the tree would look like the following

If a graph is made with the report node as the root you will have a graph of the following
             Report
               |
               |
               |
              Page
               |
          ----------------------------
         /                      |     \
        CB1                    CB2   CB3
         |                      |
        CR1                    CR2
         |                      |
       Chart----------------->Query
         |                      |
      ---------                DS1
     /    |    \
   Col1  Col2  Col3
 
If a graph is made without the children of objects being included in the graph the result will look like the following
            Report
              |
         -----------
        /           \
     Chart-------->Query
                     |
                    DS1
 
If we look at a graph without the objects children, just the dependencies, with the query as the root we will get the graph
    Query
      |
     DS1
 
If we then reverse the polarity on the graph above we get
              Query
                |
           -----------
          /           \
        Chart         CR2
          |
         CR1
 


Constructor Summary
WorkspaceGraphModel(WabitObject root, WabitObject graphStartNode, boolean showOnlyDependencies, boolean reversePolarity)
           
 
Method Summary
 java.util.Collection<WabitObject> getAdjacentNodes(WabitObject node)
           
 java.util.Collection<WorkspaceGraphModelEdge> getEdges()
           
 WabitObject getGraphStartNode()
           
 java.util.Collection<WorkspaceGraphModelEdge> getInboundEdges(WabitObject node)
           
 java.util.Collection<WabitObject> getNodes()
           
 java.util.Collection<WorkspaceGraphModelEdge> getOutboundEdges(WabitObject node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkspaceGraphModel

public WorkspaceGraphModel(WabitObject root,
                           WabitObject graphStartNode,
                           boolean showOnlyDependencies,
                           boolean reversePolarity)
Parameters:
root - The Wabit object that is the highest ancestor of all of the objects in the graph. This node is used to create an initial graph ensuring no nodes are missed when reversing polarity. This will normally be the WabitWorkspace.
graphStartNode - The Wabit object to start creating the graph model from. This will be the starting point for finding edges and nodes. Only objects that are dependencies or children, if the child flag is set, recursively will be included in the graph. If the entire workspace is desired to be made into a graph this should be the workspace object. This must be a child/grandchild/etc of the root.
showOnlyDependencies - If false the children of objects will be included in the graph and their parent/child relationship will be included as an edge. If true only the dependency lines will be stored when creating the graph not the parent/child edges. The children will still be traversed if this is true but the edge created for the dependency will link the child traversed from's ancestor to the object the child depends on directly not its ancestor. The ancestor to link to will always be a child of the root object given.
reversePolarity - If false the edges in the graph will go from the parent object to the child object for parent/child edges, and dependencies edges will go from the object that is dependent on an object to the object being depended on. If this is true then the edges in the graph will be reversed so the children of objects will have an edge pointing to their parent and objects being depended on will point to the objects that depend on them.
Method Detail

getAdjacentNodes

public java.util.Collection<WabitObject> getAdjacentNodes(WabitObject node)
Specified by:
getAdjacentNodes in interface ca.sqlpower.graph.GraphModel<WabitObject,WorkspaceGraphModelEdge>

getEdges

public java.util.Collection<WorkspaceGraphModelEdge> getEdges()
Specified by:
getEdges in interface ca.sqlpower.graph.GraphModel<WabitObject,WorkspaceGraphModelEdge>

getInboundEdges

public java.util.Collection<WorkspaceGraphModelEdge> getInboundEdges(WabitObject node)
Specified by:
getInboundEdges in interface ca.sqlpower.graph.GraphModel<WabitObject,WorkspaceGraphModelEdge>

getNodes

public java.util.Collection<WabitObject> getNodes()
Specified by:
getNodes in interface ca.sqlpower.graph.GraphModel<WabitObject,WorkspaceGraphModelEdge>

getOutboundEdges

public java.util.Collection<WorkspaceGraphModelEdge> getOutboundEdges(WabitObject node)
Specified by:
getOutboundEdges in interface ca.sqlpower.graph.GraphModel<WabitObject,WorkspaceGraphModelEdge>

getGraphStartNode

public WabitObject getGraphStartNode()


Copyright © 2009. All Rights Reserved.