use of org.talend.dataprep.api.preparation.PreparationMessage in project data-prep by Talend.
the class APIPreparationConversionsTest method shouldNotEnrichPreparationWithDataset.
@Test
public void shouldNotEnrichPreparationWithDataset() {
// given
final PreparationMessage preparation = getPreparationMessage(null);
// when
final EnrichedPreparation actual = conversionService.convert(preparation, EnrichedPreparation.class);
// then
assertNotNull(actual);
assertNull(actual.getSummary());
assertNull(actual.getFolder());
}
use of org.talend.dataprep.api.preparation.PreparationMessage in project data-prep by Talend.
the class APIPreparationConversionsTest method getPreparationMessage.
private PreparationMessage getPreparationMessage(String dataSetId) {
final PreparationMessage preparation = new PreparationMessage();
preparation.setDataSetId(dataSetId);
List<Step> steps = new ArrayList<>(12);
Step parentStep = preparation.getSteps().get(0);
for (int i = 0; i < 12; i++) {
final Step step = new Step(parentStep.id(), new PreparationActions().id(), "2.1");
steps.add(step);
parentStep = step;
}
preparation.setSteps(steps);
return preparation;
}
use of org.talend.dataprep.api.preparation.PreparationMessage in project data-prep by Talend.
the class APIPreparationConversionsTest method shouldDealWithRepeatedStepIds.
@Test
public void shouldDealWithRepeatedStepIds() {
// given
DataSetMetadata metadata = getDataSetMetadata("super dataset", 1001L);
setupHystrixCommand(DataSetGetMetadata.class, metadata);
final PreparationMessage preparation = getPreparationMessage(metadata.getId());
preparation.setSteps(asList(Step.ROOT_STEP, Step.ROOT_STEP));
Folder folder = getFolder("F-753854");
setupHystrixCommand(LocatePreparation.class, folder);
// when
final EnrichedPreparation actual = conversionService.convert(preparation, EnrichedPreparation.class);
// then
assertEquals(1, actual.getSteps().size());
assertEquals(Step.ROOT_STEP.id(), actual.getSteps().get(0));
}
use of org.talend.dataprep.api.preparation.PreparationMessage in project data-prep by Talend.
the class PipelineTransformer method buildExecutable.
@Override
public ExecutableTransformer buildExecutable(DataSet input, Configuration configuration) {
final RowMetadata rowMetadata = input.getMetadata().getRowMetadata();
// prepare the fallback row metadata
RowMetadata fallBackRowMetadata = transformationRowMetadataUtils.getMatchingEmptyRowMetadata(rowMetadata);
final TransformerWriter writer = writerRegistrationService.getWriter(configuration.formatId(), configuration.output(), configuration.getArguments());
final ConfiguredCacheWriter metadataWriter = new ConfiguredCacheWriter(contentCache, DEFAULT);
final TransformationMetadataCacheKey metadataKey = cacheKeyGenerator.generateMetadataKey(configuration.getPreparationId(), configuration.stepId(), configuration.getSourceType());
final PreparationMessage preparation = configuration.getPreparation();
// function that from a step gives the rowMetadata associated to the previous/parent step
final Function<Step, RowMetadata> previousStepRowMetadataSupplier = s -> //
Optional.ofNullable(s.getParent()).map(//
id -> preparationUpdater.get(id)).orElse(null);
final Pipeline pipeline = //
Pipeline.Builder.builder().withAnalyzerService(//
analyzerService).withActionRegistry(//
actionRegistry).withPreparation(//
preparation).withActions(//
actionParser.parse(configuration.getActions())).withInitialMetadata(rowMetadata, //
configuration.volume() == SMALL).withMonitor(//
configuration.getMonitor()).withFilter(//
configuration.getFilter()).withLimit(//
configuration.getLimit()).withFilterOut(//
configuration.getOutFilter()).withOutput(//
() -> new WriterNode(writer, metadataWriter, metadataKey, fallBackRowMetadata)).withStatisticsAdapter(//
adapter).withStepMetadataSupplier(//
previousStepRowMetadataSupplier).withGlobalStatistics(//
configuration.isGlobalStatistics()).allowMetadataChange(//
configuration.isAllowMetadataChange()).build();
// wrap this transformer into an executable transformer
return new ExecutableTransformer() {
@Override
public void execute() {
try {
LOGGER.debug("Before transformation: {}", pipeline);
pipeline.execute(input);
} finally {
LOGGER.debug("After transformation: {}", pipeline);
}
if (preparation != null) {
final UpdatedStepVisitor visitor = new UpdatedStepVisitor(preparationUpdater);
pipeline.accept(visitor);
}
}
@Override
public void signal(Signal signal) {
pipeline.signal(signal);
}
};
}
Aggregations