Search in sources :

Example 26 with RestBodyResponse

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);
}
Also used : Locale(java.util.Locale) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 27 with RestBodyResponse

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);
    }
}
Also used : InputStream(java.io.InputStream) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 28 with RestBodyResponse

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);
}
Also used : JsonObject(com.google.gson.JsonObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 29 with RestBodyResponse

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);
}
Also used : JsonObject(com.google.gson.JsonObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 30 with RestBodyResponse

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);
    }
}
Also used : ImportStrategy(net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy) JSONObject(org.json.JSONObject) InputStream(java.io.InputStream) SimpleDateFormat(java.text.SimpleDateFormat) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Aggregations

RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)53 Endpoint (com.runwaysdk.mvc.Endpoint)52 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)25 Date (java.util.Date)16 JsonObject (com.google.gson.JsonObject)14 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)11 JsonArray (com.google.gson.JsonArray)10 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)8 JSONArray (org.json.JSONArray)7 JSONObject (org.json.JSONObject)7 SimpleDateFormat (java.text.SimpleDateFormat)5 InputStream (java.io.InputStream)4 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)4 ImportStrategy (net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy)3 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)3 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)3 PermissionContext (net.geoprism.registry.permission.PermissionContext)2 TreeNode (org.commongeoregistry.adapter.dataaccess.TreeNode)2 ValueObjectDTO (com.runwaysdk.business.ValueObjectDTO)1