Search in sources :

Example 1 with PreparationDetailsDTO

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;
}
Also used : LocaleContextHolder(org.springframework.context.i18n.LocaleContextHolder) PreparationDetailsDTO(org.talend.dataprep.api.preparation.PreparationDetailsDTO) ActionRegistry(org.talend.dataprep.transformation.pipeline.ActionRegistry) CREATE_NEW_COLUMN(org.talend.dataprep.transformation.actions.common.ActionsUtils.CREATE_NEW_COLUMN) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) ActionForm(org.talend.dataprep.api.action.ActionForm) List(java.util.List) Component(org.springframework.stereotype.Component) Locale(java.util.Locale) ActionDefinition(org.talend.dataprep.api.action.ActionDefinition) Action(org.talend.dataprep.api.preparation.Action) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActionForm(org.talend.dataprep.api.action.ActionForm)

Example 2 with PreparationDetailsDTO

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);
    }
}
Also used : Response(com.jayway.restassured.response.Response) TDPException(org.talend.dataprep.exception.TDPException) MockTDPException(org.talend.dataprep.test.MockTDPException) MockTDPException(org.talend.dataprep.test.MockTDPException) PreparationDetailsDTO(org.talend.dataprep.api.preparation.PreparationDetailsDTO) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) IOException(java.io.IOException)

