}
// FIXME: rework the delete logic, make it faster!!
// first delete all analyzed data before deleting trees:
Study s = pSubmission.getStudy();
getAnalysisService().deleteAnalyses(s);
deleteSubmittedData(pSubmission);
if (s != null) {
// getStudyHome().refresh(s);
// for now only delete in progress study until we have a better
// security handling:
/*
* if (!s.isInProgress()) { String msg = "This method deletes only in progress study
* until a better security is in place."; throw new IllegalArgumentException(msg); }
*/
// Cascade delete:
// * study
// * matrices,
// * trees
// * taxon labels
// getMatrixHome().delete(new
// ArrayList<Matrix>(pSubmission.getSubmittedMatricesReadOnly()));
// getPhyloTreeHome().deleteTreeBlocks(
// new ArrayList<TreeBlock>(pSubmission.getSubmittedTreeBlocksReadOnly()));
//
// pSubmission.clearSubmittedData();
// // taxon labels need to be deleted last, after everyone referencing to them
// // are gone
// getTaxonLabelHome().delete(pSubmission.getSubmittedTaxonLabelsReadOnly());
//
// manage bi-directional relationships:
// pStudy.getSubmitter().removeSubmission(pSubmission);
// Note: ---important: the delete order is important---
// Cascade delete
// all the analyses
// submission
// all taxonLabelSet
// all study specific taxonlabels
// citation
// getAnalysisService().deleteAnalyses(pStudy.getAnalyses());
// getAnalysisService().deleteAnalyses(pStudy.getAnalysesReadOnly());
// Study specific taxonlabels: handled by submission.delete.
// all taxonLabelSet
getStudyHome().deleteAll(s.getTaxonLabelSets());
s.getTaxonLabelSets().clear();
// manage bi-directional relationships:
if (pSubmission.getSubmitter() != null) {
pSubmission.getSubmitter().removeSubmission(pSubmission);
}
getSubmissionHome().deletePersist(pSubmission);
// need to delete study after deleting the submission.
// have to after delete all taxonLabel sets:
getDomainHome().flush();
getTaxonLabelHome().deleteByStudy(s);
Citation c = s.getCitation();
getStudyHome().deletePersist(s);
// Notes: must delete study first before delete the citation, not-null constraint!
if (c != null) {