Search in sources :

Example 6 with ReplaceOnValueHelper

use of org.talend.dataprep.transformation.actions.common.ReplaceOnValueHelper in project data-prep by Talend.

the class MatchesPattern method getPattern.

/**
 * @param parameters the action parameters.
 * @return the pattern to use according to the given parameters.
 */
private ReplaceOnValueHelper getPattern(Map<String, String> parameters) {
    if (CUSTOM.equals(parameters.get(PATTERN_PARAMETER))) {
        final String jsonString = parameters.get(MANUAL_PATTERN_PARAMETER);
        final ReplaceOnValueHelper regexParametersHelper = new ReplaceOnValueHelper();
        return regexParametersHelper.build(jsonString, true);
    } else {
        return new ReplaceOnValueHelper(parameters.get(PATTERN_PARAMETER), ReplaceOnValueHelper.REGEX_MODE);
    }
}
Also used : ReplaceOnValueHelper(org.talend.dataprep.transformation.actions.common.ReplaceOnValueHelper)

Example 7 with ReplaceOnValueHelper

use of org.talend.dataprep.transformation.actions.common.ReplaceOnValueHelper in project data-prep by Talend.

the class DeleteOnValue method compile.

@Override
public void compile(ActionContext actionContext) {
    super.compile(actionContext);
    if (ActionsUtils.doesCreateNewColumn(actionContext.getParameters(), CREATE_NEW_COLUMN_DEFAULT)) {
        ActionsUtils.createNewColumn(actionContext, singletonList(ActionsUtils.additionalColumn()));
    }
    if (actionContext.getActionStatus() == OK) {
        final Map<String, String> parameters = actionContext.getParameters();
        final ReplaceOnValueHelper regexParametersHelper = new ReplaceOnValueHelper();
        actionContext.get("replaceOnValue", p -> regexParametersHelper.build(parameters.get(VALUE_PARAMETER), true));
    }
}
Also used : ReplaceOnValueHelper(org.talend.dataprep.transformation.actions.common.ReplaceOnValueHelper)

Aggregations

ReplaceOnValueHelper (org.talend.dataprep.transformation.actions.common.ReplaceOnValueHelper)7 InvalidParameterException (java.security.InvalidParameterException)1 Pattern (java.util.regex.Pattern)1 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)1 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)1