com.ptc.windchill.upgrade.ius
Class DependencyGraphModel

java.lang.Object
  extended bycom.ptc.windchill.upgrade.ius.DependencyGraphModel

public final class DependencyGraphModel
extends Object

Maintains a graph of interdependencies betwee all the updates in a particular UpdateStore Provides an easy way to ask for predecessors and successors of an IncrementalUpdate. It will detect if there are dependency cycles between updates. It will also detect if there is more than one dependency path from an update to another where there are required/exclusion conflicts.

See Also:
IncrementalUpdate, UpdateStore

Nested Class Summary
private  class DependencyGraphModel.ConflictDetector
          Searches for required/excludes conflicts in the dependency graph.
private  class DependencyGraphModel.CycleDetector
          Searches for cycles in the dependency graph.
private  class DependencyGraphModel.Edge
          Generic edge class.
private  class DependencyGraphModel.ExcludingEdge
          Edge to denote an exclusion dependency as: "If the to-node is run, it precludes the from-node from running"
private  class DependencyGraphModel.InvalidVersionOrderingDetector
           
private  class DependencyGraphModel.Node
          A node in the dependency graph.
private  class DependencyGraphModel.RequiringEdge
          Edge to denote an required dependency as: "The to-node is required for the from-node to work"
 
Field Summary
private static String CLASSNAME
           
private static boolean DEBUG
           
private  ArrayList edges_
           
private static String EOL
           
private  HashMap fromKeyedEdges_
           
private  List iuSequence_
           
private  HashMap keyedNodes_
           
private  HashMap keyedUpdates_
           
private static DebugWriter LOG
           
private  String storeDescription_
           
private  HashMap toKeyedEdges_
           
 
Constructor Summary
DependencyGraphModel()
          Create a model that is a snapshot of the dependencies between incremental updates in the provided UpdateStore.
DependencyGraphModel(UpdateStore store)
           
 
Method Summary
private  void addToSequenceIfNotYetAdded(IncrementalUpdate update, HashSet has_been_added)
           
private  void adjustForVersionOrderInconsistencies()
           
private  void assertIusAreOrderedCorrectly()
           
private  void buildSequence()
          Adds IUs to a sequence with depended-upon IUs being added first.
private  void collectUuidsFromNodesPointedToBy(DependencyGraphModel.Node node, Class edge_class, Set container, boolean recurse)
          Generic method to collect nodes pointed to by the specified node along edges of the provided class.
private  void collectUuidsFromNodesPointingTo(DependencyGraphModel.Node node, Class edge_class, Collection container, boolean recurse)
          Generic method to collect nodes pointing to the specified node along edges of the provided class.
 String describe()
           
 String describe(Set ius_to_mark)
           
private  String divWrap(String content)
           
private  String divWrap(String content, int depth, String extra_style, boolean hanging_indent)
           
private  String divWrapWithTopBorder(String content, int depth)
           
private  String edgeStackToPath(Stack edge_stack)
          Renders the path as a String.
(package private)  Set getAllPredecessorsOf(UUID uuid)
           
(package private)  Set getAllSuccessorsOf(UUID uuid)
           
private  ArrayList getEdgesFrom(DependencyGraphModel.Node node)
          Collection of edges from this node.
private  ArrayList getEdgesTo(DependencyGraphModel.Node node)
          Collection of edges to this node.
 Set getExcludedImmediateSuccessorsOf(UUID uuid)
          Collection of UUIDs of updates that the corresponding node excludes.
 Set getExcludingImmediatePredecessorsOf(UUID uuid)
          Collection of UUIDs of updates that the corresponding node is excluded by.
 List getIncrementalUpdateSequence()
           
 Set getRequiredImmediatePredecessorsOf(UUID uuid)
          Collection of UUIDs of updates that the corresponding node requires.
 Set getRequiringImmediateSuccessorsOf(UUID uuid)
          Collection of UUIDs of updates that required the corresponding node.
(package private)  IncrementalUpdate getUpdateFor(UUID uuid)
           
(package private)  Iterator getUpdates()
           
(package private)  Iterator getUpdateUuids()
           
private  void prepGraph(UpdateStore store)
          Populate the graph's nodes and edges based on the contents of the UpdateStore.
private  void process(IncrementalUpdate update, StringBuffer buffer, int depth, boolean forward)
           
