Search in sources :

Example 6 with BooleanExpressionNode

use of org.talend.dataquality.expressions.BooleanExpressionNode in project tdq-studio-se by Talend.

the class AnalysisHelper method setStringDataFilter.

public static boolean setStringDataFilter(Analysis analysis, String datafilterString) {
    EList<Domain> dataFilters = analysis.getParameters().getDataFilter();
    // update existing filters
    if (!dataFilters.isEmpty()) {
        Domain domain = dataFilters.get(0);
        EList<RangeRestriction> ranges = domain.getRanges();
        RangeRestriction rangeRestriction = (ranges.isEmpty()) ? DomainHelper.addRangeRestriction(domain) : ranges.get(0);
        BooleanExpressionNode expressions = rangeRestriction.getExpressions();
        if (expressions == null) {
            expressions = BooleanExpressionHelper.createBooleanExpressionNode(datafilterString);
            rangeRestriction.setExpressions(expressions);
        } else {
            Expression expression = expressions.getExpression();
            if (expression == null) {
                expression = BooleanExpressionHelper.createTdExpression(BooleanExpressionHelper.DEFAULT_LANGUAGE, datafilterString);
                expressions.setExpression(expression);
            } else {
                expression.setBody(datafilterString);
            }
        }
        return false;
    }
    // else
    return dataFilters.add(createDomain(analysis, datafilterString));
}
Also used : Expression(orgomg.cwm.objectmodel.core.Expression) BooleanExpressionNode(org.talend.dataquality.expressions.BooleanExpressionNode) RangeRestriction(org.talend.dataquality.domain.RangeRestriction) Domain(org.talend.dataquality.domain.Domain)

Aggregations

BooleanExpressionNode (org.talend.dataquality.expressions.BooleanExpressionNode)6 Domain (org.talend.dataquality.domain.Domain)4 RangeRestriction (org.talend.dataquality.domain.RangeRestriction)4 Expression (orgomg.cwm.objectmodel.core.Expression)3 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 TdExpression (org.talend.cwm.relational.TdExpression)1 AnalysisParameters (org.talend.dataquality.analysis.AnalysisParameters)1