Search in sources :

Example 16 with GeoObjectType

use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.

the class GeoObjectUtilTest method testGetAncestorMapForTreeType.

@Test
@Request
public void testGetAncestorMapForTreeType() {
    ServerGeoObjectType type = USATestData.AREA.getServerObject();
    ServerHierarchyType hierarchyType = ServerHierarchyType.get(USATestData.HIER_ADMIN.getCode());
    ServerGeoObjectIF object = new ServerGeoObjectService().getGeoObjectByCode(USATestData.CO_A_ONE.getCode(), type);
    List<GeoObjectType> dtoAncestors = type.getTypeAncestors(hierarchyType, true);
    List<ServerGeoObjectType> ancestors = new LinkedList<ServerGeoObjectType>();
    for (GeoObjectType ancestor : dtoAncestors) {
        ancestors.add(ServerGeoObjectType.get(ancestor));
    }
    Map<String, LocationInfo> map = object.getAncestorMap(hierarchyType, ancestors);
    Assert.assertEquals(3, map.size());
    // Validate the county values
    Assert.assertTrue(map.containsKey(USATestData.COUNTY.getCode()));
    LocationInfo vObject = map.get(USATestData.COUNTY.getCode());
    Assert.assertEquals(USATestData.CO_C_ONE.getCode(), vObject.getCode());
    Assert.assertEquals(USATestData.CO_C_ONE.getDisplayLabel(), vObject.getLabel());
    // Validate the state values
    Assert.assertTrue(map.containsKey(USATestData.STATE.getCode()));
    vObject = map.get(USATestData.STATE.getCode());
    Assert.assertEquals(USATestData.COLORADO.getCode(), vObject.getCode());
    Assert.assertEquals(USATestData.COLORADO.getDisplayLabel(), vObject.getLabel());
    // Validate the country values
    Assert.assertTrue(map.containsKey(USATestData.COUNTRY.getCode()));
    vObject = map.get(USATestData.COUNTRY.getCode());
    Assert.assertEquals(USATestData.USA.getCode(), vObject.getCode());
    Assert.assertEquals(USATestData.USA.getDisplayLabel(), vObject.getLabel());
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) LinkedList(java.util.LinkedList) LocationInfo(net.geoprism.registry.model.LocationInfo) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 17 with GeoObjectType

use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.

the class ListType method getAncestorMap.

public Map<ServerHierarchyType, List<ServerGeoObjectType>> getAncestorMap(ServerGeoObjectType type) {
    Map<ServerHierarchyType, List<ServerGeoObjectType>> map = new HashMap<>();
    JsonArray hierarchies = this.getHierarchiesAsJson();
    for (int i = 0; i < hierarchies.size(); i++) {
        JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
        List<String> pCodes = this.getParentCodes(hierarchy);
        if (pCodes.size() > 0) {
            String hCode = hierarchy.get("code").getAsString();
            ServerHierarchyType hierarchyType = ServerHierarchyType.get(hCode);
            List<GeoObjectType> dtoAncestors = type.getTypeAncestors(hierarchyType, true);
            List<ServerGeoObjectType> ancestors = new LinkedList<ServerGeoObjectType>();
            for (GeoObjectType ancestor : dtoAncestors) {
                ancestors.add(ServerGeoObjectType.get(ancestor));
            }
            map.put(hierarchyType, ancestors);
        }
    }
    return map;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HashMap(java.util.HashMap) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) LinkedList(java.util.LinkedList) JsonArray(com.google.gson.JsonArray) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) List(java.util.List) LinkedList(java.util.LinkedList)

Example 18 with GeoObjectType

use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.

the class UpdateGeoObjectAction method getMessage.

@Override
protected String getMessage() {
    GeoObjectOverTime go = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), this.getGeoObjectJson());
    GeoObjectType got = go.getType();
    String message = LocalizationFacade.getFromBundles("change.request.email.update.object");
    message = message.replaceAll("\\{0\\}", go.getCode());
    message = message.replaceAll("\\{1\\}", got.getLabel().getValue(Session.getCurrentLocale()));
    return message;
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)

