org.squashtest.csp.tm.internal.service.deletion
Class AbstractNodeDeletionHandlerImpl<NODE extends LibraryNode,FOLDER extends Folder<NODE>>

java.lang.Object
  extended by org.squashtest.csp.tm.internal.service.deletion.AbstractNodeDeletionHandlerImpl<NODE,FOLDER>
Type Parameters:
NODE - a kind of LibraryNode
FOLDER - the corresponding Folder
All Implemented Interfaces:
NodeDeletionHandler<NODE,FOLDER>
Direct Known Subclasses:
CampaignDeletionHandlerImpl, RequirementDeletionHandlerImpl, TestCaseNodeDeletionHandlerImpl

public abstract class AbstractNodeDeletionHandlerImpl<NODE extends LibraryNode,FOLDER extends Folder<NODE>>
extends Object
implements NodeDeletionHandler<NODE,FOLDER>

This class is a abstract and generic implementation of NodeDeletionHandler that implements a few basic rules. Regardless of the end domain object (TestCase, Campaign etc) the common rules are :

Basically this class covers the tasks related to the directory structure (subtree coverage and detection of locked folders) by implementing those two features. On the other hand subclasses must determine, by implementing diagnoseSuppression(List) and detectLockedNodes(List), which nodes are locked for other reasons. See the documentations of the subclasses for more informations.

Author:
bsiri

Constructor Summary
AbstractNodeDeletionHandlerImpl()
           
 
Method Summary
protected abstract  void batchDeleteNodes(List<Long> ids)
          Will delete the nodes identified by the ids parameter.
 List<Long> deleteNodes(List<Long> targetIds)
          NodeDeletionHandler.deleteNodes(List)
protected abstract  List<Long> detectLockedNodes(List<Long> nodeIds)
           Given a list of node ids, returns a sublist corresponding to the ids of the nodes which cannot be deleted according to the specs.
protected abstract  List<SuppressionPreviewReport> diagnoseSuppression(List<Long> nodeIds)
          Given their ids, that method should check the nodes and actually report the informations as specified in NodeDeletionHandler.simulateDeletion(List).
protected  List<Long> findNodeHierarchy(List<Long> rootNodeIds)
          Accepts a list of node ids and returns themselves and their children as a list.
protected  List<Long[]> findPairedNodeHierarchy(List<Long> rootNodeIds)
          Accepts a list of ids and returns themselves and their children as a list of pairs, each pair being an array of long (node ids) such as [ parent.id, child.id ].
protected abstract  FolderDao<FOLDER,NODE> getFolderDao()
          The implemention should return which FolderDao to use depending on the end domain object.
 List<SuppressionPreviewReport> simulateDeletion(List<Long> targetIds)
          NodeDeletionHandler.simulateDeletion(List)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractNodeDeletionHandlerImpl

public AbstractNodeDeletionHandlerImpl()
Method Detail

getFolderDao

protected abstract FolderDao<FOLDER,NODE> getFolderDao()
The implemention should return which FolderDao to use depending on the end domain object.

Returns:
an appropriate FolderDao.

simulateDeletion

public List<SuppressionPreviewReport> simulateDeletion(List<Long> targetIds)
NodeDeletionHandler.simulateDeletion(List)

Specified by:
simulateDeletion in interface NodeDeletionHandler<NODE extends LibraryNode,FOLDER extends Folder<NODE>>
Parameters:
targetIds - the ids of the input node.
Returns:
a list of SuppressionPreviewReport.

deleteNodes

public List<Long> deleteNodes(List<Long> targetIds)
NodeDeletionHandler.deleteNodes(List)

Specified by:
deleteNodes in interface NodeDeletionHandler<NODE extends LibraryNode,FOLDER extends Folder<NODE>>
Parameters:
targetIds - the list of node ids selected by the user.
Returns:
the list of the ids of the nodes actually deleted.

findPairedNodeHierarchy

protected List<Long[]> findPairedNodeHierarchy(List<Long> rootNodeIds)

Accepts a list of ids and returns themselves and their children as a list of pairs, each pair being an array of long (node ids) such as [ parent.id, child.id ]. see FolderDao.findPairedContentForList(List) for details. The nodes input nodes will be paired with null (no parents), and the leaves will be be paired with null (for children). Obviously, only folders have children.

Parameters:
rootNodesIds - the ids defining the upper level of the hierarchy.
Returns:
the rootNodeIds and the ids of their children, paired together as described above.

findNodeHierarchy

protected List<Long> findNodeHierarchy(List<Long> rootNodeIds)

Accepts a list of node ids and returns themselves and their children as a list.

Parameters:
rootNodeIds - rootNodesIds the ids defining the upper level of the hierarchy.
Returns:
the rootNodeIds and the ids of their children.

detectLockedNodes

protected abstract List<Long> detectLockedNodes(List<Long> nodeIds)

Given a list of node ids, returns a sublist corresponding to the ids of the nodes which cannot be deleted according to the specs. The input list includes all the nodes and their children in the directory structure. The implementation is responsible to fetch any other dependencies needed for the completion of its task. The implementation is not required to resolve which folders are locked : this abstract class will handle that on the basis of the returned value.

Parameters:
nodeIds - all the node ids.
Returns:
the sublist of node ids that should NOT be deleted.

diagnoseSuppression

protected abstract List<SuppressionPreviewReport> diagnoseSuppression(List<Long> nodeIds)

Given their ids, that method should check the nodes and actually report the informations as specified in NodeDeletionHandler.simulateDeletion(List). See detectLockedNodes(List) for details regarding the input list.

Parameters:
nodeIds - the complete list of the nodes involved in that report.
Returns:
a list of reports summarizing in human readable format what will happen.

batchDeleteNodes

protected abstract void batchDeleteNodes(List<Long> ids)
Will delete the nodes identified by the ids parameter. Those nodes have been identified as legal for deletion and the implementation should only care of deleting them and unbinding them from the rest of the domain.

Parameters:
ids - the doomed node ids.


Copyright © 2010-2012 Squashtest TM, Squashtest.org. All Rights Reserved.