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;
}
Aggregations