private  DependencyGraphModel.Node safeGetNodeFor(UUID uuid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOL

private static final String EOL

CLASSNAME

private static final String CLASSNAME

DEBUG

private static final boolean DEBUG

LOG

private static final DebugWriter LOG

keyedUpdates_

private HashMap keyedUpdates_

keyedNodes_

private HashMap keyedNodes_

edges_

private ArrayList edges_

fromKeyedEdges_

private HashMap fromKeyedEdges_

toKeyedEdges_

private HashMap toKeyedEdges_

iuSequence_

private List iuSequence_

storeDescription_

private String storeDescription_
Constructor Detail

DependencyGraphModel

public DependencyGraphModel()
                     throws DependencyException
Create a model that is a snapshot of the dependencies between incremental updates in the provided UpdateStore.

Throws:
UpdateStoreException - if there are problems reading the updates from the store
DependencyException - if:

DependencyGraphModel

public DependencyGraphModel(UpdateStore store)
                     throws DependencyException
Method Detail

getUpdateUuids

Iterator getUpdateUuids()

getUpdates

Iterator getUpdates()

getUpdateFor

IncrementalUpdate getUpdateFor(UUID uuid)

prepGraph

private void prepGraph(UpdateStore store)
                throws DependencyException
Populate the graph's nodes and edges based on the contents of the UpdateStore.

Throws:
UpdateStoreException - if errors occur reading the updates from the UpdateStore
DependencyException - if dependencies are specified on IncrementalUpdates that do not exist in the UpdateStore.

collectUuidsFromNodesPointedToBy

private void collectUuidsFromNodesPointedToBy(DependencyGraphModel.Node node,
                                              Class edge_class,
                                              Set container,
                                              boolean recurse)
Generic method to collect nodes pointed to by the specified node along edges of the provided class. The matching nodes are placed into the container.


collectUuidsFromNodesPointingTo

private void collectUuidsFromNodesPointingTo(DependencyGraphModel.Node node,
                                             Class edge_class,
                                             Collection container,
                                             boolean recurse)
Generic method to collect nodes pointing to the specified node along edges of the provided class. The matching nodes are placed into the container.


getEdgesFrom

private ArrayList getEdgesFrom(DependencyGraphModel.Node node)
Collection of edges from this node. The collection is re-computed for each call (for simplicities sake). This can be cached if performance requires it.

Returns:
null if no edges from this node

getEdgesTo

private ArrayList getEdgesTo(DependencyGraphModel.Node node)
Collection of edges to this node. The collection is re-computed for each call (for simplicities sake). This can be cached if performance requires it.

Returns:
null if no edges to this node

safeGetNodeFor

private DependencyGraphModel.Node safeGetNodeFor(UUID uuid)

getRequiredImmediatePredecessorsOf

public Set getRequiredImmediatePredecessorsOf(UUID uuid)
Collection of UUIDs of updates that the corresponding node requires. The collection is re-computed for each call (for simplicities sake). This can be cached if performance requires it.


getExcludingImmediatePredecessorsOf

public Set getExcludingImmediatePredecessorsOf(UUID uuid)
Collection of UUIDs of updates that the corresponding node is excluded by. The collection is re-computed for each call (for simplicities sake). This can be cached if performance requires it.


getRequiringImmediateSuccessorsOf

public Set getRequiringImmediateSuccessorsOf(UUID uuid)
Collection of UUIDs of updates that required the corresponding node. The collection is re-computed for each call (for simplicities sake). This can be cached if performance requires it.


getExcludedImmediateSuccessorsOf

public Set getExcludedImmediateSuccessorsOf(UUID uuid)
Collection of UUIDs of updates that the corresponding node excludes. The collection is re-computed for each call (for simplicities sake). This can be cached if performance requires it.


getAllSuccessorsOf

Set getAllSuccessorsOf(UUID uuid)

getAllPredecessorsOf

Set getAllPredecessorsOf(UUID uuid)

edgeStackToPath

private String edgeStackToPath(Stack edge_stack)
Renders the path as a String.


buildSequence

private void buildSequence()
                    throws DependencyException
Adds IUs to a sequence with depended-upon IUs being added first. The comparator should ensure that IUs with lower minimum-target-versions are earlier in the sequence. If to incremental updates cannot be compared using min-target-versions(e.g. they have no assembly-id in common), then the IU being inserted will be added later in the sequence. Once the sequence is built, the sequence is checked to ensure that, for all ius, their depended-upon IUs appear earlier in the sequence.

Throws:
DependencyException

addToSequenceIfNotYetAdded

private void addToSequenceIfNotYetAdded(IncrementalUpdate update,
                                        HashSet has_been_added)

adjustForVersionOrderInconsistencies

private void adjustForVersionOrderInconsistencies()

assertIusAreOrderedCorrectly

private void assertIusAreOrderedCorrectly()
                                   throws DependencyException
Throws:
DependencyException

getIncrementalUpdateSequence

public List getIncrementalUpdateSequence()

describe

public String describe()

describe

public String describe(Set ius_to_mark)

process

private void process(IncrementalUpdate update,
                     StringBuffer buffer,
                     int depth,
                     boolean forward)

divWrapWithTopBorder

private String divWrapWithTopBorder(String content,
                                    int depth)

divWrap

private String divWrap(String content)

divWrap

private String divWrap(String content,
                       int depth,
                       String extra_style,
                       boolean hanging_indent)