use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class RegistryLocalizationController method getNewLocaleInformation.
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF getNewLocaleInformation(ClientRequestIF request) throws IOException, ServletException {
JSONObject json = new JSONObject();
JSONArray languages = new JSONArray();
JSONArray countries = new JSONArray();
Locale sessionLocale = LocaleUtils.toLocale(RegistryService.getInstance().getCurrentLocale(request.getSessionId()));
for (Locale locale : LocalizationFacade.getAvailableLanguagesSorted()) {
JSONObject jobj = new JSONObject();
jobj.put("key", locale.getLanguage());
jobj.put("label", locale.getDisplayLanguage(sessionLocale));
languages.put(jobj);
}
for (Locale locale : LocalizationFacade.getAvailableCountriesSorted()) {
JSONObject jobj = new JSONObject();
jobj.put("key", locale.getCountry());
jobj.put("label", locale.getDisplayCountry(sessionLocale));
countries.put(jobj);
}
json.put("languages", languages);
json.put("countries", countries);
return new RestBodyResponse(json);
}
use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class ChangeRequestController method uploadFileCR.
/**
* @param request
* @param crOid
* @param file
* @return
* @throws IOException
*/
@Endpoint(url = "upload-file-cr", method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF uploadFileCR(ClientRequestIF request, @RequestParamter(name = "crOid") String crOid, @RequestParamter(name = "file") MultipartFileParameter file) throws IOException {
try (InputStream stream = file.getInputStream()) {
String fileName = file.getFilename();
String vfOid = service.uploadFileCR(request.getSessionId(), crOid, fileName, stream);
return new RestBodyResponse(vfOid);
}
}
use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class ClassificationController method apply.
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = "apply")
public ResponseIF apply(ClientRequestIF request, @RequestParamter(name = "classificationCode") String classificationCode, @RequestParamter(name = "parentCode") String parentCode, @RequestParamter(name = "classification") String classification, @RequestParamter(name = "isNew") Boolean isNew) {
JsonObject object = JsonParser.parseString(classification).getAsJsonObject();
JsonObject response = this.service.apply(request.getSessionId(), classificationCode, parentCode, object, isNew);
return new RestBodyResponse(response);
}
use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphController method getParents.
@Endpoint(url = "get-parents", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF getParents(ClientRequestIF request, @RequestParamter(name = "childCode", required = true) String childCode, @RequestParamter(name = "childTypeCode", required = true) String childTypeCode, @RequestParamter(name = "directedGraphCode", required = true) String directedGraphCode, @RequestParamter(name = "recursive", required = true) Boolean recursive, @RequestParamter(name = "date", required = true) String sDate) {
Date date = GeoRegistryUtil.parseDate(sDate, true);
JsonObject response = this.service.getParents(request.getSessionId(), childCode, childTypeCode, directedGraphCode, recursive, date);
return new RestBodyResponse(response);
}
use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.
the class ExcelImportController method getConfiguration.
@Endpoint(url = "get-configuration", method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF getConfiguration(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.getExcelConfiguration(request.getSessionId(), type, sDate, eDate, fileName, stream, strategy, copyBlank);
return new RestBodyResponse(configuration);
}
}
Aggregations