Example 19 with GeoObjectType

use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.

the class GeoObjectTypeMetadata method hasPublicChildren.

public boolean hasPublicChildren() {
    ServerGeoObjectType type = this.getServerType();
    GeoObjectType typeDTO = type.getType();
    List<ServerHierarchyType> hierarchyTypes = ServiceFactory.getMetadataCache().getAllHierarchyTypes();
    for (ServerHierarchyType ht : hierarchyTypes) {
        List<HierarchyNode> roots = ht.getRootGeoObjectTypes();
        for (HierarchyNode root : roots) {
            HierarchyNode node = root.findChild(typeDTO);
            if (node != null) {
                Iterator<HierarchyNode> it = node.getDescendantsIterator();
                while (it.hasNext()) {
                    HierarchyNode child = it.next();
                    if (!child.getGeoObjectType().getIsPrivate()) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) HierarchyNode(org.commongeoregistry.adapter.metadata.HierarchyNode)

Example 20 with GeoObjectType

use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.

the class ServerGeoObjectTypeConverter method build.

public ServerGeoObjectType build(Universal universal) {
    MdBusiness mdBusiness = universal.getMdBusiness();
    MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(universal.getUniversalId());
    com.runwaysdk.system.gis.geo.GeometryType geoPrismgeometryType = universal.getGeometryType().get(0);
    org.commongeoregistry.adapter.constants.GeometryType cgrGeometryType = GeometryTypeFactory.get(geoPrismgeometryType);
    LocalizedValue label = convert(universal.getDisplayLabel());
    LocalizedValue description = convert(universal.getDescription());
    String ownerActerOid = universal.getOwnerOid();
    String organizationCode = Organization.getRootOrganizationCode(ownerActerOid);
    MdGeoVertexDAOIF superType = mdVertex.getSuperClass();
    GeoObjectType geoObjType = new GeoObjectType(universal.getUniversalId(), cgrGeometryType, label, description, universal.getIsGeometryEditable(), organizationCode, ServiceFactory.getAdapter());
    geoObjType.setIsAbstract(mdBusiness.getIsAbstract());
    try {
        GeoObjectTypeMetadata metadata = GeoObjectTypeMetadata.getByKey(universal.getKey());
        geoObjType.setIsPrivate(metadata.getIsPrivate());
    } catch (DataNotFoundException | AttributeDoesNotExistException e) {
        geoObjType.setIsPrivate(false);
    }
    if (superType != null && !superType.definesType().equals(GeoVertex.CLASS)) {
        String parentCode = superType.getTypeName();
        geoObjType.setSuperTypeCode(parentCode);
    }
    geoObjType = this.convertAttributeTypes(universal, geoObjType, mdBusiness);
    return new ServerGeoObjectType(geoObjType, universal, mdBusiness, mdVertex);
}
Also used : GeoObjectTypeMetadata(net.geoprism.registry.model.GeoObjectTypeMetadata) DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) MdGeoVertexDAOIF(com.runwaysdk.gis.dataaccess.MdGeoVertexDAOIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeDoesNotExistException(com.runwaysdk.dataaccess.AttributeDoesNotExistException) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)

Aggregations

GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)33 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)23 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)13 JsonArray (com.google.gson.JsonArray)10 JsonObject (com.google.gson.JsonObject)10 Request (com.runwaysdk.session.Request)10 LinkedList (java.util.LinkedList)7 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)6 Test (org.junit.Test)6 ServerGeoObjectTypeConverter (net.geoprism.registry.conversion.ServerGeoObjectTypeConverter)4 HierarchyNode (org.commongeoregistry.adapter.metadata.HierarchyNode)4 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)4 Endpoint (com.runwaysdk.mvc.Endpoint)3 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)3 List (java.util.List)3 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)3 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)2 Universal (com.runwaysdk.system.gis.geo.Universal)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2