TransformationService extends BaseTransformationService { @RequestMapping(value = "/export/dataset/{datasetId}/{format}", method = GET) @ApiOperation(value = "Export the given dataset") @Timed public StreamingResponseBody exportDataset( @ApiParam(value = "DataSet id to transform.") @PathVariable(value = "datasetId") final String datasetId, @ApiParam(value = "Output format") @PathVariable("format") final String formatName, @ApiParam(value = "Name of the transformation", defaultValue = "untitled") @RequestParam(value = "name", required = false, defaultValue = "untitled") final String name, @RequestParam final Map<String, String> exportParams) { return applyOnDataset(null, datasetId, formatName, null, name, exportParams); }  @RequestMapping(value = "/apply", method = POST) @ApiOperation(value = "Run the transformation given the provided export parameters", notes = "This operation transforms the dataset or preparation using parameters in export parameters.") @VolumeMetered @AsyncOperation(conditionalClass = GetPrepContentAsyncCondition.class, // resultUrlGenerator = PreparationGetContentUrlGenerator.class, // executionIdGeneratorClass = ExportParametersExecutionIdGenerator.class // ) StreamingResponseBody execute(@ApiParam(
                    value = "Preparation id to apply.") @RequestBody @Valid @AsyncParameter @AsyncExecutionId final ExportParameters parameters); @RequestMapping(value = "/apply/preparation/{preparationId}/{stepId}/metadata", method = GET) @ApiOperation(value = "Run the transformation given the provided export parameters", notes = "This operation transforms the dataset or preparation using parameters in export parameters.") @VolumeMetered @AsyncOperation(conditionalClass = GetPrepMetadataAsyncCondition.class, // resultUrlGenerator = PrepMetadataGetContentUrlGenerator.class, // executionIdGeneratorClass = PrepMetadataExecutionIdGenerator.class) DataSetMetadata executeMetadata(@PathVariable("preparationId") @AsyncParameter String preparationId,
            @PathVariable("stepId") @AsyncParameter String stepId); @RequestMapping(value = "/apply/preparation/{preparationId}/dataset/{datasetId}/{format}", method = GET) @ApiOperation(value = "Transform the given preparation to the given format on the given dataset id", notes = "This operation transforms the dataset using preparation id in the provided format.") @VolumeMetered StreamingResponseBody applyOnDataset(@ApiParam(value = "Preparation id to apply.") @PathVariable(value = "preparationId") final String preparationId,
                                                @ApiParam(value = "DataSet id to transform.") @PathVariable(value = "datasetId") final String datasetId,
                                                @ApiParam(value = "Output format") @PathVariable("format") final String formatName,
                                                @ApiParam(value = "Step id", defaultValue = "head") @RequestParam(value = "stepId", required = false, defaultValue = "head") final String stepId,
                                                @ApiParam(value = "Name of the transformation", defaultValue = "untitled") @RequestParam(value = "name", required = false, defaultValue = "untitled") final String name,
                                                @RequestParam final Map<String, String> exportParams); @RequestMapping(value = "/export/dataset/{datasetId}/{format}", method = GET) @ApiOperation(value = "Export the given dataset") @Timed StreamingResponseBody exportDataset(
            @ApiParam(value = "DataSet id to transform.") @PathVariable(value = "datasetId") final String datasetId,
            @ApiParam(value = "Output format") @PathVariable("format") final String formatName,
            @ApiParam(value = "Name of the transformation", defaultValue = "untitled") @RequestParam(value = "name", required = false, defaultValue = "untitled") final String name,
            @RequestParam final Map<String, String> exportParams); @RequestMapping(value = "/aggregate", method = POST, consumes = APPLICATION_JSON_VALUE) @ApiOperation(value = "Compute the aggregation according to the request body rawParams", consumes = APPLICATION_JSON_VALUE) @VolumeMetered AggregationResult aggregate(@ApiParam(value = "The aggregation rawParams in json") @RequestBody final String rawParams); @RequestMapping(value = "/transform/preview", method = POST, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Preview the transformation on input data", notes = "This operation returns the input data diff between the old and the new transformation actions", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @VolumeMetered void transformPreview(@ApiParam(name = "body", value = "Preview parameters.") @RequestBody final PreviewParameters previewParameters,
                                 final OutputStream output); @RequestMapping(value = "/transform/diff/metadata", method = POST) @ApiOperation(value = "Given a list of requested preview, it applies the diff to each one. A diff is between 2 sets of actions and return the info like created columns ids", notes = "This operation returns the diff metadata", consumes = APPLICATION_JSON_VALUE) @VolumeMetered Stream<StepDiff> getCreatedColumns(@ApiParam(name = "body", value = "Preview parameters list in json.") @RequestBody final List<PreviewParameters> previewParameters); @RequestMapping(value = "/preparation/{preparationId}/cache", method = DELETE) @ApiOperation(value = "Evict content entries related to the preparation", notes = "This operation remove content entries related to the preparation.") @VolumeMetered void evictCache(@ApiParam(value = "Preparation Id.") @PathVariable(value = "preparationId") final String preparationId); @RequestMapping(value = "/transform/suggest/{action}/params", method = POST) @ApiOperation(value = "Get the transformation dynamic parameters", notes = "Returns the transformation parameters.") @Timed GenericParameter dynamicParams(
            @ApiParam(value = "Action name.") @PathVariable("action") final String action,
            @ApiParam(value = "The column id.") @RequestParam(value = "columnId") final String columnId,
            @ApiParam(value = "Data set content as JSON") final InputStream content); @RequestMapping(value = "/actions/column", method = POST) @ApiOperation(value = "Return all actions for a column (regardless of column metadata)", notes = "This operation returns an array of actions.") @ResponseBody Stream<ActionForm> columnActions(@RequestBody(required = false) ColumnMetadata column); @RequestMapping(value = "/suggest/column", method = POST) @ApiOperation(value = "Suggest actions for a given column metadata", notes = "This operation returns an array of suggested actions in decreasing order of importance.") @ResponseBody Stream<ActionForm> suggest(@RequestBody(required = false) ColumnMetadata column, //
            @ApiParam(value = "How many actions should be suggested at most", defaultValue = "5") @RequestParam(
                    value = "limit", defaultValue = "5", required = false) int limit); @RequestMapping(value = "/actions/line", method = GET) @ApiOperation(value = "Return all actions on lines", notes = "This operation returns an array of actions.") @ResponseBody Stream<ActionForm> lineActions(); @RequestMapping(value = "/actions/dataset", method = GET) @ApiOperation(value = "Return all actions on the whole dataset.", notes = "This operation returns an array of actions.") @ResponseBody Stream<ActionForm> datasetActions(); @RequestMapping(value = "/actions/multi_columns", method = GET) @ApiOperation(value = "Return all actions on the selected columns.", notes = "This operation returns an array of actions.") @ResponseBody Stream<ActionForm> multiColumnsActions(); @RequestMapping(value = "/transform/errors", method = RequestMethod.GET) @ApiOperation(value = "Get all transformation related error codes.", notes = "Returns the list of all transformation related error codes.") @Timed Iterable<JsonErrorCodeDescription> listErrors(); @RequestMapping(value = "/export/formats", method = GET) @ApiOperation(value = "Get the available format types") @Timed @PublicAPI Stream<ExportFormatMessage> exportTypes(); @RequestMapping(value = "/export/formats/preparations/{preparationId}", method = GET) @ApiOperation(value = "Get the available format types for the preparation") @Timed Stream<ExportFormatMessage> getPreparationExportTypesForPreparation(@PathVariable String preparationId); @RequestMapping(value = "/export/formats/datasets/{dataSetId}", method = GET) @ApiOperation(value = "Get the available format types for the preparation") @Timed Stream<ExportFormatMessage> getPreparationExportTypesForDataSet(@PathVariable String dataSetId); @RequestMapping(value = "/dictionary", method = GET, produces = APPLICATION_OCTET_STREAM_VALUE) @ApiOperation(value = "Get current dictionary (as serialized object).") @Timed StreamingResponseBody getDictionary(); @RequestMapping(value = "/preparations/{preparationId}/columns/{columnId}/types", method = GET) @ApiOperation(value = "list the types of the wanted column", notes = "This list can be used by user to change the column type.") @Timed @PublicAPI List<SemanticDomain> getPreparationColumnSemanticCategories(
            @ApiParam(value = "The preparation id") @PathVariable String preparationId,
            @ApiParam(value = "The column id") @PathVariable String columnId,
            @ApiParam(value = "The preparation version") @RequestParam(defaultValue = "head") String stepId);  }
@Test public void exportDataSet() throws Exception { String dataSetId = createDataset("input_dataset.csv", "my dataset", "text/csv"); String exportContent = given() .queryParam("name", "ds_export") .expect() .statusCode(200) .log() .ifError() .when() .get("/export/dataset/{id}/{format}", dataSetId, "JSON") .asString(); String expectedContent = IOUtils.toString(this.getClass().getResourceAsStream("no_action_expected.json"), UTF_8); JSONAssert.assertEquals(expectedContent, exportContent, false); }