Search in sources :

Example 1 with DatasetDetailsDTO

use of org.talend.dataprep.api.dataset.DatasetDetailsDTO in project data-prep by Talend.

the class DataSetAPI method getPreparation.

/**
 * Return the list of preparation using a dataset
 *
 * @param id the wanted dataset.
 * @return the list of preparation using the dataset
 */
@RequestMapping(value = "/api/datasets/{id}/preparations", method = GET, produces = APPLICATION_JSON_VALUE)
@ApiOperation(value = "Get the list of preparation using a dataset by the dataset id.", produces = APPLICATION_JSON_VALUE, notes = "Get the list of preparation using a dataset by the dataset id.")
@Timed
public List<DatasetDetailsDTO.Preparation> getPreparation(@ApiParam(value = "Id of the data set to get") @PathVariable(value = "id") String id) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Requesting preparations using dataset #{} (pool: {})...", id, getConnectionStats());
    }
    try {
        DatasetDetailsDTO details = datasetClient.getDataSetDetails(id);
        // Add the related preparations list to the given dataset metadata.
        final PreparationSearchByDataSetId getPreparations = getCommand(PreparationSearchByDataSetId.class, details.getId());
        List<DatasetDetailsDTO.Preparation> preps = new ArrayList<>();
        // 
        toStream(PreparationDTO.class, mapper, getPreparations).filter(p -> p.getSteps() != null).forEach(p -> preps.add(new DatasetDetailsDTO.Preparation(p.getId(), p.getName(), (long) p.getSteps().size(), p.getLastModificationDate())));
        return preps;
    } finally {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Request preparations using dataset #{} (pool: {}) done.", id, getConnectionStats());
        }
    }
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) UpdateDataSet(org.talend.dataprep.api.service.command.dataset.UpdateDataSet) StringUtils.containsIgnoreCase(org.apache.commons.lang3.StringUtils.containsIgnoreCase) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) SetFavorite(org.talend.dataprep.api.service.command.dataset.SetFavorite) DatasetDetailsDTO(org.talend.dataprep.api.dataset.DatasetDetailsDTO) CommandHelper.toStream(org.talend.dataprep.command.CommandHelper.toStream) DatasetDTO(org.talend.dataprep.api.dataset.DatasetDTO) TEXT_PLAIN_VALUE(org.springframework.http.MediaType.TEXT_PLAIN_VALUE) CommandHelper.toStreaming(org.talend.dataprep.command.CommandHelper.toStreaming) SemanticDomain(org.talend.dataprep.api.dataset.statistics.SemanticDomain) ApiOperation(io.swagger.annotations.ApiOperation) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) DataSet(org.talend.dataprep.api.dataset.DataSet) CertificationState(org.talend.dataprep.dataset.adapter.Dataset.CertificationState) Order(org.talend.dataprep.util.SortAndOrderHelper.Order) MediaType(org.springframework.http.MediaType) UpdateColumn(org.talend.dataprep.api.service.command.dataset.UpdateColumn) PublicAPI(org.talend.dataprep.security.PublicAPI) StreamingResponseBody(org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) DataSetPreview(org.talend.dataprep.api.service.command.dataset.DataSetPreview) List(java.util.List) HystrixCommand(com.netflix.hystrix.HystrixCommand) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) Stream(java.util.stream.Stream) GetDataSetColumnTypes(org.talend.dataprep.api.service.command.dataset.GetDataSetColumnTypes) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) PreparationList(org.talend.dataprep.api.service.command.preparation.PreparationList) CopyDataSet(org.talend.dataprep.api.service.command.dataset.CopyDataSet) GenericCommand(org.talend.dataprep.command.GenericCommand) SuggestLookupActions(org.talend.dataprep.api.service.command.transformation.SuggestLookupActions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Callable(java.util.concurrent.Callable) CreateOrUpdateDataSet(org.talend.dataprep.api.service.command.dataset.CreateOrUpdateDataSet) SortAndOrderHelper(org.talend.dataprep.util.SortAndOrderHelper) GET(org.springframework.web.bind.annotation.RequestMethod.GET) PreparationSearchByDataSetId(org.talend.dataprep.api.service.command.preparation.PreparationSearchByDataSetId) DatasetClient(org.talend.dataprep.dataset.adapter.DatasetClient) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) CONTENT_TYPE(org.springframework.http.HttpHeaders.CONTENT_TYPE) Charset(java.nio.charset.Charset) CompatibleDataSetList(org.talend.dataprep.api.service.command.dataset.CompatibleDataSetList) POST(org.springframework.web.bind.annotation.RequestMethod.POST) DataSetGetImportParameters(org.talend.dataprep.api.service.command.dataset.DataSetGetImportParameters) DELETE(org.springframework.web.bind.annotation.RequestMethod.DELETE) CreateDataSet(org.talend.dataprep.api.service.command.dataset.CreateDataSet) Sort(org.talend.dataprep.util.SortAndOrderHelper.Sort) APPLICATION_JSON_VALUE(org.springframework.http.MediaType.APPLICATION_JSON_VALUE) StringsHelper(org.talend.dataprep.util.StringsHelper) ActionForm(org.talend.dataprep.api.action.ActionForm) PreparationDTO(org.talend.dataprep.api.preparation.PreparationDTO) DataSetDelete(org.talend.dataprep.api.service.command.dataset.DataSetDelete) CERTIFIED(org.talend.dataprep.dataset.adapter.Dataset.CertificationState.CERTIFIED) ResponseEntity(org.springframework.http.ResponseEntity) CommandHelper(org.talend.dataprep.command.CommandHelper) EncodingSupport(org.talend.dataprep.configuration.EncodingSupport) Timed(org.talend.dataprep.metrics.Timed) InputStream(java.io.InputStream) DatasetDetailsDTO(org.talend.dataprep.api.dataset.DatasetDetailsDTO) ArrayList(java.util.ArrayList) PreparationSearchByDataSetId(org.talend.dataprep.api.service.command.preparation.PreparationSearchByDataSetId) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with DatasetDetailsDTO

