Search in sources :

Example 1 with HierarchyRootException

use of net.geoprism.registry.HierarchyRootException in project geoprism-registry by terraframe.

the class ServerGeoObjectType method setInheritedHierarchy.

@Transaction
public InheritedHierarchyAnnotation setInheritedHierarchy(ServerHierarchyType forHierarchy, ServerHierarchyType inheritedHierarchy) {
    // Hierarchy"
    if (!this.isRoot(forHierarchy) || this.getIsAbstract()) {
        throw new HierarchyRootException();
    }
    HierarchicalRelationshipType fhrt = forHierarchy.getHierarchicalRelationshipType();
    HierarchicalRelationshipType ihrt = inheritedHierarchy.getHierarchicalRelationshipType();
    if (InheritedHierarchyAnnotation.getByForHierarchical(fhrt) != null) {
        throw new UnsupportedOperationException("A hierarchy cannot inherit from more than one other hierarchy");
    }
    if (this.isRoot(inheritedHierarchy)) {
        throw new UnsupportedOperationException("A root node in a hierarchy cannot be inherited");
    }
    InheritedHierarchyAnnotation annotation = new InheritedHierarchyAnnotation();
    annotation.setUniversal(this.universal);
    annotation.setInheritedHierarchicalRelationshipType(ihrt);
    annotation.setForHierarchicalRelationshipType(fhrt);
    annotation.apply();
    return annotation;
}
Also used : HierarchyRootException(net.geoprism.registry.HierarchyRootException) InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) HierarchicalRelationshipType(net.geoprism.registry.HierarchicalRelationshipType) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 HierarchicalRelationshipType (net.geoprism.registry.HierarchicalRelationshipType)1 HierarchyRootException (net.geoprism.registry.HierarchyRootException)1 InheritedHierarchyAnnotation (net.geoprism.registry.InheritedHierarchyAnnotation)1