@Transactional(readOnly = false) @Override public ThesaurusConcept destroyThesaurusConcept(ThesaurusConcept object) { if (object.getStatus() == ConceptStatusEnum.CANDIDATE.getStatus() || object.getStatus() == ConceptStatusEnum.REJECTED.getStatus()) { List<ThesaurusTerm> terms = thesaurusTermDAO.findTermsByConceptId(object.getIdentifier()); for (ThesaurusTerm term : terms) { term.setConcept(null); thesaurusTermDAO.update(term); } List<ThesaurusConcept> childrenConcepts = getChildrenByConceptId(object.getIdentifier(), null); for (ThesaurusConcept childConcept : childrenConcepts) { childConcept.getParentConcepts().remove(object); thesaurusConceptDAO.update(childConcept); } List<ThesaurusConcept> rootChildrenConcepts = thesaurusConceptDAO.getAllRootChildren(object); for (ThesaurusConcept rootChild : rootChildrenConcepts) { rootChild.getRootConcepts().remove(object); thesaurusConceptDAO.update(rootChild); } List<ThesaurusArray> arrays = thesaurusArrayDAO.getConceptSuperOrdinateArrays(object.getIdentifier()); for (ThesaurusArray array : arrays) { thesaurusArrayDAO.delete(array); } List<Alignment> alignments = alignmentDAO.findByTargetConceptId(object.getIdentifier()); for (Alignment alignment : alignments) { if (alignment.getTargetConcepts().size() <= 1) { alignmentDAO.delete(alignment); } } return thesaurusConceptDAO.delete(object); } else { throw new BusinessException( "It's not possible to delete a concept with a status different from candidate or rejected", "delete-concept"); } }