Section superiorSection = this.getSuperiorSection(); Site sectionSite = this.getSite(); Integer sectionToDeleteOrder = this.getSectionOrder();
if (this.getAssociatedSectionsCount() != 0) { List<Section> sections = new ArrayList(); sections.addAll(this.getAssociatedSections()); for (Section section : sections) { section.delete(); } }
    public void delete() {	checkIfSectionCanBeDeleted(this);	for (Section subSection : this.getAssociatedSections()) {	    checkIfSectionCanBeDeleted(subSection);	}	Section superiorSection = this.getSuperiorSection();	Site sectionSite = this.getSite();	Integer sectionToDeleteOrder = this.getSectionOrder();	// Delete Associated Items	if (this.getAssociatedItemsCount() != 0) {	    List<Item> items = new ArrayList();	    items.addAll(this.getAssociatedItems());	    for (Item item : items) {		item.delete();	    }	}	// Delete Associated Sections	if (this.getAssociatedSectionsCount() != 0) {	    List<Section> sections = new ArrayList();	    sections.addAll(this.getAssociatedSections());	    for (Section section : sections) {		section.delete();	    }	}	// Delete Associations with Superior Section if exists	if (superiorSection != null) {	    this.setSuperiorSection(null);	}	// Delete Associations with Site	this.setSite(null);	// ReOrder Sections	List<Section> sectionsReordered = sectionSite.getAssociatedSections(superiorSection);	for (Section section : sectionsReordered) {	    Integer sectionOrder = section.getSectionOrder();	    if (sectionOrder.intValue() > sectionToDeleteOrder.intValue()) {		section.setSectionOrder(new Integer(sectionOrder.intValue() - 1));	    }	}	removeRootDomainObject();	super.deleteDomainObject();    }