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;
}
Aggregations