Search in sources :

Example 6 with DataSetRowAction

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

the class MetadataChangesOnActionsGenerator method compileActionsOnMetadata.

/**
 * Compile the given actions, hence updating the given row metadata and return the later.
 *
 * @param actions the actions to compile.
 * @param startingRowMetadata the row metadata to start from.
 * @return the updated row metadata from the actions compilation.
 */
private RowMetadata compileActionsOnMetadata(List<RunnableAction> actions, final RowMetadata startingRowMetadata) {
    final RowMetadata updatedRowMetadata = startingRowMetadata.clone();
    TransformationContext transformationContext = new TransformationContext();
    // compile every action within the transformation context
    for (RunnableAction action : actions) {
        final DataSetRowAction rowAction = action.getRowAction();
        final ActionContext actionContext = transformationContext.create(rowAction, updatedRowMetadata);
        rowAction.compile(actionContext);
    }
    // the cleanup is REALLY important (as it can close http connection in case of a lookup for instance)
    transformationContext.cleanup();
    return updatedRowMetadata;
}
Also used : DataSetRowAction(org.talend.dataprep.transformation.api.action.DataSetRowAction) RunnableAction(org.talend.dataprep.transformation.actions.common.RunnableAction) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) ActionContext(org.talend.dataprep.transformation.api.action.context.ActionContext) TransformationContext(org.talend.dataprep.transformation.api.action.context.TransformationContext)

Aggregations

RunnableAction (org.talend.dataprep.transformation.actions.common.RunnableAction)6 DataSetRowAction (org.talend.dataprep.transformation.api.action.DataSetRowAction)6 TransformationContext (org.talend.dataprep.transformation.api.action.context.TransformationContext)6 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)5 ActionContext (org.talend.dataprep.transformation.api.action.context.ActionContext)5 Test (org.junit.Test)4 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 CoreMatchers (org.hamcrest.CoreMatchers)2 CoreMatchers.is (org.hamcrest.CoreMatchers.is)2 Assert (org.junit.Assert)2 Before (org.junit.Before)2 DataSet (org.talend.dataprep.api.dataset.DataSet)2 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)2 END_OF_STREAM (org.talend.dataprep.transformation.pipeline.Signal.END_OF_STREAM)2 NodeBuilder (org.talend.dataprep.transformation.pipeline.builder.NodeBuilder)2