use of org.talend.dataquality.expressions.BooleanExpressionNode in project tdq-studio-se by Talend.
the class RangeRestrictionImpl method basicSetExpressions.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetExpressions(BooleanExpressionNode newExpressions, NotificationChain msgs) {
BooleanExpressionNode oldExpressions = expressions;
expressions = newExpressions;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DomainPackage.RANGE_RESTRICTION__EXPRESSIONS, oldExpressions, newExpressions);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.talend.dataquality.expressions.BooleanExpressionNode in project tdq-studio-se by Talend.
the class AnalysisHelper method createDomain.
private static Domain createDomain(Analysis analysis, String datafilterString, String alias) {
// by default use same name as the analysis. This is ok as long as there is only one datafilter.
Domain domain = DomainHelper.createDomain(analysis.getName() + alias);
RangeRestriction rangeRestriction = DomainHelper.addRangeRestriction(domain);
BooleanExpressionNode expressionNode = BooleanExpressionHelper.createBooleanExpressionNode(datafilterString);
rangeRestriction.setExpressions(expressionNode);
return domain;
}
use of org.talend.dataquality.expressions.BooleanExpressionNode in project tdq-studio-se by Talend.
the class BooleanExpressionHelper method createBooleanExpressionNode.
/**
* Method "createBooleanExpressionNode".
*
* @param body the body of the Expression
* @return a BooleanExpressionNode with the given Expression.
*/
public static BooleanExpressionNode createBooleanExpressionNode(String body) {
BooleanExpressionNode expr = ExpressionsFactory.eINSTANCE.createBooleanExpressionNode();
TdExpression expression = createTdExpression(DEFAULT_LANGUAGE, body);
expr.setExpression(expression);
return expr;
}
use of org.talend.dataquality.expressions.BooleanExpressionNode in project tdq-studio-se by Talend.
the class AnalysisHelper method setStringDataFilter.
/**
* DOC xqliu Comment method "setStringDataFilter".
*
* @param analysis
* @param datafilterString
* @param index 0 for DataFilterA, 1 for DataFilterB
* @return
*/
public static boolean setStringDataFilter(Analysis analysis, String datafilterString, int index) {
if (index == 1) {
EList<Domain> dataFilters = analysis.getParameters().getDataFilter();
int size = dataFilters.size();
if (size == 0) {
// $NON-NLS-1$
dataFilters.add(createDomain(analysis, ""));
// $NON-NLS-1$
return dataFilters.add(createDomain(analysis, datafilterString, "1"));
} else if (size == 1) {
// $NON-NLS-1$
return dataFilters.add(createDomain(analysis, datafilterString, "1"));
} else if (size == 2) {
Domain domain = dataFilters.get(1);
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 false;
}
} else {
return setStringDataFilter(analysis, datafilterString);
}
}
use of org.talend.dataquality.expressions.BooleanExpressionNode in project tdq-studio-se by Talend.
the class AnalysisHelper method getStringDataFilter.
/**
* DOC xqliu Comment method "getStringDataFilter".
*
* @param analysis
* @param index 0 for DataFilterA, 1 for DataFilterB
* @return
*/
public static String getStringDataFilter(Analysis analysis, int index) {
AnalysisParameters parameters = analysis.getParameters();
if (parameters == null) {
return null;
}
EList<Domain> dataFilters = parameters.getDataFilter();
// remove existing filters
if (dataFilters == null || dataFilters.isEmpty()) {
return null;
}
int i = 0;
for (Domain domain : dataFilters) {
if (domain == null) {
continue;
}
EList<RangeRestriction> ranges = domain.getRanges();
for (RangeRestriction rangeRestriction : ranges) {
BooleanExpressionNode expressions = rangeRestriction.getExpressions();
if (expressions == null) {
continue;
}
Expression expression = expressions.getExpression();
if (expression == null) {
continue;
}
if (i == index) {
// MOD klliu 2011-07-14 bug 23150 solve an NPE
String body = expression.getBody();
if (body == null) {
continue;
}
// ~
return body.trim();
} else if (i > index) {
return null;
}
}
i++;
}
return null;
}
Aggregations