Search in sources :

Example 1 with TermAndRel

use of com.runwaysdk.business.ontology.TermAndRel 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());
        }
    }
}
Also used : MultipleHierarchyRootsException(net.geoprism.registry.graph.MultipleHierarchyRootsException) Universal(com.runwaysdk.system.gis.geo.Universal) TermAndRel(com.runwaysdk.business.ontology.TermAndRel) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

TermAndRel (com.runwaysdk.business.ontology.TermAndRel)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 Universal (com.runwaysdk.system.gis.geo.Universal)1 MultipleHierarchyRootsException (net.geoprism.registry.graph.MultipleHierarchyRootsException)1