use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class RegistryController method getGeoObjectSuggestions.
/**
* 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 = "geoobject/suggestions", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF getGeoObjectSuggestions(ClientRequestIF request, @RequestParamter(name = "text") String text, @RequestParamter(name = "type", required = true) String type, @RequestParamter(name = "parent") String parent, @RequestParamter(name = "parentTypeCode") String parentTypeCode, @RequestParamter(name = "hierarchy") String hierarchy, @RequestParamter(name = "startDate") String startDateString, @RequestParamter(name = "endDate") 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;
JsonArray response = this.registryService.getGeoObjectSuggestions(request.getSessionId(), text, type, parent, parentTypeCode, hierarchy, startDate, endDate);
return new RestBodyResponse(response);
}
use of com.runwaysdk.mvc.RestBodyResponse 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));
}
use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class RegistryController method listGeoObjectTypes.
/**
* Returns an array of (label, code) pairs that define all of the geo object
* types in the system.
*
* @pre
* @post
*
* @returns @throws
*/
@Endpoint(url = "geoobjecttype/list-types", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF listGeoObjectTypes(ClientRequestIF request, @RequestParamter(name = "includeAbstractTypes", required = true) Boolean includeAbstractTypes) {
GeoObjectType[] gots = this.registryService.getGeoObjectTypes(request.getSessionId(), null, null, PermissionContext.READ);
Arrays.sort(gots, new Comparator<GeoObjectType>() {
@Override
public int compare(GeoObjectType o1, GeoObjectType o2) {
return o1.getLabel().getValue().compareTo(o2.getLabel().getValue());
}
});
JsonArray jarray = new JsonArray();
for (int i = 0; i < gots.length; ++i) {
GeoObjectType geoObjectType = gots[i];
if (!geoObjectType.getCode().equals("ROOT") && (includeAbstractTypes || !geoObjectType.getIsAbstract())) {
JsonObject type = new JsonObject();
type.addProperty("label", geoObjectType.getLabel().getValue());
type.addProperty("code", geoObjectType.getCode());
type.addProperty("orgCode", geoObjectType.getOrganizationCode());
type.addProperty("superTypeCode", geoObjectType.getSuperTypeCode());
jarray.add(type);
}
}
return new RestBodyResponse(jarray);
}
use of com.runwaysdk.mvc.RestBodyResponse 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);
}
use of com.runwaysdk.mvc.RestBodyResponse 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));
}
Aggregations