use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class RegistryController method getGeoObjectTypes.
/**
* Returns an array of {@link GeoOjectType} objects that define the given list
* of types.
*
* @pre @post
*
* @param types
* A serialized json array of GeoObjectType codes. If blank then all
* GeoObjectType objects are returned.
* @param hierarchies
* A serialized json array of HierarchyType codes. If blank then
* GeoObjectTypes belonging to all hierarchies are returned.
*
* @returns @throws
*/
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_TYPE_GET_ALL)
public ResponseIF getGeoObjectTypes(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TYPE_GET_ALL_PARAM_TYPES) String types, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TYPE_GET_ALL_PARAM_HIERARCHIES) String hierarchies, @RequestParamter(name = "context") String context) {
String[] aTypes = null;
if (types != null) {
JSONArray jaTypes = new JSONArray(types);
aTypes = new String[jaTypes.length()];
for (int i = 0; i < jaTypes.length(); i++) {
aTypes[i] = jaTypes.getString(i);
}
}
String[] aHierarchies = null;
if (hierarchies != null) {
JSONArray jaHierarchies = new JSONArray(hierarchies);
aHierarchies = new String[jaHierarchies.length()];
for (int i = 0; i < jaHierarchies.length(); i++) {
aHierarchies[i] = jaHierarchies.getString(i);
}
}
PermissionContext pContext = PermissionContext.get(context);
GeoObjectType[] gots = this.registryService.getGeoObjectTypes(request.getSessionId(), aTypes, aHierarchies, pContext);
JsonArray jarray = new JsonArray();
for (int i = 0; i < gots.length; ++i) {
JsonObject jo = this.registryService.serialize(request.getSessionId(), gots[i]);
jarray.add(jo);
}
return new RestBodyResponse(jarray);
}
use of com.runwaysdk.mvc.RestBodyResponse 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);
}
use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class ShapefileController method getShapefileConfiguration.
@Endpoint(url = "get-shapefile-configuration", method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF getShapefileConfiguration(ClientRequestIF request, @RequestParamter(name = "type", required = true) String type, @RequestParamter(name = "startDate") String startDate, @RequestParamter(name = "endDate") String endDate, @RequestParamter(name = "file", required = true) MultipartFileParameter file, @RequestParamter(name = "strategy", required = true) String sStrategy, @RequestParamter(name = "copyBlank", required = true) Boolean copyBlank) throws IOException, JSONException, ParseException {
try (InputStream stream = file.getInputStream()) {
String fileName = file.getFilename();
SimpleDateFormat format = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
Date sDate = startDate != null ? format.parse(startDate) : null;
Date eDate = endDate != null ? format.parse(endDate) : null;
ImportStrategy strategy = ImportStrategy.valueOf(sStrategy);
JSONObject configuration = service.getShapefileConfiguration(request.getSessionId(), type, sDate, eDate, fileName, stream, strategy, copyBlank);
return new RestBodyResponse(configuration);
}
}
use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class TermController method createClassifierSynonym.
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF createClassifierSynonym(ClientRequestIF request, @RequestParamter(name = "classifierId", required = true) String classifierId, @RequestParamter(name = "label", required = true) String label) throws JSONException {
String response = DataUploaderDTO.createClassifierSynonym(request, classifierId, label);
JSONObject object = new JSONObject(response);
return new RestBodyResponse(object);
}
use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class UndirectedGraphController method addChild.
@Endpoint(url = "add-target", method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF addChild(ClientRequestIF request, @RequestParamter(name = "sourceCode", required = true) String sourceCode, @RequestParamter(name = "sourceTypeCode", required = true) String sourceTypeCode, @RequestParamter(name = "targetCode", required = true) String targetCode, @RequestParamter(name = "targetTypeCode", required = true) String targetTypeCode, @RequestParamter(name = "undirectedRelationshipCode", required = true) String undirectedRelationshipCode, @RequestParamter(name = "startDate", required = true) String startDateStr, @RequestParamter(name = "endDate", required = true) String endDateStr) {
Date startDate = GeoRegistryUtil.parseDate(startDateStr, true);
Date endDate = GeoRegistryUtil.parseDate(endDateStr, true);
JsonObject response = this.service.addChild(request.getSessionId(), sourceCode, sourceTypeCode, targetCode, targetTypeCode, undirectedRelationshipCode, startDate, endDate);
return new RestBodyResponse(response);
}
Aggregations