use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class PreparationConversions method toPreparationDetailsDTO.
private PreparationDetailsDTO toPreparationDetailsDTO(PreparationDTO source, PreparationDetailsDTO target, ApplicationContext applicationContext) {
final PreparationRepository preparationRepository = applicationContext.getBean(PreparationRepository.class);
List<String> idsStep = source.getSteps();
final List<StepDiff> diffs = preparationRepository.list(PersistentStep.class, in("id", idsStep.toArray(new String[] {}))).filter(//
step -> !Step.ROOT_STEP.id().equals(step.getId())).sorted((step1, step2) -> {
// we need to keep the order from the original list (source.getSteps())
int idPosStep1 = idsStep.indexOf(step1.getId());
int idPosStep2 = idsStep.indexOf(step2.getId());
return idPosStep1 - idPosStep2;
}).map(//
PersistentStep::getDiff).collect(toList());
target.setDiff(diffs);
// TDP-5888: It is important for Spark runs to have a row metadata to describe initial data schema.
// and also to display column names in filter labels of steps
final PersistentPreparation preparation = preparationRepository.get(source.getId(), PersistentPreparation.class);
target.setRowMetadata(preparation.getRowMetadata());
injectColumnNamesIntoActions(source.getHeadId(), target, applicationContext.getBean(PreparationService.class));
return target;
}
use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class SortAndOrderHelperTest method getPreparationComparison.
private //
int getPreparationComparison(//
String firstName, //
String secondName, //
String firstAuthor, //
String secondAuthor, //
long firstCreation, //
long secondCreation, //
long firstModification, //
long secondModification, //
long firstSize, //
long secondSize, //
String firstDsName, //
String secondDsName, Sort sort, Order order) {
PreparationDTO firstUserPrep = createUserPreparation(firstName, firstAuthor, firstCreation, firstModification, firstSize, firstDsName);
PreparationDTO secondUserPrep = createUserPreparation(secondName, secondAuthor, secondCreation, secondModification, secondSize, secondDsName);
PreparationDTO firstPrep = createUserPreparation(firstName, firstAuthor, firstCreation, firstModification, firstSize, firstDsName);
PreparationDTO secondPrep = createUserPreparation(secondName, secondAuthor, secondCreation, secondModification, secondSize, secondDsName);
// when
Comparator<PreparationDTO> preparationComparator = SortAndOrderHelper.getPreparationComparator(sort, order);
// then
assertNotNull(preparationComparator);
final int userPreparationOrder = preparationComparator.compare(firstUserPrep, secondUserPrep);
final int preparationOrder = preparationComparator.compare(firstPrep, secondPrep);
assertEquals(userPreparationOrder, preparationOrder);
return userPreparationOrder;
}
use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class SortAndOrderHelperTest method createUserPreparation.
private PreparationDTO createUserPreparation(String name, String author, long creation, long modification, long size, String dataSetName) {
PreparationDTO firstPrep = new PreparationDTO();
firstPrep.setDataSetName(dataSetName);
firstPrep.setName(name);
firstPrep.setAuthor("1234");
firstPrep.setOwner(new Owner("1234", author, ""));
firstPrep.setCreationDate(creation);
firstPrep.setLastModificationDate(modification);
List<String> steps = new ArrayList<>();
for (int i = 0; i < size; i++) {
steps.add(null);
}
firstPrep.setSteps(steps);
return firstPrep;
}
use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class PersistentPreparationTest method should_merge_from_source.
@Test
public void should_merge_from_source() {
PreparationDTO theOtherOne = new PreparationDTO();
theOtherOne.setId("#23874");
PersistentPreparation source = new PersistentPreparation();
source.setId("#158387");
source.setAuthor("Bloc Party");
source.setCreationDate(theOtherOne.getCreationDate() - 1000);
source.setDataSetId("ds#65478");
source.setDataSetName("My Dataset Name");
source.setLastModificationDate(source.getCreationDate() + 2658483);
source.setName("banquet");
source.setHeadId(Step.ROOT_STEP.id());
PersistentPreparation actual = source.merge(theOtherOne);
assertEquals("#23874", actual.getId());
assertEquals("Bloc Party", actual.getAuthor());
assertEquals("ds#65478", actual.getDataSetId());
assertEquals("My Dataset Name", actual.getDataSetName());
}
use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class PersistentPreparationTest method should_merge_from_other.
@Test
public void should_merge_from_other() {
PersistentPreparation source = new PersistentPreparation();
source.setId("#4837");
PreparationDTO theOtherOne = new PreparationDTO();
theOtherOne.setAuthor("Joss Stone");
theOtherOne.setCreationDate(source.getCreationDate() - 1000);
theOtherOne.setDataSetId("ds#123456");
theOtherOne.setDataSetName("My Dataset Name");
theOtherOne.setLastModificationDate(theOtherOne.getCreationDate() + 12345682);
theOtherOne.setName("my preparation name");
theOtherOne.setHeadId(Step.ROOT_STEP.id());
PersistentPreparation actual = source.merge(theOtherOne);
assertEquals("Joss Stone", actual.getAuthor());
assertEquals(source.getCreationDate() - 1000, actual.getCreationDate());
assertEquals("ds#123456", actual.getDataSetId());
assertEquals("My Dataset Name", actual.getDataSetName());
assertEquals(theOtherOne.getCreationDate() + 12345682, actual.getLastModificationDate());
assertEquals("my preparation name", actual.getName());
assertEquals(Step.ROOT_STEP.id(), actual.getHeadId());
}
Aggregations