use of org.talend.dataprep.preparation.store.PersistentPreparation in project data-prep by Talend.
the class PreparationEventUtilTest method shouldUpdateDataSetName.
@Test
public void shouldUpdateDataSetName() {
// given
final DataSetMetadata metadata = new DataSetMetadata();
metadata.setId("ds-1234");
metadata.setName("My updated name");
final PersistentPreparation preparation = mock(PersistentPreparation.class);
when(preparationRepository.list(eq(PersistentPreparation.class), eq(TqlBuilder.eq("dataSetId", "ds-1234")))).thenReturn(Stream.of(preparation), Stream.of(preparation));
when(datasetClient.getDataSetMetadata(eq("ds-1234"))).thenReturn(metadata);
// when
preparationEventUtil.performUpdateEvent(metadata.getId());
// then
verify(preparation, times(1)).setDataSetName(eq("My updated name"));
}
use of org.talend.dataprep.preparation.store.PersistentPreparation in project data-prep by Talend.
the class SetStepRowMetadataTest method makePersistentPreparation.
private PersistentPreparation makePersistentPreparation(String id) {
PersistentPreparation preparation = new PersistentPreparation();
preparation.setId(id);
return preparation;
}
use of org.talend.dataprep.preparation.store.PersistentPreparation in project data-prep by Talend.
the class PreparationService method addPreparationAction.
public void addPreparationAction(final String preparationId, final AppendStep appendStep) {
PersistentPreparation preparation = preparationRepository.get(preparationId, PersistentPreparation.class);
List<Action> actions = getVersionedAction(preparation, HEAD);
StepDiff actionCreatedColumns = stepDiffDelegate.computeCreatedColumns(preparation.getRowMetadata(), buildActions(actions), buildActions(appendStep.getActions()));
appendStep.setDiff(actionCreatedColumns);
checkActionStepConsistency(appendStep);
appendStepToHead(preparation, appendStep);
LOGGER.debug("Added action to preparation.");
if (auditService.isActive()) {
auditService.auditPreparationAddStep(preparationId, appendStep.getActions().stream().collect(toMap(Action::getName, Action::getParameters)));
}
}
use of org.talend.dataprep.preparation.store.PersistentPreparation in project data-prep by Talend.
the class PreparationService method getPreparationDetails.
/**
* Return a preparation details.
*
* @param id the wanted preparation id.
* @param stepId the optional step id.
* @return the preparation details.
*/
public PreparationDTO getPreparationDetails(String id, String stepId) {
LOGGER.debug("Get content of preparation details for #{}.", id);
final PersistentPreparation preparation = preparationRepository.get(id, PersistentPreparation.class);
if (preparation == null) {
throw new TDPException(PreparationErrorCodes.PREPARATION_DOES_NOT_EXIST, build().put(ID, id));
}
ensurePreparationConsistency(preparation);
// specify the step id if provided
if (!StringUtils.equals(HEAD, stepId)) {
// just make sure the step does exist
if (Step.ROOT_STEP.id().equals(stepId)) {
preparation.setSteps(Collections.singletonList(Step.ROOT_STEP.id()));
preparation.setHeadId(Step.ROOT_STEP.id());
} else if (preparationRepository.exist(PersistentStep.class, eq(ID, stepId))) {
preparation.setSteps(preparationUtils.listStepsIds(stepId, preparationRepository));
preparation.setHeadId(stepId);
} else {
throw new TDPException(PREPARATION_STEP_DOES_NOT_EXIST, build().put(ID, preparation).put(STEP_ID, stepId));
}
}
final PreparationDTO details = beanConversionService.convert(preparation, PreparationDTO.class);
LOGGER.debug("returning details for {} -> {}", id, details);
return details;
}
use of org.talend.dataprep.preparation.store.PersistentPreparation in project data-prep by Talend.
the class PreparationService method deleteAction.
/**
* Delete a step in a preparation.<br/>
* STD : Step To Delete <br/>
* <br/>
* <ul>
* <li>1. Extract the actions from STD (excluded) to the head. The actions list contains all the actions from the
* STD's child to the head.</li>
* <li>2. Filter the actions that apply on a column created by the step to delete. Those steps will be removed
* too.</li>
* <li>2bis. Change the actions that apply on columns whose id is higher than the STD last created column id. The
* created columns ids after
* the STD are shifted.</li>
* <li>3. Set preparation head to STD's parent, so STD will be excluded</li>
* <li>4. Append each action after the new preparation head</li>
* </ul>
*
* @param id the preparation id.
* @param stepToDeleteId the step id to delete.
*/
public void deleteAction(final String id, final String stepToDeleteId) {
if (Step.ROOT_STEP.getId().equals(stepToDeleteId)) {
throw new TDPException(PREPARATION_ROOT_STEP_CANNOT_BE_DELETED);
}
final PersistentPreparation preparation = lockPreparation(id);
try {
deleteAction(preparation, stepToDeleteId);
auditService.auditPreparationDeleteStep(preparation.getId(), preparation.getName(), stepToDeleteId);
} finally {
unlockPreparation(id);
}
}
Aggregations