use of org.talend.dataprep.api.dataset.DatasetDetailsDTO in project data-prep by Talend.

the class DataSetAPI method getDetails.

/**
 * Return the dataset details.
 *
 * @param id the wanted dataset details.
 * @return the dataset datails or no content if not found.
 */
@RequestMapping(value = "/api/datasets/{id}/details", method = GET, produces = APPLICATION_JSON_VALUE)
@ApiOperation(value = "Get a data set detail by id.", produces = APPLICATION_JSON_VALUE, notes = "Get a data set metadata based on given id.")
@Timed
public DatasetDetailsDTO getDetails(@ApiParam(value = "Id of the data set to get") @PathVariable(value = "id") String id) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Requesting dataset details #{} (pool: {})...", id, getConnectionStats());
    }
    try {
        DatasetDetailsDTO details = datasetClient.getDataSetDetails(id);
        List<DatasetDetailsDTO.Preparation> preps = getPreparation(details.getId());
        details.setPreparations(preps);
        return details;
    } finally {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Request dataset details #{} (pool: {}) done.", id, getConnectionStats());
        }
    }
}
Also used : DatasetDetailsDTO(org.talend.dataprep.api.dataset.DatasetDetailsDTO) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DatasetDetailsDTO (org.talend.dataprep.api.dataset.DatasetDetailsDTO)2 HystrixCommand (com.netflix.hystrix.HystrixCommand)1 ApiParam (io.swagger.annotations.ApiParam)1 InputStream (java.io.InputStream)1 Charset (java.nio.charset.Charset)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 StringUtils.containsIgnoreCase (org.apache.commons.lang3.StringUtils.containsIgnoreCase)1 StringUtils.isNotBlank (org.apache.commons.lang3.StringUtils.isNotBlank)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Value (org.springframework.beans.factory.annotation.Value)1 CONTENT_TYPE (org.springframework.http.HttpHeaders.CONTENT_TYPE)1 MediaType (org.springframework.http.MediaType)1 APPLICATION_JSON_VALUE (org.springframework.http.MediaType.APPLICATION_JSON_VALUE)1 TEXT_PLAIN_VALUE (org.springframework.http.MediaType.TEXT_PLAIN_VALUE)1