use of org.talend.dataprep.api.preparation.PreparationDetailsDTO in project data-prep by Talend.
the class InjectorUtil method injectPreparationDetails.
public PreparationDetailsDTO injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details) {
// Append actions and action forms
details.setActions(actions);
final AtomicBoolean allowDistributedRun = new AtomicBoolean();
final List<ActionForm> metadata = actions.stream().map(//
a -> registry.get(a.getName())).peek(a -> {
if (allowDistributedRun.get()) {
allowDistributedRun.set(a.getBehavior().contains(ActionDefinition.Behavior.FORBID_DISTRIBUTED));
}
}).map(//
a -> a.getActionForm(LocaleContextHolder.getLocale(), Locale.US)).map(//
InjectorUtil::disallowColumnCreationChange).collect(Collectors.toList());
details.setMetadata(metadata);
// Flag for allow distributed run (based on metadata).
details.setAllowDistributedRun(allowDistributedRun.get());
return details;
}
use of org.talend.dataprep.api.preparation.PreparationDetailsDTO in project data-prep by Talend.
the class PreparationClientTest method getDetails.
/**
* Return the details of a preparation at a given (optional) step.
*
* @param preparationId the wanted preparation id.
* @param wantedStepId the optional wanted step id.
* @return the details of a preparation at a given (optional) step.
*/
public PreparationDetailsDTO getDetails(String preparationId, String wantedStepId) {
final RequestSpecification specs = given();
if (StringUtils.isNotBlank(wantedStepId)) {
specs.queryParam("stepId", wantedStepId);
}
final Response response = specs.when().get("/preparations/{id}/details", preparationId);
if (response.getStatusCode() != 200) {
throw new MockTDPException(response);
}
try {
return mapper.readerFor(PreparationDetailsDTO.class).readValue(response.asString());
} catch (IOException e) {
throw new TDPException(UNABLE_TO_READ_CONTENT);
}
}
use of org.talend.dataprep.api.preparation.PreparationDetailsDTO 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);
}
use of org.talend.dataprep.api.preparation.PreparationDetailsDTO in project data-prep by Talend.
the class PreparationService method injectActionsForms.
private PreparationDetailsDTO injectActionsForms(PreparationDetailsDTO details) {
// Append actions and action forms
Iterator<String> stepsIterator = details.getSteps().iterator();
final AtomicBoolean allowDistributedRun = new AtomicBoolean();
final List<ActionForm> metadata = details.getActions().stream().map(action -> {
String stepBeforeAction = stepsIterator.next();
return adaptActionDefinition(details, action, stepBeforeAction);
}).peek(a -> {
if (allowDistributedRun.get()) {
allowDistributedRun.set(a.getBehavior().contains(ActionDefinition.Behavior.FORBID_DISTRIBUTED));
}
}).map(//
a -> a.getActionForm(LocaleContextHolder.getLocale(), Locale.US)).map(//
PreparationService::disallowColumnCreationChange).collect(toList());
details.setMetadata(metadata);
// Flag for allow distributed run (based on metadata).
details.setAllowDistributedRun(allowDistributedRun.get());
return details;
}
use of org.talend.dataprep.api.preparation.PreparationDetailsDTO in project data-prep by Talend.
the class PreparationService method getPreparationDetailsFull.
/**
* Return a preparation details.
*
* @param id the wanted preparation id.
* @param stepId the optional step id.
* @return the preparation details.
*/
public PreparationDetailsDTO getPreparationDetailsFull(String id, String stepId) {
final PreparationDTO prep = getPreparationDetails(id, stepId);
final PreparationDetailsDTO details = injectActionsForms(beanConversionService.convert(prep, PreparationDetailsDTO.class));
LOGGER.debug("returning details for {} -> {}", id, details);
return details;
}
Aggregations