org.squashtest.tm.service.internal.deletion
Class AbstractNodeDeletionHandler<NODE extends org.squashtest.tm.domain.library.LibraryNode,FOLDER extends org.squashtest.tm.domain.library.Folder<NODE>>

java.lang.Object
  extended by org.squashtest.tm.service.internal.deletion.AbstractNodeDeletionHandler<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 AbstractNodeDeletionHandler<NODE extends org.squashtest.tm.domain.library.LibraryNode,FOLDER extends org.squashtest.tm.domain.library.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
AbstractNodeDeletionHandler()
           
 
Method Summary
protected abstract  OperationReport batchDeleteNodes(List<Long> ids)
          Will delete the nodes identified by the ids parameter.
 OperationReport 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 flat 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

AbstractNodeDeletionHandler

public AbstractNodeDeletionHandler()
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 org.squashtest.tm.domain.library.LibraryNode,FOLDER extends org.squashtest.tm.domain.library.Folder<NODE>>
Parameters:
targetIds - the ids of the input node.
Returns:
a list of SuppressionPreviewReport.

deleteNodes

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

Specified by:
deleteNodes in interface NodeDeletionHandler<NODE extends org.squashtest.tm.domain.library.LibraryNode,FOLDER extends org.squashtest.tm.domain.library.Folder<NODE>>
Parameters:
targetIds - the list of node ids selected by the user.
Returns:
an OperationReport saying what happened.

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).

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 flat 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 OperationReport 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.
Returns:


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