Search in sources :

Example 11 with ActionDefinition

use of org.talend.dataprep.api.action.ActionDefinition in project data-prep by Talend.

the class DeleteTest method should_adapt_to_line_scope.

@Test
public void should_adapt_to_line_scope() {
    // when
    final ActionDefinition adaptedAction = action.adapt(LINE);
    // then
    assertThat(adaptedAction.getDescription(Locale.US), is("Delete this row"));
    assertThat(adaptedAction.getLabel(Locale.US), is("Delete row"));
    assertThat(adaptedAction, not(is(action)));
}
Also used : ActionDefinition(org.talend.dataprep.api.action.ActionDefinition) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 12 with ActionDefinition

use of org.talend.dataprep.api.action.ActionDefinition in project data-prep by Talend.

the class DeleteTest method should_adapt_to_column_scope.

@Test
public void should_adapt_to_column_scope() {
    // when
    final ActionDefinition adaptedAction = action.adapt(COLUMN);
    // then
    assertThat(adaptedAction.getDescription(Locale.US), is("Delete this column"));
    assertThat(adaptedAction.getLabel(Locale.US), is("Delete column"));
}
Also used : ActionDefinition(org.talend.dataprep.api.action.ActionDefinition) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 13 with ActionDefinition

use of org.talend.dataprep.api.action.ActionDefinition in project data-prep by Talend.

the class PreparationService method buildActions.

/**
 * Given a list of actions recreate but with the Spring Context {@link ActionDefinition}. It is mandatory to use any
 * action parsed from JSON.
 */
private List<RunnableAction> buildActions(List<Action> allActions) {
    final List<RunnableAction> builtActions = new ArrayList<>(allActions.size() + 1);
    for (Action parsedAction : allActions) {
        if (parsedAction != null && parsedAction.getName() != null) {
            String actionNameLowerCase = parsedAction.getName().toLowerCase();
            final ActionDefinition metadata = actionRegistry.get(actionNameLowerCase);
            builtActions.add(factory.create(metadata, parsedAction.getParameters()));
        }
    }
    return builtActions;
}
Also used : RunnableAction(org.talend.dataprep.transformation.actions.common.RunnableAction) RunnableAction(org.talend.dataprep.transformation.actions.common.RunnableAction) ActionDefinition(org.talend.dataprep.api.action.ActionDefinition)

Aggregations

ActionDefinition (org.talend.dataprep.api.action.ActionDefinition)13 Test (org.junit.Test)7 Action (org.talend.dataprep.api.preparation.Action)4 RunnableAction (org.talend.dataprep.transformation.actions.common.RunnableAction)4 ActionRegistry (org.talend.dataprep.transformation.pipeline.ActionRegistry)4 HashMap (java.util.HashMap)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 StringUtils (org.apache.commons.lang.StringUtils)2 ServiceBaseTest (org.talend.ServiceBaseTest)2 TalendRuntimeException (org.talend.daikon.exception.TalendRuntimeException)2 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)2 Owner (org.talend.dataprep.api.share.Owner)2 Parameter (org.talend.dataprep.parameters.Parameter)2 PreparationRepository (org.talend.dataprep.preparation.store.PreparationRepository)2 Security (org.talend.dataprep.security.Security)2 AbstractMetadataBaseTest (org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)2