Search in sources :

Example 1 with TreeNode

use of org.commongeoregistry.adapter.dataaccess.TreeNode 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 2 with TreeNode

use of org.commongeoregistry.adapter.dataaccess.TreeNode 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)

Aggregations

Endpoint (com.runwaysdk.mvc.Endpoint)2 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)2 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)2 TreeNode (org.commongeoregistry.adapter.dataaccess.TreeNode)2 JSONArray (org.json.JSONArray)2