Search in sources :

Example 1 with CustomSerializer

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

use of org.commongeoregistry.adapter.metadata.CustomSerializer 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 3 with CustomSerializer

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

the class RegistryController method getOrganizations.

/**
 * 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 = "organizations/get-all", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF getOrganizations(ClientRequestIF request) throws ParseException {
    OrganizationDTO[] orgs = this.registryService.getOrganizations(request.getSessionId(), null);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    JsonArray orgsJson = new JsonArray();
    for (OrganizationDTO org : orgs) {
        orgsJson.add(org.toJSON(serializer));
    }
    return new RestBodyResponse(orgsJson);
}
Also used : JsonArray(com.google.gson.JsonArray) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) OrganizationDTO(org.commongeoregistry.adapter.metadata.OrganizationDTO) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 4 with CustomSerializer

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

the class RegistryController method submitDataConflictResolution.

/**
 * Submit scheduled job conflict.
 *
 * @param sessionId
 * @param conflict
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = "registry/submit-conflict")
public ResponseIF submitDataConflictResolution(ClientRequestIF request, @RequestParamter(name = "conflict", required = true) String conflict) {
    // TODO: set this method up
    HierarchyType hierarchyType = ServiceFactory.getHierarchyService().createHierarchyType(request.getSessionId(), conflict);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(hierarchyType.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 CustomSerializer

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

the class RegistryController method createGeoObject.

/**
 * Creates a new GeoObject in the Common Geo-Registry
 *
 * @pre
 * @post
 *
 * @param geoObject
 *          in GeoJSON format to be created.
 * @throws ParseException
 *
 * @returns
 * @throws //TODO
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_CREATE)
public ResponseIF createGeoObject(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_CREATE_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.createGeoObject(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)

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