Search in sources :

Example 11 with Universal

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;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) MdAttributeTerm(com.runwaysdk.system.metadata.MdAttributeTerm) Term(org.commongeoregistry.adapter.Term) LinkedList(java.util.LinkedList)

Example 12 with Universal

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;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) Organization(net.geoprism.registry.Organization) LinkedList(java.util.LinkedList)

Example 13 with Universal

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;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) JsonObject(com.google.gson.JsonObject) MdAttributeTerm(com.runwaysdk.system.metadata.MdAttributeTerm) Term(org.commongeoregistry.adapter.Term)

Example 14 with Universal

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;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) LinkedList(java.util.LinkedList)

Example 15 with Universal

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;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) LinkedList(java.util.LinkedList)

Aggregations

Universal (com.runwaysdk.system.gis.geo.Universal)26 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)8 QueryFactory (com.runwaysdk.query.QueryFactory)7 LinkedList (java.util.LinkedList)7 ServerGeoObjectTypeConverter (net.geoprism.registry.conversion.ServerGeoObjectTypeConverter)6 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)5 UniversalQuery (com.runwaysdk.system.gis.geo.UniversalQuery)5 JsonObject (com.google.gson.JsonObject)3 MdGraphClassDAOIF (com.runwaysdk.dataaccess.MdGraphClassDAOIF)3 MdGeoVertexDAO (com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)3 JsonArray (com.google.gson.JsonArray)2 Term (com.runwaysdk.business.ontology.Term)2 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)2 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)2 MdAttributeTerm (com.runwaysdk.system.metadata.MdAttributeTerm)2 List (java.util.List)2 Organization (net.geoprism.registry.Organization)2 GeoObjectTypeMetadata (net.geoprism.registry.model.GeoObjectTypeMetadata)2 Term (org.commongeoregistry.adapter.Term)2 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)2