Example #1
0
  @Override
  public void delete(Session session) {
    // Delete links from this to each parent
    if (getParentOrgLinks() != null) {
      for (SubOrg so : getParentOrgLinks()) {
        session.delete(so);
      }
      setParentOrgLinks(null);
    }
    if (getWebsites() != null) {
      for (Website w : getWebsites()) {
        w.delete(session);
      }
    }
    setWebsites(null);
    if (getGroups() != null) {
      for (Group g : getGroups()) {
        g.delete(false, session); // do a hard delete
      }
    }

    for (Organisation childOrg : childOrgs()) {
      childOrg.delete(session);
    }
    session.delete(this);
    Organisation parent = getOrganisation();
    if (parent != null) {
      parent.getChildOrgs().remove(this);
      session.save(parent);
    }
  }