Search in sources :

Example 6 with Condition

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;
}
Also used : Condition(org.teiid.language.Condition) Comparison(org.teiid.language.Comparison)

Example 7 with Condition

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);
}
Also used : Condition(org.teiid.language.Condition)

Example 8 with Condition

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);
}
Also used : Condition(org.teiid.language.Condition) HashSet(java.util.HashSet)

Aggregations

Condition (org.teiid.language.Condition)8 Expression (org.teiid.language.Expression)3 ArrayList (java.util.ArrayList)2 Comparison (org.teiid.language.Comparison)2 Literal (org.teiid.language.Literal)2 HashSet (java.util.HashSet)1 TranslationUtility (org.teiid.cdk.api.TranslationUtility)1 ColumnReference (org.teiid.language.ColumnReference)1 In (org.teiid.language.In)1 SearchedWhenClause (org.teiid.language.SearchedWhenClause)1 Select (org.teiid.language.Select)1 SetClause (org.teiid.language.SetClause)1 Update (org.teiid.language.Update)1 ForeignKey (org.teiid.metadata.ForeignKey)1 Table (org.teiid.metadata.Table)1 TranslatorException (org.teiid.translator.TranslatorException)1