use of net.geoprism.registry.TypeInUseException in project geoprism-registry by terraframe.
the class ServerGeoObjectType method deleteInTransaction.
@Transaction
private void deleteInTransaction() {
List<ServerHierarchyType> hierarchies = this.getHierarchies(true);
if (hierarchies.size() > 0) {
StringBuilder codes = hierarchies.stream().collect(StringBuilder::new, (x, y) -> x.append(y.getCode()), (a, b) -> a.append(",").append(b));
throw new TypeInUseException("Cannot delete a GeoObjectType used in the hierarchies: " + codes);
}
// for (String hierarchy : hierarchies)
// {
// OIterator<com.runwaysdk.business.ontology.Term> it =
// this.universal.getDirectDescendants(hierarchy);
//
// try
// {
// if (it.hasNext())
// {
// }
// }
// finally
// {
// it.close();
// }
// }
/*
* Delete all subtypes
*/
List<ServerGeoObjectType> subtypes = this.getSubtypes();
for (ServerGeoObjectType subtype : subtypes) {
subtype.deleteInTransaction();
}
/*
* Delete all inherited hierarchies
*/
List<? extends InheritedHierarchyAnnotation> annotations = InheritedHierarchyAnnotation.getByUniversal(getUniversal());
for (InheritedHierarchyAnnotation annotation : annotations) {
annotation.delete();
}
GeoVertexType.remove(this.universal.getUniversalId());
/*
* Delete all Attribute references
*/
// AttributeHierarchy.deleteByUniversal(this.universal);
this.getMetadata().delete();
// This deletes the {@link MdBusiness} as well
this.universal.delete(false);
// Delete the term root
Classifier classRootTerm = TermConverter.buildIfNotExistdMdBusinessClassifier(this.mdBusiness);
classRootTerm.delete();
// roles specified on the super type.
if (this.getSuperType() == null) {
Actor ownerActor = this.universal.getOwner();
if (ownerActor instanceof Roles) {
Roles ownerRole = (Roles) ownerActor;
String roleName = ownerRole.getRoleName();
if (RegistryRole.Type.isOrgRole(roleName)) {
String organizationCode = RegistryRole.Type.parseOrgCode(roleName);
String geoObjectTypeCode = this.type.getCode();
String rmRoleName = RegistryRole.Type.getRM_RoleName(organizationCode, geoObjectTypeCode);
Roles role = Roles.findRoleByName(rmRoleName);
role.delete();
String rcRoleName = RegistryRole.Type.getRC_RoleName(organizationCode, geoObjectTypeCode);
role = Roles.findRoleByName(rcRoleName);
role.delete();
String acRoleName = RegistryRole.Type.getAC_RoleName(organizationCode, geoObjectTypeCode);
role = Roles.findRoleByName(acRoleName);
role.delete();
}
}
}
ListType.markAllAsInvalid(null, this);
new SearchService().clear(this.getCode());
new ChangeRequestService().markAllAsInvalid(this);
// Delete the transition and transition events
TransitionEvent.removeAll(this);
Transition.removeAll(this);
}
Aggregations