Search in sources :

Example 1 with PreparationCreate

use of org.talend.dataprep.api.service.command.preparation.PreparationCreate in project data-prep by Talend.

the class PreparationAPI method createPreparation.

// @formatter:off
@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
public 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) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Creating a preparation in {} (pool: {} )...", folder, getConnectionStats());
    }
    final DataSetMetadata dataSetMetadata = datasetClient.getDataSetMetadata(preparation.getDataSetId());
    if (StringUtils.isEmpty(preparation.getName())) {
        preparation.setName((dataSetMetadata.getName() != null ? dataSetMetadata.getName() + " " : "") + message("preparation.create.suffix"));
    }
    preparation.setRowMetadata(dataSetMetadata.getRowMetadata());
    preparation.setDataSetName(dataSetMetadata.getName());
    PreparationCreate preparationCreate = getCommand(PreparationCreate.class, preparation, folder);
    final String preparationId = preparationCreate.execute();
    LOG.info("New Preparation #{}, name: {}, created in folder {}", preparationId, preparation.getName(), folder);
    return preparationId;
}
Also used : PreparationCreate(org.talend.dataprep.api.service.command.preparation.PreparationCreate) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) 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 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)1 PreparationCreate (org.talend.dataprep.api.service.command.preparation.PreparationCreate)1 Timed (org.talend.dataprep.metrics.Timed)1