PreparationAPI extends APIService { @RequestMapping(value = "/api/preparations/{preparationId}/steps/{stepId}/order", method = POST, consumes = APPLICATION_JSON_VALUE) @ApiOperation(value = "Moves a step within a preparation just after the specified <i>parentStepId</i>", notes = "Moves a step within a preparation.") @Timed public void moveStep(@PathVariable("preparationId") final String preparationId, @ApiParam(value = "The current index of the action we want to move.") @PathVariable("stepId") String stepId, @ApiParam(value = "The current index of the action we want to move.") @RequestParam String parentStepId) { LOG.info("Moving step {} after step {}, within preparation {}", stepId, parentStepId, preparationId); final HystrixCommand<String> command = getCommand(PreparationReorderStep.class, preparationId, stepId, parentStepId); command.execute(); LOG.debug("Step {} moved after step {}, within preparation {}", stepId, parentStepId, preparationId); }  @RequestMapping(value = "/api/preparations", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get all preparations.", notes = "Returns the list of preparations the current user is allowed to see.") @Timed Stream<PreparationListItemDTO> listPreparations(
            @ApiParam(name = "name",
                    value = "Filter preparations by name.") @RequestParam(required = false) String name,
            @ApiParam(name = "folder_path", value = "Filter preparations by its folder path.") @RequestParam(
                    required = false, name = "folder_path") String folderPath,
            @ApiParam(name = "path",
                    value = "Filter preparations by full path. Should always return one preparation") @RequestParam(
                            required = false, name = "path") String path,
            @ApiParam(value = "Sort key, defaults to 'modification'.") @RequestParam(
                    defaultValue = "lastModificationDate") Sort sort,
            @ApiParam(value = "Order for sort key (desc or asc), defaults to 'desc'.") @RequestParam(
                    defaultValue = "desc") Order order); @RequestMapping(value = "/api/preparations", method = POST, produces = TEXT_PLAIN_VALUE) @ApiOperation(value = "Create a new preparation for preparation content in body.", notes = "Returns the created preparation id.") @Timed String createPreparation(
            @ApiParam(name = "folder", value = "Where to store the preparation.") @RequestParam(value = "folder") String folder,
            @ApiParam(name = "body", value = "The original preparation. You may set all values, service will override values you can't write to.") @RequestBody Preparation preparation); @RequestMapping(value = "/api/preparations/{id}", method = PUT, consumes = APPLICATION_JSON_VALUE, produces = TEXT_PLAIN_VALUE) @ApiOperation(value = "Update a preparation with content in body.", notes = "Returns the updated preparation id.") @Timed String updatePreparation(
            @ApiParam(name = "id", value = "The id of the preparation to update.") @PathVariable("id") String id,
            @ApiParam(name = "body",
                    value = "The updated preparation. Null values are ignored during update. You may set all values, service will override values you can't write to.") @RequestBody PreparationDTO preparation); @RequestMapping(value = "/api/preparations/{id}", method = DELETE, produces = TEXT_PLAIN_VALUE) @ApiOperation(value = "Delete a preparation by id", notes = "Delete a preparation content based on provided id. Id should be a UUID returned by the list operation. Not valid or non existing preparation id returns empty content.") @Timed String deletePreparation(
            @ApiParam(name = "id", value = "The id of the preparation to delete.") @PathVariable("id") String id); @RequestMapping(value = "/api/preparations/{id}/copy", method = POST, produces = TEXT_PLAIN_VALUE) @ApiOperation(value = "Copy a preparation", produces = TEXT_PLAIN_VALUE, notes = "Copy a preparation based the provided id.") String copy(
            @ApiParam(value = "Id of the preparation to copy") @PathVariable(value = "id") String id,
            @ApiParam(value = "Optional new name of the copied preparation, if not set the copy will get the original name.") @RequestParam(required = false) String newName,
            @ApiParam(value = "The destination path to create the entry.") @RequestParam(required = false) String destination); @RequestMapping(value = "/api/preparations/{id}/move", method = PUT) @ApiOperation(value = "Move a Preparation", notes = "Move a preparation to another folder.") @Timed void move(@PathVariable(value = "id") @ApiParam(name = "id", value = "Id of the preparation to move") String id,
                     @ApiParam(value = "The original folder path of the preparation.") @RequestParam(defaultValue = "", required = false) String folder,
                     @ApiParam(value = "The new folder path of the preparation.") @RequestParam() String destination,
                     @ApiParam(value = "The new name of the moved dataset.") @RequestParam(defaultValue = "", required = false) String newName); @RequestMapping(value = "/api/preparations/{id}/details", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get a preparation by id and details.", notes = "Returns the preparation details.") @Timed PreparationDetailsDTO getPreparation(
            @PathVariable(value = "id") @ApiParam(name = "id", value = "Preparation id.") String preparationId, //
            @RequestParam(value = "stepId", defaultValue = "head") @ApiParam(name = "stepId",
                    value = "optional step id", defaultValue = "head") String stepId); @RequestMapping(value = "/api/preparations/{id}/summary", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get a preparation by id and details.", notes = "Returns the preparation details.") @Timed PreparationDTO getPreparationSummary(
            @PathVariable(value = "id") @ApiParam(name = "id", value = "Preparation id.") String preparationId, //
            @RequestParam(value = "stepId", defaultValue = "head") @ApiParam(name = "stepId",
                    value = "optional step id", defaultValue = "head") String stepId); @RequestMapping(value = "/api/preparations/{id}/content", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get preparation content by id and at a given version.", notes = "Returns the preparation content at version.") @Timed ResponseEntity<StreamingResponseBody> getPreparation( //
            @PathVariable(value = "id") @ApiParam(name = "id", value = "Preparation id.") String preparationId, //
            @RequestParam(value = "version", defaultValue = "head") @ApiParam(name = "version",
                    value = "Version of the preparation (can be 'origin', 'head' or the version id). Defaults to 'head'.") String version,
            @RequestParam(value = "from", defaultValue = "HEAD") @ApiParam(name = "from",
                    value = "Where to get the data from") ExportParameters.SourceType from,
            @RequestParam(value = "filter", required = false) @ApiParam(name = "filter",
                    value = "A filter apply on the content") String filter); @RequestMapping(value = "/api/preparations/{id}/metadata", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get preparation metadata by id and at a given version.", notes = "Returns the preparation metadata at version.") @Timed ResponseEntity<DataSetMetadata> getPreparationMetadata( //
            @PathVariable(value = "id") @ApiParam(name = "id", value = "Preparation id.") String preparationId, //
            @RequestParam(value = "version", defaultValue = "head") @ApiParam(name = "version",
                    value = "Version of the preparation (can be 'origin', 'head' or the version id). Defaults to 'head'.") String version); @RequestMapping(value = "/api/preparations/{id}/actions", method = POST, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Adds an action at the end of preparation.", notes = "Does not return any value, client may expect successful operation based on HTTP status code.") @Timed void addPreparationAction(
            @ApiParam(name = "id", value = "Preparation id.") @PathVariable(value = "id") final String preparationId,
            @ApiParam("Action to add at end of the preparation.") @RequestBody final AppendStep actionsContainer); @RequestMapping(value = "/api/preparations/{preparationId}/actions/{stepId}", method = PUT, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Updates an action in the preparation.", notes = "Does not return any value, client may expect successful operation based on HTTP status code.") @Timed void updatePreparationAction(@ApiParam(name = "preparationId", value = "Preparation id.") @PathVariable(value = "preparationId") final String preparationId,
                                        @ApiParam(name = "stepId", value = "Step id in the preparation.") @PathVariable(value = "stepId") final String stepId,
                                        @ApiParam("New content for the action.") @RequestBody final AppendStep step); @RequestMapping(value = "/api/preparations/{id}/actions/{stepId}", method = DELETE, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Delete an action in the preparation.", notes = "Does not return any value, client may expect successful operation based on HTTP status code.") @Timed void deletePreparationAction(
            @PathVariable(value = "id") @ApiParam(name = "id", value = "Preparation id.") final String preparationId,
            @PathVariable(value = "stepId") @ApiParam(name = "stepId",
                    value = "Step id to delete.") final String stepId); @RequestMapping(value = "/api/preparations/{id}/head/{headId}", method = PUT) @ApiOperation(value = "Changes the head of the preparation.", notes = "Does not return any value, client may expect successful operation based on HTTP status code.") @Timed void setPreparationHead(@PathVariable(value = "id") @ApiParam(name = "id", value = "Preparation id.") final String preparationId,
                                   @PathVariable(value = "headId") @ApiParam(name = "headId", value = "New head step id") final String headId); @RequestMapping(value = "/api/preparations/{preparationId}/lock", method = PUT, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Mark a preparation as locked by a user.", notes = "Does not return any value, client may expect successful operation based on HTTP status code.") @Timed void lockPreparation(@PathVariable(value = "preparationId") @ApiParam(name = "preparationId",
            value = "Preparation id.") final String preparationId); @RequestMapping(value = "/api/preparations/{preparationId}/unlock", method = PUT, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Mark a preparation as unlocked by a user.", notes = "Does not return any value, client may expect successful operation based on HTTP status code.") @Timed void unlockPreparation(@PathVariable(value = "preparationId") @ApiParam(name = "preparationId",
            value = "Preparation id.") final String preparationId); @RequestMapping(value = "/api/preparations/{id}/steps/copy", method = PUT) @ApiOperation(value = "Copy the steps from another preparation", notes = "Copy the steps from another preparation if this one has no steps.") @Timed void copyStepsFrom(@ApiParam(value="the preparation id to update") @PathVariable("id")String id,
                              @ApiParam(value = "the preparation to copy the steps from.") @RequestParam String from); @RequestMapping(value = "/api/preparations/{preparationId}/steps/{stepId}/order", method = POST, consumes = APPLICATION_JSON_VALUE) @ApiOperation(value = "Moves a step within a preparation just after the specified <i>parentStepId</i>", notes = "Moves a step within a preparation.") @Timed void moveStep(@PathVariable("preparationId") final String preparationId,
            @ApiParam(value = "The current index of the action we want to move.") @PathVariable("stepId") String stepId,
            @ApiParam(value = "The current index of the action we want to move.") @RequestParam String parentStepId); @RequestMapping(value = "/api/preparations/preview/diff", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get a preview diff between 2 steps of the same preparation.") @Timed StreamingResponseBody previewDiff(@RequestBody final PreviewDiffParameters input); @RequestMapping(value = "/api/preparations/preview/update", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get a preview diff between the same step of the same preparation but with one step update.") StreamingResponseBody previewUpdate(@RequestBody final PreviewUpdateParameters input); @RequestMapping(value = "/api/preparations/preview/add", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get a preview between the head step and a new appended transformation") StreamingResponseBody previewAdd(@RequestBody @Valid final PreviewAddParameters input); @RequestMapping(value = "/api/preparations/{preparationId}/columns/{columnId}/types", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "list the types of the wanted column", notes = "This list can be used by user to change the column type.") @Timed @PublicAPI ResponseEntity<StreamingResponseBody> 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 testMoveStep() throws Exception { final String datasetId = testClient.createDataset("preview/preview_dataset.csv", "testPreview"); String testPrepId = testClient.createPreparationFromDataset(datasetId, "testPrep", home.getId()); AppendStep appendStep = new AppendStep(); final Action actionToBeMoved = buildAction("uppercase", buildParametersMap("column_id", "0001", "column_name", "firstname", "scope", "column")); appendStep.setActions(Arrays.asList( buildAction("uppercase", buildParametersMap("column_id", "0002", "column_name", "lastname", "scope", "column")), actionToBeMoved)); appendStepsToPrep(testPrepId, appendStep); PreparationDTO testPrepDetails = getPreparationDetails(testPrepId); List<String> stepsCreated = testPrepDetails.getSteps(); String rootStep = stepsCreated.get(0); String secondStep = stepsCreated.get(2); changePreparationStepsOrder(testPrepId, rootStep, secondStep); PreparationDTO testPrepDetailsAfter = getPreparationDetails(testPrepId); final Action initialUpperCaseAction = getActions(testPrepDetails.getSteps().get(2)).get(1); assertEquals(actionToBeMoved, initialUpperCaseAction); final Action movedAction = getActions(testPrepDetailsAfter.getSteps().get(1)).get(0); assertEquals(initialUpperCaseAction, movedAction); }