Search in sources :

Example 41 with RestBodyResponse

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

the class RegistryController method getGeoObjectBounds.

@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "geoobject/get-bounds")
public ResponseIF getGeoObjectBounds(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CODE_PARAM_CODE) String code, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARAM_TYPE_CODE) String typeCode) throws JSONException {
    GeoObject geoObject = this.registryService.getGeoObjectByCode(request.getSessionId(), code, typeCode, null);
    String bounds = this.registryService.getGeoObjectBounds(request.getSessionId(), geoObject);
    return new RestBodyResponse(bounds);
}
Also used : GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 42 with RestBodyResponse

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

the class RegistryController method getParentGeoObjects.

/**
 * Get parents of the given GeoObject
 *
 * @pre @post
 *
 * @param childUid
 *          UID of the child object for which the call fetches parents. @param
 *          parentTypes An array of GeoObjectType names of the types of parent
 *          GeoObjects to fetch. If blank then return parents of all
 *          types. @param recursive TRUE if recursive parents of the given
 *          parent with the given types should be returned, FALSE if only
 *          single level parents should be returned.
 * @throws ParseException
 *
 * @returns @throws
 */
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_GET_PARENTS)
public ResponseIF getParentGeoObjects(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_CHILDCODE, required = true) String childCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_CHILD_TYPE_CODE, required = true) String childTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_DATE, required = true) String date, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_PARENT_TYPES) String parentTypes, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARENTS_PARAM_RECURSIVE, required = true) Boolean recursive) throws ParseException {
    String[] aParentTypes = null;
    if (parentTypes != null) {
        JSONArray jaParentTypes = new JSONArray(parentTypes);
        aParentTypes = new String[jaParentTypes.length()];
        for (int i = 0; i < jaParentTypes.length(); i++) {
            aParentTypes[i] = jaParentTypes.getString(i);
        }
    }
    TreeNode tn = this.registryService.getParentGeoObjects(request.getSessionId(), childCode, childTypeCode, aParentTypes, 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 43 with RestBodyResponse

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

the class RegistryController method removeFromHierarchy.

/**
 * Removes the {@link GeoObjectType} with the given child code from the parent
 * {@link GeoObjectType} with the given code for the given
 * {@link HierarchyType} code.
 *
 * @param sessionId
 * @param hierarchyCode
 *          code of the {@link HierarchyType} the child is being added to.
 * @param parentGeoObjectTypeCode
 *          parent {@link GeoObjectType}.
 * @param childGeoObjectTypeCode
 *          child {@link GeoObjectType}.
 */
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.HIERARCHY_TYPE_REMOVE)
public ResponseIF removeFromHierarchy(ClientRequestIF request, @RequestParamter(name = "hierarchyCode", required = true) String hierarchyCode, @RequestParamter(name = "parentGeoObjectTypeCode", required = true) String parentGeoObjectTypeCode, @RequestParamter(name = "childGeoObjectTypeCode", required = true) String childGeoObjectTypeCode) {
    HierarchyType ht = ServiceFactory.getHierarchyService().removeFromHierarchy(request.getSessionId(), hierarchyCode, parentGeoObjectTypeCode, childGeoObjectTypeCode, true);
    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 44 with RestBodyResponse

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

the class RegistryController method addChild.

/**
 * Creates a relationship between @parentUid and @childUid.
 *
 * @pre Both the parent and child have already been persisted / applied
 * @post A relationship will exist between @parent and @child
 *
 * @returns ParentTreeNode The new node which was created with the provided
 *          parent.
 * @param startDate TODO
 * @param endDate TODO
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_ADD_CHILD)
public ResponseIF addChild(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_PARENTCODE, required = true) String parentCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_PARENT_TYPE_CODE, required = true) String parentTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_CHILDCODE, required = true) String childCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_CHILD_TYPE_CODE, required = true) String childTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_HIERARCHY_CODE, required = true) String hierarchyRef, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_START_DATE) String startDateString, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_END_DATE) 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;
    ParentTreeNode pn = ServiceFactory.getGeoObjectService().addChild(request.getSessionId(), parentCode, parentTypeCode, childCode, childTypeCode, hierarchyRef, startDate, endDate);
    return new RestBodyResponse(pn.toJSON());
}
Also used : ParentTreeNode(org.commongeoregistry.adapter.dataaccess.ParentTreeNode) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 45 with RestBodyResponse

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

the class RegistryController method submitNewOrganization.

/**
 * Submit new organization.
 *
 * @param sessionId
 * @param json
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = "orgainization/create")
public ResponseIF submitNewOrganization(ClientRequestIF request, @RequestParamter(name = "json", required = true) String json) {
    OrganizationDTO org = this.registryService.createOrganization(request.getSessionId(), json);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(org.toJSON(serializer));
}
Also used : CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) OrganizationDTO(org.commongeoregistry.adapter.metadata.OrganizationDTO) 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