org.squashtest.tm.service.internal.deletion
Class LockedFileInferenceGraph

java.lang.Object
  extended by org.squashtest.tm.domain.library.structures.LibraryGraph<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node>
      extended by org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph

public class LockedFileInferenceGraph
extends org.squashtest.tm.domain.library.structures.LibraryGraph<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node>


Nested Class Summary
 
Nested classes/interfaces inherited from class org.squashtest.tm.domain.library.structures.LibraryGraph
org.squashtest.tm.domain.library.structures.LibraryGraph.GraphNodePair
 
Constructor Summary
LockedFileInferenceGraph()
           
 
Method Summary
 void build(List<Object[]> rawData)
           
 List<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node> collectDeletableNodes()
          Once the locks are resolved, will return the nodes that are eventually deletable.
 List<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node> collectLockedCandidates()
          Once the locks are resolved, will return the list of nodes that are both locked and candidates.
 List<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node> collectLockedNodes()
          Once the locks are resolved, returns all the nodes that are locked.
 List<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node> collectLockers()
          Once the locks are resolved, return the list of nodes that are locked and were not candidates.
 boolean hasLockedFiles()
           
 void reset()
           
protected  void resolveLockedFiles()
          That method will check that if a test case is candidate to deletion, all test cases calling it directly or indirectly will be deleted along.
 void setCandidatesToDeletion(List<Long> candidates)
           
 
Methods inherited from class org.squashtest.tm.domain.library.structures.LibraryGraph
addNodes, collect, filter, filterAndcollect, getChildless, getNode, getNodes, getOrphans, newPair, newPair, setNodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockedFileInferenceGraph

public LockedFileInferenceGraph()
Method Detail

setCandidatesToDeletion

public void setCandidatesToDeletion(List<Long> candidates)

build

public void build(List<Object[]> rawData)

reset

public void reset()

resolveLockedFiles

protected void resolveLockedFiles()

That method will check that if a test case is candidate to deletion, all test cases calling it directly or indirectly will be deleted along. If so the test case is deletable, else it is locked.

Requires the graph to be built. The graph must be acyclic, of fear my wrath.

algorithm :
  1. init : all nodes are non deletable
  2. remaining_nodes := orphan nodes that are to be deleted
  3. for all nodes in remaining_nodes, node.deletable := true
  4. while remaining_nodes is not empty
    1. node := first of remaining_nodes
    2. for child in node.children
      1. child.parentProcessed +=1
      2. if child.parentDeletableCount = child.parent.size and child should be deleted
        1. child.deletable := true
        2. remaining_nodes += child
    3. remove node from remaining_nodes
  5. done

note : the algorithm starts from the parent nodes of the graph and explore the nodes breadth-first. So we are sure that all parent nodes will be processed before their children are (and so the algorithm works).


collectLockedNodes

public List<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node> collectLockedNodes()
Once the locks are resolved, returns all the nodes that are locked.

Returns:

collectLockedCandidates

public List<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node> collectLockedCandidates()
Once the locks are resolved, will return the list of nodes that are both locked and candidates.

Returns:

collectLockers

public List<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node> collectLockers()
Once the locks are resolved, return the list of nodes that are locked and were not candidates. They are most likely locking other nodes.

Returns:

collectDeletableNodes

public List<org.squashtest.tm.service.internal.deletion.LockedFileInferenceGraph.Node> collectDeletableNodes()
Once the locks are resolved, will return the nodes that are eventually deletable. Note that by design, a node is deletable only if it was a candidate to deletion (see resolveLockedFiles() for the reasons of that statement).

Returns:

hasLockedFiles

public boolean hasLockedFiles()


Copyright © 2010-2013 Henix, henix.fr. All Rights Reserved.