use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class ServerGeoObjectType method getTypeAncestors.
/**
* Returns all ancestors of a GeoObjectType
*
* @param hierarchyType
* The Hierarchy code
* @param includeInheritedTypes
* TODO
* @param GeoObjectType
* child
*
* @return
*/
public List<GeoObjectType> getTypeAncestors(ServerHierarchyType hierarchyType, Boolean includeInheritedTypes) {
List<GeoObjectType> ancestors = new LinkedList<GeoObjectType>();
Collection<com.runwaysdk.business.ontology.Term> list = GeoEntityUtil.getOrderedAncestors(Universal.getRoot(), this.getUniversal(), hierarchyType.getUniversalType());
list.forEach(term -> {
Universal parent = (Universal) term;
if (!parent.getKeyName().equals(Universal.ROOT) && !parent.getOid().equals(this.getUniversal().getOid())) {
ServerGeoObjectType sParent = ServerGeoObjectType.get(parent);
ancestors.add(sParent.getType());
if (includeInheritedTypes && sParent.isRoot(hierarchyType)) {
ServerHierarchyType inheritedHierarchy = sParent.getInheritedHierarchy(hierarchyType);
if (inheritedHierarchy != null) {
ancestors.addAll(0, sParent.getTypeAncestors(inheritedHierarchy, includeInheritedTypes));
}
}
}
});
if (ancestors.size() == 0) {
ServerGeoObjectType superType = this.getSuperType();
if (superType != null) {
return superType.getTypeAncestors(hierarchyType, includeInheritedTypes);
}
}
return ancestors;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class ServerGeoObjectType method getHierarchies.
public List<ServerHierarchyType> getHierarchies(boolean includeFromSuperType) {
List<ServerHierarchyType> hierarchies = new LinkedList<ServerHierarchyType>();
List<ServerHierarchyType> hierarchyTypes = ServiceFactory.getMetadataCache().getAllHierarchyTypes();
Universal root = Universal.getRoot();
for (ServerHierarchyType hierarchyType : hierarchyTypes) {
Organization org = hierarchyType.getOrganization();
if (ServiceFactory.getHierarchyPermissionService().canRead(org.getCode())) {
if (this.isRoot(hierarchyType)) {
hierarchies.add(hierarchyType);
} else {
// Note: Ordered ancestors always includes self
Collection<?> parents = GeoEntityUtil.getOrderedAncestors(root, this.getUniversal(), hierarchyType.getUniversalType());
if (parents.size() > 1) {
hierarchies.add(hierarchyType);
}
}
}
}
if (includeFromSuperType) {
ServerGeoObjectType superType = this.getSuperType();
if (superType != null) {
hierarchies.addAll(superType.getHierarchies(includeFromSuperType));
}
}
return hierarchies;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class ServerGeoObjectType method findHierarchy.
/**
* Finds the actual hierarchy used for the parent type if the parent type is
* inherited from a different hierarchy
*
* @param hierarchyType
* @param parent
* @return
*/
public ServerHierarchyType findHierarchy(ServerHierarchyType hierarchyType, ServerGeoObjectType parent) {
Collection<com.runwaysdk.business.ontology.Term> list = GeoEntityUtil.getOrderedAncestors(Universal.getRoot(), this.getUniversal(), hierarchyType.getUniversalType());
for (Object term : list) {
Universal universal = (Universal) term;
if (parent.getUniversal().getOid().equals(universal.getOid())) {
return hierarchyType;
}
ServerGeoObjectType sParent = ServerGeoObjectType.get(universal);
if (sParent.isRoot(hierarchyType)) {
ServerHierarchyType inheritedHierarchy = sParent.getInheritedHierarchy(hierarchyType);
if (inheritedHierarchy != null) {
return sParent.findHierarchy(inheritedHierarchy, parent);
}
}
}
return hierarchyType;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class ServerHierarchyType method getDirectRootNodes.
public List<ServerGeoObjectType> getDirectRootNodes() {
Universal rootUniversal = Universal.getByKey(Universal.ROOT);
LinkedList<ServerGeoObjectType> roots = new LinkedList<ServerGeoObjectType>();
try (OIterator<? extends Business> i = rootUniversal.getChildren(this.hierarchicalRelationship.getMdTermRelationship().definesType())) {
i.forEach(u -> roots.add(ServerGeoObjectType.get((Universal) u)));
}
return roots;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class ServerHierarchyType method getAllTypes.
public List<ServerGeoObjectType> getAllTypes() {
List<ServerGeoObjectType> types = new LinkedList<ServerGeoObjectType>();
Universal rootUniversal = Universal.getByKey(Universal.ROOT);
try (OIterator<? extends Business> i = rootUniversal.getAllDescendants(this.hierarchicalRelationship.getMdTermRelationship().definesType())) {
i.forEach(u -> types.add(ServerGeoObjectType.get((Universal) u)));
}
return types;
}
Aggregations