Search in sources :

Example 1 with GeoObjectType

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

the class MasterList 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) LinkedList(java.util.LinkedList) List(java.util.List)

Example 2 with GeoObjectType

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

the class CreateGeoObjectAction 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.create.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 3 with GeoObjectType

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

the class RegistryController method listGeoObjectTypes.

/**
 * Returns an array of (label, code) pairs that define all of the geo object
 * types in the system.
 *
 * @pre
 * @post
 *
 * @returns @throws
 */
@Endpoint(url = "geoobjecttype/list-types", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF listGeoObjectTypes(ClientRequestIF request, @RequestParamter(name = "includeAbstractTypes", required = true) Boolean includeAbstractTypes) {
    GeoObjectType[] gots = this.registryService.getGeoObjectTypes(request.getSessionId(), null, null, PermissionContext.READ);
    Arrays.sort(gots, new Comparator<GeoObjectType>() {

        @Override
        public int compare(GeoObjectType o1, GeoObjectType o2) {
            return o1.getLabel().getValue().compareTo(o2.getLabel().getValue());
        }
    });
    JsonArray jarray = new JsonArray();
    for (int i = 0; i < gots.length; ++i) {
        GeoObjectType geoObjectType = gots[i];
        if (!geoObjectType.getCode().equals("ROOT") && (includeAbstractTypes || !geoObjectType.getIsAbstract())) {
            JsonObject type = new JsonObject();
            type.addProperty("label", geoObjectType.getLabel().getValue());
            type.addProperty("code", geoObjectType.getCode());
            type.addProperty("orgCode", geoObjectType.getOrganizationCode());
            type.addProperty("superTypeCode", geoObjectType.getSuperTypeCode());
            jarray.add(type);
        }
    }
    return new RestBodyResponse(jarray);
}
Also used : JsonArray(com.google.gson.JsonArray) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) JsonObject(com.google.gson.JsonObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 4 with GeoObjectType

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

the class RegistryController method getTypeAncestors.

@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "geoobjecttype/get-ancestors")
public ResponseIF getTypeAncestors(ClientRequestIF request, @RequestParamter(name = "code", required = true) String code, @RequestParamter(name = "hierarchyCode", required = true) String hierarchyCode, @RequestParamter(name = "includeInheritedTypes") Boolean includeInheritedTypes, @RequestParamter(name = "includeChild") Boolean includeChild) {
    if (includeInheritedTypes == null) {
        includeInheritedTypes = false;
    }
    JsonArray response = new JsonArray();
    List<GeoObjectType> ancestors = this.registryService.getAncestors(request.getSessionId(), code, hierarchyCode, includeInheritedTypes, includeChild);
    for (GeoObjectType ancestor : ancestors) {
        JsonObject object = new JsonObject();
        object.addProperty("label", ancestor.getLabel().getValue());
        object.addProperty("code", ancestor.getCode());
        response.add(object);
    }
    return new RestBodyResponse(response.toString());
}
Also used : JsonArray(com.google.gson.JsonArray) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) JsonObject(com.google.gson.JsonObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 5 with GeoObjectType

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

the class RegistryController method getGeoObjectTypes.

/**
 * Returns an array of {@link GeoOjectType} objects that define the given list
 * of types.
 *
 * @pre @post
 *
 * @param types
 *          A serialized json array of GeoObjectType codes. If blank then all
 *          GeoObjectType objects are returned.
 * @param hierarchies
 *          A serialized json array of HierarchyType codes. If blank then
 *          GeoObjectTypes belonging to all hierarchies are returned.
 *
 * @returns @throws
 */
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_TYPE_GET_ALL)
public ResponseIF getGeoObjectTypes(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TYPE_GET_ALL_PARAM_TYPES) String types, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TYPE_GET_ALL_PARAM_HIERARCHIES) String hierarchies, @RequestParamter(name = "context") String context) {
    String[] aTypes = null;
    if (types != null) {
        JSONArray jaTypes = new JSONArray(types);
        aTypes = new String[jaTypes.length()];
        for (int i = 0; i < jaTypes.length(); i++) {
            aTypes[i] = jaTypes.getString(i);
        }
    }
    String[] aHierarchies = null;
    if (hierarchies != null) {
        JSONArray jaHierarchies = new JSONArray(hierarchies);
        aHierarchies = new String[jaHierarchies.length()];
        for (int i = 0; i < jaHierarchies.length(); i++) {
            aHierarchies[i] = jaHierarchies.getString(i);
        }
    }
    PermissionContext pContext = PermissionContext.get(context);
    GeoObjectType[] gots = this.registryService.getGeoObjectTypes(request.getSessionId(), aTypes, aHierarchies, pContext);
    JsonArray jarray = new JsonArray();
    for (int i = 0; i < gots.length; ++i) {
        JsonObject jo = this.registryService.serialize(request.getSessionId(), gots[i]);
        jarray.add(jo);
    }
    return new RestBodyResponse(jarray);
}
Also used : JsonArray(com.google.gson.JsonArray) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) JSONArray(org.json.JSONArray) PermissionContext(net.geoprism.registry.permission.PermissionContext) JsonObject(com.google.gson.JsonObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint) Endpoint(com.runwaysdk.mvc.Endpoint)

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