Search in sources :

Example 11 with Endpoint

use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.

the class RegistryController method getChildGeoObjects.

/**
 * Get children of the given GeoObject
 *
 * @pre @post
 *
 * @param parentUid
 *          UID of the parent object for which the call fetches
 *          children. @param childrentTypes An array of GeoObjectType names of
 *          the types of children GeoObjects to fetch. If blank then return
 *          children of all types. @param recursive TRUE if recursive children
 *          of the given parent with the given types should be returned, FALSE
 *          if only single level children should be returned.
 *
 * @returns @throws
 */
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_GET_CHILDREN)
public ResponseIF getChildGeoObjects(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_PARENTCODE, required = true) String parentCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CHILDREN_PARAM_PARENT_TYPE_CODE, required = true) String parentTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CHILDREN_PARAM_DATE, required = true) String date, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CHILDREN_PARAM_CHILDREN_TYPES) String childrenTypes, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CHILDREN_PARAM_RECURSIVE, required = true) Boolean recursive) {
    String[] aChildTypes = null;
    if (childrenTypes != null) {
        JSONArray jaChildTypes = new JSONArray(childrenTypes);
        aChildTypes = new String[jaChildTypes.length()];
        for (int i = 0; i < jaChildTypes.length(); i++) {
            aChildTypes[i] = jaChildTypes.getString(i);
        }
    }
    TreeNode tn = this.registryService.getChildGeoObjects(request.getSessionId(), parentCode, parentTypeCode, aChildTypes, recursive, GeoRegistryUtil.parseDate(date, true));
    return new RestBodyResponse(tn.toJSON());
}
Also used : ParentTreeNode(org.commongeoregistry.adapter.dataaccess.ParentTreeNode) TreeNode(org.commongeoregistry.adapter.dataaccess.TreeNode) JSONArray(org.json.JSONArray) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 12 with Endpoint

use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.

the class RegistryController method getGeoObjectSuggestions.

/**
 * Returns an array of (label, entityId) pairs that under the given
 * parent/hierarchy and have the given label.
 *
 * @throws ParseException
 *
 * @pre
 * @post
 *
 * @returns @throws
 */
@Endpoint(url = "geoobject/suggestions", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF getGeoObjectSuggestions(ClientRequestIF request, @RequestParamter(name = "text") String text, @RequestParamter(name = "type", required = true) String type, @RequestParamter(name = "parent") String parent, @RequestParamter(name = "parentTypeCode") String parentTypeCode, @RequestParamter(name = "hierarchy") String hierarchy, @RequestParamter(name = "startDate") String startDateString, @RequestParamter(name = "endDate") String endDateString) {
    Date startDate = (startDateString != null && startDateString.length() > 0) ? GeoRegistryUtil.parseDate(startDateString, true) : null;
    Date endDate = (endDateString != null && endDateString.length() > 0) ? GeoRegistryUtil.parseDate(endDateString, true) : null;
    JsonArray response = this.registryService.getGeoObjectSuggestions(request.getSessionId(), text, type, parent, parentTypeCode, hierarchy, startDate, endDate);
    return new RestBodyResponse(response);
}
Also used : JsonArray(com.google.gson.JsonArray) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 13 with Endpoint

use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.

the class RegistryController method updateGeoObject.

/**
 * Update a new GeoObject in the Common Geo-Registry
 *
 * @pre
 * @post
 *
 * @param geoObject
 *          in GeoJSON format to be updated.
 * @throws ParseException
 *
 * @returns
 * @throws //TODO
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_UPDATE)
public ResponseIF updateGeoObject(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_UPDATE_PARAM_GEOOBJECT) String jGeoObj, @RequestParamter(name = "startDate") String startDateString, @RequestParamter(name = "endDate") String endDateString) throws ParseException {
    Date startDate = (startDateString != null && startDateString.length() > 0) ? GeoRegistryUtil.parseDate(startDateString, true) : null;
    Date endDate = (endDateString != null && endDateString.length() > 0) ? GeoRegistryUtil.parseDate(endDateString, true) : null;
    GeoObject geoObject = this.registryService.updateGeoObject(request.getSessionId(), jGeoObj, startDate, endDate);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(geoObject.toJSON(serializer));
}
Also used : GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 14 with Endpoint

use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.

the class RegistryController method manage.

@Endpoint(method = ServletMethod.GET)
public ResponseIF manage() {
    ViewResponse resp = new ViewResponse(JSP_DIR + INDEX_JSP);
    String customFont = GeoregistryProperties.getCustomFont();
    if (customFont != null && customFont.length() > 0) {
        resp.set("customFont", customFont);
    }
    return resp;
}
Also used : ViewResponse(com.runwaysdk.mvc.ViewResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 15 with Endpoint

use of com.runwaysdk.mvc.Endpoint 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)

Aggregations

Endpoint (com.runwaysdk.mvc.Endpoint)68 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)52 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)25 Date (java.util.Date)21 JsonObject (com.google.gson.JsonObject)19 JsonArray (com.google.gson.JsonArray)16 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)11 JSONArray (org.json.JSONArray)11 JSONObject (org.json.JSONObject)11 RestResponse (com.runwaysdk.mvc.RestResponse)8 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)8 SimpleDateFormat (java.text.SimpleDateFormat)6 InputStreamResponse (com.runwaysdk.mvc.InputStreamResponse)5 InputStream (java.io.InputStream)5 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)5 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)4 Locale (java.util.Locale)3 ImportStrategy (net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy)3 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)3