Search in sources :

Example 1 with RestBodyResponse

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

the class DirectedAcyclicGraphController method addChild.

@Endpoint(url = "add-child", method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF addChild(ClientRequestIF request, @RequestParamter(name = "parentCode", required = true) String parentCode, @RequestParamter(name = "parentTypeCode", required = true) String parentTypeCode, @RequestParamter(name = "childCode", required = true) String childCode, @RequestParamter(name = "childTypeCode", required = true) String childTypeCode, @RequestParamter(name = "directedGraphCode", required = true) String directedGraphCode, @RequestParamter(name = "startDate", required = true) String startDateStr, @RequestParamter(name = "endDate", required = true) String endDateStr) {
    Date startDate = GeoRegistryUtil.parseDate(startDateStr, true);
    Date endDate = GeoRegistryUtil.parseDate(endDateStr, true);
    JsonObject response = this.service.addChild(request.getSessionId(), parentCode, parentTypeCode, childCode, childTypeCode, directedGraphCode, startDate, endDate);
    return new RestBodyResponse(response);
}
Also used : JsonObject(com.google.gson.JsonObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 2 with RestBodyResponse

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

the class DirectedAcyclicGraphController method getChildren.

@Endpoint(url = "get-children", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF getChildren(ClientRequestIF request, @RequestParamter(name = "parentCode", required = true) String parentCode, @RequestParamter(name = "parentTypeCode", required = true) String parentTypeCode, @RequestParamter(name = "directedGraphCode", required = true) String directedGraphCode, @RequestParamter(name = "recursive", required = true) Boolean recursive, @RequestParamter(name = "date", required = true) String sDate) {
    Date date = GeoRegistryUtil.parseDate(sDate, true);
    JsonObject response = this.service.getChildren(request.getSessionId(), parentCode, parentTypeCode, directedGraphCode, recursive, date);
    return new RestBodyResponse(response);
}
Also used : JsonObject(com.google.gson.JsonObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 3 with RestBodyResponse

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

the class GeoObjectController method doesGeoObjectExistAtRange.

@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "exists-at-range")
public ResponseIF doesGeoObjectExistAtRange(ClientRequestIF request, @RequestParamter(name = "startDate") String startDate, @RequestParamter(name = "endDate") String endDate, @RequestParamter(name = "typeCode") String typeCode, @RequestParamter(name = "code") String code) throws ParseException {
    Date dStartDate = null;
    if (startDate != null) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
        dStartDate = format.parse(startDate);
    }
    Date dEndDate = null;
    if (endDate != null) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
        dEndDate = format.parse(endDate);
    }
    JsonObject stats = ServiceFactory.getGeoObjectService().doesGeoObjectExistAtRange(request.getSessionId(), dStartDate, dEndDate, typeCode, code);
    return new RestBodyResponse(stats.toString());
}
Also used : JsonObject(com.google.gson.JsonObject) SimpleDateFormat(java.text.SimpleDateFormat) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 4 with RestBodyResponse

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

the class HierarchyController method setInheritedHierarchy.

/**
 * Modifies a hierarchy to inherit from another hierarchy at the given
 * GeoObjectType
 *
 * @param request
 *          Session Request
 * @param hierarchyTypeCode
 *          code of the {@link HierarchyType} being modified.
 * @param inheritedHierarchyTypeCode
 *          code of the {@link HierarchyType} being inherited.
 * @param geoObjectTypeCode
 *          code of the root {@link GeoObjectType}.
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = "setInherited")
public ResponseIF setInheritedHierarchy(ClientRequestIF request, @RequestParamter(name = "hierarchyTypeCode", required = true) String hierarchyTypeCode, @RequestParamter(name = "inheritedHierarchyTypeCode", required = true) String inheritedHierarchyTypeCode, @RequestParamter(name = "geoObjectTypeCode", required = true) String geoObjectTypeCode) {
    HierarchyType ht = ServiceFactory.getHierarchyService().setInheritedHierarchy(request.getSessionId(), hierarchyTypeCode, inheritedHierarchyTypeCode, geoObjectTypeCode);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(ht.toJSON(serializer));
}
Also used : HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 5 with RestBodyResponse

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

Aggregations

RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)53 Endpoint (com.runwaysdk.mvc.Endpoint)52 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)25 Date (java.util.Date)16 JsonObject (com.google.gson.JsonObject)14 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)11 JsonArray (com.google.gson.JsonArray)10 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)8 JSONArray (org.json.JSONArray)7 JSONObject (org.json.JSONObject)7 SimpleDateFormat (java.text.SimpleDateFormat)5 InputStream (java.io.InputStream)4 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)4 ImportStrategy (net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy)3 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)3 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)3 PermissionContext (net.geoprism.registry.permission.PermissionContext)2 TreeNode (org.commongeoregistry.adapter.dataaccess.TreeNode)2 ValueObjectDTO (com.runwaysdk.business.ValueObjectDTO)1