Search in sources :

Example 11 with CustomSerializer

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

the class RegistryController method updateGeoObjectOverTime.

@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_TIME_UPDATE)
public ResponseIF updateGeoObjectOverTime(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TIME_UPDATE_PARAM_GEOOBJECT) String jGeoObj) {
    GeoObjectOverTime goTime = this.registryService.updateGeoObjectOverTime(request.getSessionId(), jGeoObj);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(goTime.toJSON(serializer));
}
Also used : GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 12 with CustomSerializer

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

the class RegistryController method getGeoObjectByCode.

/**
 * Returns a GeoObject with the given code.
 *
 * @pre @post
 *
 * @param uid
 *          The UID of the GeoObject.
 *
 * @returns a GeoObject in GeoJSON format with the given uid. @throws
 */
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_GET_CODE)
public ResponseIF getGeoObjectByCode(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CODE_PARAM_CODE) String code, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CODE_PARAM_TYPE_CODE) String typeCode, @RequestParamter(name = "date") String date) throws JSONException {
    GeoObject geoObject = this.registryService.getGeoObjectByCode(request.getSessionId(), code, typeCode, GeoRegistryUtil.parseDate(date, true));
    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) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 13 with CustomSerializer

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

the class RegistryLocationController method search.

@Endpoint(error = ErrorSerialization.JSON)
public ResponseIF search(ClientRequestIF request, @RequestParamter(name = "text") String text, @RequestParamter(name = "date") String date) throws JSONException, ParseException {
    List<GeoObject> results = service.search(request.getSessionId(), text, parseDate(date));
    CustomSerializer serializer = ServiceFactory.getRegistryService().serializer(request.getSessionId());
    JsonArray features = results.stream().collect(() -> new JsonArray(), (array, element) -> array.add(element.toJSON(serializer)), (listA, listB) -> {
    });
    JsonObject featureCollection = new JsonObject();
    featureCollection.addProperty("type", "FeatureCollection");
    featureCollection.add("features", features);
    return new RestBodyResponse(featureCollection);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 14 with CustomSerializer

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

the class HierarchyController method insertBetweenTypes.

/**
 * Inserts the {@link GeoObjectType} 'middleGeoObjectTypeCode' into the
 * hierarchy as the child of 'parentGeoObjectTypeCode' and the new parent for
 * 'youngestGeoObjectTypeCode'. If an existing parent/child relationship
 * already exists between 'youngestGeoObjectTypeCode' and
 * 'parentgeoObjectTypeCode', it will first be removed.
 *
 * @param sessionId
 * @param hierarchyTypeCode
 *          code of the {@link HierarchyType}
 * @param parentGeoObjectTypeCode
 *          parent {@link GeoObjectType}.
 * @param middleGeoObjectTypeCode
 *          middle child {@link GeoObjectType} after this method returns
 * @param youngestGeoObjectTypeCode
 *          youngest child {@link GeoObjectType} after this method returns
 */
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "insertBetweenTypes")
public ResponseIF insertBetweenTypes(ClientRequestIF request, @RequestParamter(name = "hierarchyCode", required = true) String hierarchyCode, @RequestParamter(name = "parentGeoObjectTypeCode", required = true) String parentGeoObjectTypeCode, @RequestParamter(name = "middleGeoObjectTypeCode", required = true) String middleGeoObjectTypeCode, @RequestParamter(name = "youngestGeoObjectTypeCode", required = true) String youngestGeoObjectTypeCode) {
    HierarchyType ht = ServiceFactory.getHierarchyService().insertBetweenTypes(request.getSessionId(), hierarchyCode, parentGeoObjectTypeCode, middleGeoObjectTypeCode, youngestGeoObjectTypeCode);
    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 15 with CustomSerializer

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

the class HierarchyController method addToHierarchy.

/**
 * Adds the {@link GeoObjectType} with the given child code to 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.POST, error = ErrorSerialization.JSON, url = "add")
public ResponseIF addToHierarchy(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().addToHierarchy(request.getSessionId(), hierarchyCode, parentGeoObjectTypeCode, childGeoObjectTypeCode);
    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)

Aggregations

CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)29 Endpoint (com.runwaysdk.mvc.Endpoint)25 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)25 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)12 JsonArray (com.google.gson.JsonArray)8 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)7 JsonObject (com.google.gson.JsonObject)5 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)5 Request (com.runwaysdk.session.Request)4 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 Date (java.util.Date)2 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)2 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)2 JSONArray (org.json.JSONArray)2 Locale (java.util.Locale)1 BadServerUriException (net.geoprism.dhis2.dhis2adapter.exception.BadServerUriException)1 HTTPException (net.geoprism.dhis2.dhis2adapter.exception.HTTPException)1 InvalidLoginException (net.geoprism.dhis2.dhis2adapter.exception.InvalidLoginException)1 UnexpectedResponseException (net.geoprism.dhis2.dhis2adapter.exception.UnexpectedResponseException)1 OrganisationUnitGroup (net.geoprism.dhis2.dhis2adapter.response.model.OrganisationUnitGroup)1