Map<String,String> referenceMap = new HashMap<String,String>();
referenceMap.put("deleteelementtype", "Delete this particular TreeBlock");
Long treeBlockID = Long.parseLong(request.getParameter("treeblockid"));
TreeBlock pTreeBlock = getPhyloTreeHome().findTreeBlockById(treeBlockID);
Collection<PhyloTree> pTreeCollection = pTreeBlock.getTreeList();
for (PhyloTree pTree : pTreeCollection) {
/*if (pTree.getStudy() != null) { // It means this tree is tied to analysis step
setTestVariable(true);
referenceMap
.put(
"generalmessage",
"Either this TreeBlock or atleast one of the Tree in this Block is tied to an Analysis Step.");
break; // Even if one tree of the block is ties to Analysis step, we can exit the
// for loop.
}*/
for (Analysis analysis : pTree.getStudy().getAnalyses()) {
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
for (AnalysisStep analysisStep : analysisStepList) {
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
for (AnalyzedData analyzedData : analyzedDataSet) {
if (analyzedData instanceof AnalyzedTree) {
if ( pTreeCollection.contains(((AnalyzedTree) analyzedData).getTree())) {
referenceMap.put("generalmessage", "Either this TreeBlock or at least one of the Tree in this Block is tied to an Analysis Step.");
break; // Even if one tree of the block is ties to Analysis step, we can exit the
}
}
}
}
}
}
referenceMap.put("deleteid", "TreeBlock ID : " + treeBlockID);
referenceMap.put("objectname", "TreeBlock Title : " + pTreeBlock.getTitle());
return referenceMap;
}