use of org.teiid.language.Condition in project teiid by teiid.
the class ODataQuery method parseKeySegmentFromCondition.
protected Condition parseKeySegmentFromCondition(Condition obj) throws TranslatorException {
List<Condition> crits = LanguageUtil.separateCriteriaByAnd(obj);
if (!crits.isEmpty()) {
boolean modified = false;
for (Iterator<Condition> iter = crits.iterator(); iter.hasNext(); ) {
Condition crit = iter.next();
if (crit instanceof Comparison) {
Comparison left = (Comparison) crit;
boolean leftAdded = parseKeySegmentFromComparison(left);
if (leftAdded) {
iter.remove();
modified = true;
}
}
}
if (modified) {
return LanguageUtil.combineCriteria(crits);
}
}
return obj;
}
use of org.teiid.language.Condition in project teiid by teiid.
the class TestLanguageUtil method helpTestCombineCriteria.
public void helpTestCombineCriteria(String primaryStr, String additionalStr, String expected) throws Exception {
Condition primaryCrit = (primaryStr == null ? null : convertCriteria(primaryStr));
Condition additionalCrit = (additionalStr == null ? null : convertCriteria(additionalStr));
// Execute
Condition crit = LanguageUtil.combineCriteria(primaryCrit, additionalCrit, LanguageFactory.INSTANCE);
// Compare
String critStr = (crit == null ? null : crit.toString());
// $NON-NLS-1$
assertEquals("Did not get expected criteria", expected, critStr);
}
use of org.teiid.language.Condition in project teiid by teiid.
the class TestLanguageUtil method helpTestSeparateByAnd.
public void helpTestSeparateByAnd(String criteriaStr, String[] expected) throws Exception {
Condition criteria = convertCriteria(criteriaStr);
// Execute
List<Condition> crits = LanguageUtil.separateCriteriaByAnd(criteria);
// Build expected and actual sets
Set<String> expectedSet = new HashSet<String>(Arrays.asList(expected));
Set<String> actualSet = new HashSet<String>();
for (int i = 0; i < crits.size(); i++) {
actualSet.add(crits.get(i).toString());
}
// Compare
// $NON-NLS-1$
assertEquals("Did not get expected criteria pieces", expectedSet, actualSet);
}
Aggregations