Search in sources :

Example 1 with InputStreamResponse

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

the class ListTypeController method tile.

@Endpoint(error = ErrorSerialization.JSON)
public ResponseIF tile(ClientRequestIF request, @RequestParamter(name = "x", required = true) Integer x, @RequestParamter(name = "y", required = true) Integer y, @RequestParamter(name = "z", required = true) Integer z, @RequestParamter(name = "config", required = true) String config) throws JSONException {
    JSONObject object = new JSONObject(config);
    object.put("x", x);
    object.put("y", y);
    object.put("z", z);
    return new InputStreamResponse(this.service.getTile(request.getSessionId(), object), "application/x-protobuf", null);
}
Also used : JSONObject(org.json.JSONObject) InputStreamResponse(com.runwaysdk.mvc.InputStreamResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 2 with InputStreamResponse

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

the class LocalizationService method exportSpreadsheetInRequest.

@Request(RequestType.SESSION)
public InputStreamResponse exportSpreadsheetInRequest(String sessionId) {
    ServiceFactory.getRolePermissionService().enforceSRA();
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    BufferedOutputStream buffer = new BufferedOutputStream(bytes);
    LocalizationExcelExporter exporter = new LocalizationExcelExporter(buildConfig(), buffer);
    exporter.export();
    ByteArrayInputStream is = new ByteArrayInputStream(bytes.toByteArray());
    return new InputStreamResponse(is, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "localization.xlsx");
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) LocalizationExcelExporter(com.runwaysdk.localization.LocalizationExcelExporter) InputStreamResponse(com.runwaysdk.mvc.InputStreamResponse) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) Request(com.runwaysdk.session.Request)

Example 3 with InputStreamResponse

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

the class ListTypeController method downloadShapefile.

@Endpoint(url = "download-shapefile", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF downloadShapefile(ClientRequestIF request, @RequestParamter(name = "oid", required = true) String oid, @RequestParamter(name = "filter") String filter) throws JSONException {
    JsonObject masterList = this.service.getVersion(request.getSessionId(), oid);
    String code = masterList.get(ListType.TYPE_CODE).getAsString() + "-" + masterList.get(ListTypeVersion.FORDATE).getAsString();
    return new InputStreamResponse(service.downloadShapefile(request.getSessionId(), oid), "application/zip", code + ".zip");
}
Also used : JsonObject(com.google.gson.JsonObject) InputStreamResponse(com.runwaysdk.mvc.InputStreamResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 4 with InputStreamResponse

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

the class ListTypeController method exportSpreadsheet.

// @Endpoint(url = "generate-shapefile", method = ServletMethod.POST, error =
// ErrorSerialization.JSON)
// public ResponseIF generateShapefile(ClientRequestIF request,
// @RequestParamter(name = "oid") String oid) throws JSONException
// {
// final String jobId = service.generateShapefile(request.getSessionId(),
// oid);
// 
// final RestResponse response = new RestResponse();
// response.set("job", jobId);
// 
// return response;
// }
@Endpoint(url = "export-spreadsheet", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF exportSpreadsheet(ClientRequestIF request, @RequestParamter(name = "oid", required = true) String oid, @RequestParamter(name = "criteria") String criteria) throws JSONException {
    JsonObject masterList = this.service.getVersion(request.getSessionId(), oid);
    String code = masterList.get(ListType.TYPE_CODE).getAsString() + "-" + masterList.get(ListTypeVersion.FORDATE).getAsString();
    return new InputStreamResponse(service.exportSpreadsheet(request.getSessionId(), oid, criteria), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", code + ".xlsx");
}
Also used : JsonObject(com.google.gson.JsonObject) InputStreamResponse(com.runwaysdk.mvc.InputStreamResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 5 with InputStreamResponse

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

the class ListTypeController method exportShapefile.

@Endpoint(url = "export-shapefile", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF exportShapefile(ClientRequestIF request, @RequestParamter(name = "oid", required = true) String oid, @RequestParamter(name = "criteria") String criteria) throws JSONException {
    JsonObject masterList = this.service.getVersion(request.getSessionId(), oid);
    String code = masterList.get(ListType.TYPE_CODE).getAsString() + "-" + masterList.get(ListTypeVersion.FORDATE).getAsString();
    return new InputStreamResponse(service.exportShapefile(request.getSessionId(), oid, criteria), "application/zip", code + ".zip");
}
Also used : JsonObject(com.google.gson.JsonObject) InputStreamResponse(com.runwaysdk.mvc.InputStreamResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Aggregations

InputStreamResponse (com.runwaysdk.mvc.InputStreamResponse)6 Endpoint (com.runwaysdk.mvc.Endpoint)5 JsonObject (com.google.gson.JsonObject)3 LocalizationExcelExporter (com.runwaysdk.localization.LocalizationExcelExporter)1 Request (com.runwaysdk.session.Request)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 JSONObject (org.json.JSONObject)1