Search in sources :

Example 1 with PreparationSummaryGet

use of org.talend.dataprep.command.preparation.PreparationSummaryGet in project data-prep by Talend.

the class StandardExportStrategiesIntegrationTest method initPreparationDetails.

private void initPreparationDetails() throws Exception {
    doReturn(preparationDetailsGet).when(applicationContext).getBean(eq(PreparationDetailsGet.class), anyString(), anyString());
    final PreparationDetailsDTO preparationDetailsDTO = mapper.readerFor(// 
    PreparationDetailsDTO.class).readValue(this.getClass().getResourceAsStream("preparation_details.json"));
    // 
    when(preparationDetailsGet.execute()).thenReturn(// 
    preparationDetailsDTO).thenReturn(preparationDetailsDTO);
    doReturn(preparationSummaryGet).when(applicationContext).getBean(eq(PreparationSummaryGet.class), anyString(), anyString());
    final PreparationDTO preparationDTO = mapper.readerFor(// 
    PreparationDTO.class).readValue(this.getClass().getResourceAsStream("preparation_details_summary.json"));
    when(preparationSummaryGet.execute()).thenReturn(preparationDTO, preparationDTO);
}
Also used : PreparationDTO(org.talend.dataprep.api.preparation.PreparationDTO) PreparationDetailsDTO(org.talend.dataprep.api.preparation.PreparationDetailsDTO) PreparationDetailsGet(org.talend.dataprep.command.preparation.PreparationDetailsGet) PreparationSummaryGet(org.talend.dataprep.command.preparation.PreparationSummaryGet)

Example 2 with PreparationSummaryGet

use of org.talend.dataprep.command.preparation.PreparationSummaryGet in project data-prep by Talend.

the class ExportAPI method getExportNameAndConsolidateParameters.

private String getExportNameAndConsolidateParameters(ExportParameters parameters) {
    // export file name comes from :
    // 1. the form parameter
    // 2. the preparation name
    // 3. the dataset name
    String exportName = EMPTY;
    if (parameters.getArguments().containsKey(PREFIX + "fileName")) {
        return parameters.getArguments().get(PREFIX + "fileName");
    }
    // deal with preparation (update the export name and dataset id if needed)
    if (StringUtils.isNotBlank(parameters.getPreparationId())) {
        final PreparationSummaryGet preparationSummaryGet = getCommand(PreparationSummaryGet.class, parameters.getPreparationId());
        final PreparationDTO preparation = preparationSummaryGet.execute();
        if (StringUtils.isBlank(exportName)) {
            exportName = preparation.getName();
        }
        // update the dataset id in the parameters if needed
        if (StringUtils.isBlank(parameters.getDatasetId())) {
            parameters.setDatasetId(preparation.getDataSetId());
        }
    } else if (StringUtils.isBlank(exportName)) {
        // deal export name in case of dataset
        final DataSetMetadata metadata = datasetClient.getDataSetMetadata(parameters.getDatasetId());
        exportName = metadata.getName();
    }
    return exportName;
}
Also used : PreparationDTO(org.talend.dataprep.api.preparation.PreparationDTO) PreparationSummaryGet(org.talend.dataprep.command.preparation.PreparationSummaryGet) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata)

Aggregations

PreparationDTO (org.talend.dataprep.api.preparation.PreparationDTO)2 PreparationSummaryGet (org.talend.dataprep.command.preparation.PreparationSummaryGet)2 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)1 PreparationDetailsDTO (org.talend.dataprep.api.preparation.PreparationDetailsDTO)1 PreparationDetailsGet (org.talend.dataprep.command.preparation.PreparationDetailsGet)1