Search in sources :

Example 1 with DiffMetadata

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());
    }
}
Also used : PreparationDTO(org.talend.dataprep.api.preparation.PreparationDTO) PreparationGetActions(org.talend.dataprep.command.preparation.PreparationGetActions) DiffMetadata(org.talend.dataprep.api.service.command.preparation.DiffMetadata) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 PreparationDTO (org.talend.dataprep.api.preparation.PreparationDTO)1 DiffMetadata (org.talend.dataprep.api.service.command.preparation.DiffMetadata)1 PreparationGetActions (org.talend.dataprep.command.preparation.PreparationGetActions)1 Timed (org.talend.dataprep.metrics.Timed)1