use of net.geoprism.registry.graph.MultipleHierarchyRootsException in project geoprism-registry by terraframe.
the class HierarchicalRelationshipType method removeFromHierarchy.
@Transaction
public void removeFromHierarchy(ServerGeoObjectType parentType, ServerGeoObjectType childType, boolean migrateChildren) {
Universal parent = parentType.getUniversal();
Universal cUniversal = childType.getUniversal();
removeLink(parent, cUniversal, this.getMdTermRelationship().definesType());
if (migrateChildren) {
TermAndRel[] tnrChildren = TermUtil.getDirectDescendants(cUniversal.getOid(), new String[] { this.getMdTermRelationship().definesType() });
if (parent.getKey().equals(Universal.ROOT) && tnrChildren.length > 1) {
MultipleHierarchyRootsException ex = new MultipleHierarchyRootsException();
throw ex;
}
for (TermAndRel tnrChild : tnrChildren) {
Universal child = (Universal) tnrChild.getTerm();
removeLink(cUniversal, child, this.getMdTermRelationship().definesType());
child.addLink(parent, this.getMdTermRelationship().definesType());
}
}
}
Aggregations