Example 3 with PreparationDetailsDTO

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);
}
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 4 with PreparationDetailsDTO

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;
}
Also used : LocaleContextHolder(org.springframework.context.i18n.LocaleContextHolder) PREPARATION(org.talend.dataprep.api.folder.FolderContentType.PREPARATION) TqlBuilder.match(org.talend.tql.api.TqlBuilder.match) ActionFactory(org.talend.dataprep.transformation.actions.common.ActionFactory) Date(java.util.Date) MAX_VALUE(java.lang.Integer.MAX_VALUE) LoggerFactory(org.slf4j.LoggerFactory) TqlBuilder.and(org.talend.tql.api.TqlBuilder.and) Autowired(org.springframework.beans.factory.annotation.Autowired) PreparationRepository(org.talend.dataprep.preparation.store.PreparationRepository) StringUtils(org.apache.commons.lang3.StringUtils) StepRowMetadata(org.talend.dataprep.api.preparation.StepRowMetadata) LockedResourceRepository(org.talend.dataprep.lock.store.LockedResourceRepository) BeanConversionService(org.talend.dataprep.conversions.BeanConversionService) AppendStep(org.talend.dataprep.api.preparation.AppendStep) Collectors.toMap(java.util.stream.Collectors.toMap) Locale(java.util.Locale) Map(java.util.Map) DataprepBundle.message(org.talend.dataprep.i18n.DataprepBundle.message) PREPARATION_NOT_EMPTY(org.talend.dataprep.exception.error.PreparationErrorCodes.PREPARATION_NOT_EMPTY) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) Collectors.toSet(java.util.stream.Collectors.toSet) StepDiff(org.talend.dataprep.api.preparation.StepDiff) PREPARATION_ROOT_STEP_CANNOT_BE_DELETED(org.talend.dataprep.exception.error.PreparationErrorCodes.PREPARATION_ROOT_STEP_CANNOT_BE_DELETED) Order(org.talend.dataprep.util.SortAndOrderHelper.Order) Collections.emptyList(java.util.Collections.emptyList) Predicate(java.util.function.Predicate) PersistentStep(org.talend.dataprep.preparation.store.PersistentStep) Set(java.util.Set) PreparationErrorCodes(org.talend.dataprep.exception.error.PreparationErrorCodes) PREPARATION_STEP_CANNOT_BE_REORDERED(org.talend.dataprep.exception.error.PreparationErrorCodes.PREPARATION_STEP_CANNOT_BE_REORDERED) UUID(java.util.UUID) PREPARATION_STEP_DOES_NOT_EXIST(org.talend.dataprep.exception.error.PreparationErrorCodes.PREPARATION_STEP_DOES_NOT_EXIST) Objects(java.util.Objects) List(java.util.List) BaseDataprepAuditService(org.talend.dataprep.audit.BaseDataprepAuditService) Stream(java.util.stream.Stream) SortAndOrderHelper.getPreparationComparator(org.talend.dataprep.util.SortAndOrderHelper.getPreparationComparator) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) ActionDefinition(org.talend.dataprep.api.action.ActionDefinition) Security(org.talend.dataprep.security.Security) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) RunnableAction(org.talend.dataprep.transformation.actions.common.RunnableAction) IntStream(java.util.stream.IntStream) TqlBuilder.isEmpty(org.talend.tql.api.TqlBuilder.isEmpty) ImplicitParameters(org.talend.dataprep.transformation.actions.common.ImplicitParameters) TDPException(org.talend.dataprep.exception.TDPException) CREATE_NEW_COLUMN(org.talend.dataprep.transformation.actions.common.ActionsUtils.CREATE_NEW_COLUMN) JsonErrorCodeDescription(org.talend.dataprep.exception.json.JsonErrorCodeDescription) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Deque(java.util.Deque) Expression(org.talend.tql.model.Expression) Function(java.util.function.Function) PersistentPreparation(org.talend.dataprep.preparation.store.PersistentPreparation) DatasetClient(org.talend.dataprep.dataset.adapter.DatasetClient) ArrayList(java.util.ArrayList) PREPARATION_NAME_ALREADY_USED(org.talend.dataprep.exception.error.PreparationErrorCodes.PREPARATION_NAME_ALREADY_USED) HashSet(java.util.HashSet) FolderEntry(org.talend.dataprep.api.folder.FolderEntry) ExceptionContext.build(org.talend.daikon.exception.ExceptionContext.build) ExceptionContext(org.talend.daikon.exception.ExceptionContext) Folder(org.talend.dataprep.api.folder.Folder) Service(org.springframework.stereotype.Service) PREPARATION_DOES_NOT_EXIST(org.talend.dataprep.exception.error.PreparationErrorCodes.PREPARATION_DOES_NOT_EXIST) VersionService(org.talend.dataprep.api.service.info.VersionService) Action(org.talend.dataprep.api.preparation.Action) OwnerInjection(org.talend.dataprep.conversions.inject.OwnerInjection) Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationDetailsDTO(org.talend.dataprep.api.preparation.PreparationDetailsDTO) FolderRepository(org.talend.dataprep.folder.store.FolderRepository) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ActionRegistry(org.talend.dataprep.transformation.pipeline.ActionRegistry) DecimalFormat(java.text.DecimalFormat) Sort(org.talend.dataprep.util.SortAndOrderHelper.Sort) Step(org.talend.dataprep.api.preparation.Step) PreparationSearchCriterion.filterPreparation(org.talend.dataprep.preparation.service.PreparationSearchCriterion.filterPreparation) ActionForm(org.talend.dataprep.api.action.ActionForm) PreparationDTO(org.talend.dataprep.api.preparation.PreparationDTO) TqlBuilder.eq(org.talend.tql.api.TqlBuilder.eq) Collectors.toList(java.util.stream.Collectors.toList) PreparationUtils(org.talend.dataprep.api.preparation.PreparationUtils) SharedInjection(org.talend.dataprep.preparation.configuration.SharedInjection) ActionMetadataValidation(org.talend.dataprep.transformation.api.action.validation.ActionMetadataValidation) Lookup(org.talend.dataprep.transformation.actions.datablending.Lookup) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) PATH_SEPARATOR(org.talend.dataprep.folder.store.FoldersRepositoriesConstants.PATH_SEPARATOR) ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActionForm(org.talend.dataprep.api.action.ActionForm)

Example 5 with PreparationDetailsDTO

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;
}
Also used : PreparationDTO(org.talend.dataprep.api.preparation.PreparationDTO) PreparationDetailsDTO(org.talend.dataprep.api.preparation.PreparationDetailsDTO)

Aggregations

PreparationDetailsDTO (org.talend.dataprep.api.preparation.PreparationDetailsDTO)10 PreparationDTO (org.talend.dataprep.api.preparation.PreparationDTO)6 Action (org.talend.dataprep.api.preparation.Action)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ActionDefinition (org.talend.dataprep.api.action.ActionDefinition)4 ActionForm (org.talend.dataprep.api.action.ActionForm)4 CREATE_NEW_COLUMN (org.talend.dataprep.transformation.actions.common.ActionsUtils.CREATE_NEW_COLUMN)4 ActionRegistry (org.talend.dataprep.transformation.pipeline.ActionRegistry)4 Collections (java.util.Collections)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 Collectors.toList (java.util.stream.Collectors.toList)3 Locale (java.util.Locale)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 StringUtils (org.apache.commons.lang3.StringUtils)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 ApplicationContext (org.springframework.context.ApplicationContext)2