Search in sources :

Example 16 with Endpoint

use of com.runwaysdk.mvc.Endpoint 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 17 with Endpoint

use of com.runwaysdk.mvc.Endpoint 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 18 with Endpoint

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

Example 19 with Endpoint

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

the class RegistryController method getGeoObject.

/**
 * Returns a GeoObject with the given uid.
 *
 * @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)
public ResponseIF getGeoObject(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARAM_ID) String id, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARAM_TYPE_CODE) String typeCode, @RequestParamter(name = "date") String date) throws JSONException {
    GeoObject geoObject = this.registryService.getGeoObject(request.getSessionId(), id, 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 20 with Endpoint

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

the class RegistryController method getTypeAncestors.

@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "geoobjecttype/get-ancestors")
public ResponseIF getTypeAncestors(ClientRequestIF request, @RequestParamter(name = "code", required = true) String code, @RequestParamter(name = "hierarchyCode", required = true) String hierarchyCode, @RequestParamter(name = "includeInheritedTypes") Boolean includeInheritedTypes, @RequestParamter(name = "includeChild") Boolean includeChild) {
    if (includeInheritedTypes == null) {
        includeInheritedTypes = false;
    }
    JsonArray response = new JsonArray();
    List<GeoObjectType> ancestors = this.registryService.getAncestors(request.getSessionId(), code, hierarchyCode, includeInheritedTypes, includeChild);
    for (GeoObjectType ancestor : ancestors) {
        JsonObject object = new JsonObject();
        object.addProperty("label", ancestor.getLabel().getValue());
        object.addProperty("code", ancestor.getCode());
        response.add(object);
    }
    return new RestBodyResponse(response.toString());
}
Also used : JsonArray(com.google.gson.JsonArray) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) JsonObject(com.google.gson.JsonObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Aggregations

Endpoint (com.runwaysdk.mvc.Endpoint)68 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)52 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)25 Date (java.util.Date)21 JsonObject (com.google.gson.JsonObject)19 JsonArray (com.google.gson.JsonArray)16 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)11 JSONArray (org.json.JSONArray)11 JSONObject (org.json.JSONObject)11 RestResponse (com.runwaysdk.mvc.RestResponse)8 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)8 SimpleDateFormat (java.text.SimpleDateFormat)6 InputStreamResponse (com.runwaysdk.mvc.InputStreamResponse)5 InputStream (java.io.InputStream)5 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)5 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)4 Locale (java.util.Locale)3 ImportStrategy (net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy)3 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)3