use of org.talend.dataprep.api.service.command.preparation.DiffMetadata in project data-prep by Talend.
the class PreparationAPI method updatePreparationAction.
// @formatter:off
@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
public 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) {
if (LOG.isDebugEnabled()) {
LOG.debug("Updating preparation action at step #{} (pool: {} )...", stepId, getConnectionStats());
}
// get the preparation
PreparationDTO preparation = internalGetPreparation(preparationId);
// get the preparation actions for up to the updated action
final int stepIndex = new ArrayList<>(preparation.getSteps()).indexOf(stepId);
final String parentStepId = preparation.getSteps().get(stepIndex - 1);
final PreparationGetActions getActionsCommand = getCommand(PreparationGetActions.class, preparationId, parentStepId);
// get the diff
final DiffMetadata diffCommand = getCommand(DiffMetadata.class, preparation.getDataSetId(), preparationId, step.getActions(), getActionsCommand);
// get the update action command and execute it
final HystrixCommand<Void> command = getCommand(PreparationUpdateAction.class, preparationId, stepId, step, diffCommand);
command.execute();
if (LOG.isDebugEnabled()) {
LOG.debug("Updated preparation action at step #{} (pool: {} )...", stepId, getConnectionStats());
}
}
Aggregations