Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.CompareCriteria


        }
            List<Criteria> joinCriteria = (List<Criteria>) joinNode.getProperty(Info.JOIN_CRITERIA);
            for (int index : toCriteria) {
          SingleElementSymbol lses = leftExpressions.get(index);
          SingleElementSymbol rses = rightExpressions.get(index);
          CompareCriteria cc = new CompareCriteria(lses, CompareCriteria.EQ, rses);
          if (joinCriteria == null || joinCriteria.isEmpty()) {
            joinCriteria = new ArrayList<Criteria>();
            joinCriteria.add(cc);
            joinNode.setProperty(Info.JOIN_TYPE, JoinType.JOIN_INNER);
          }
View Full Code Here


  @Test public void testNegatedSetCriteria() throws Exception {
    DependentAccessNode dan = new DependentAccessNode(0);
    SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), Arrays.asList(new Constant(1), new Constant(2))); //$NON-NLS-1$
    DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
    Criteria result = dcp.prepareCriteria();
    assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(1)), result); //$NON-NLS-1$
    assertTrue(dcp.hasNextCommand());
  }
View Full Code Here

      cc.getVariableContext().setGlobalValue(reference.getContextSymbol(), 1);
    }
    SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), references); //$NON-NLS-1$
    DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
    Criteria result = dcp.prepareCriteria();
    assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(1)), result); //$NON-NLS-1$
    assertFalse(dcp.hasNextCommand());
  }
View Full Code Here

            if(! (theCrit instanceof CompareCriteria)) {
                nonEquiJoinCriteria.add(theCrit);
                continue;
            }
           
            CompareCriteria crit = (CompareCriteria) theCrit;
            if(crit.getOperator() != CompareCriteria.EQ) {
                nonEquiJoinCriteria.add(theCrit);
                continue;
            }
           
            Expression leftExpr = crit.getLeftExpression();
            Expression rightExpr = crit.getRightExpression();
                       
            Set<GroupSymbol> leftExprGroups = GroupsUsedByElementsVisitor.getGroups(leftExpr);           
            Set<GroupSymbol> rightExprGroups = GroupsUsedByElementsVisitor.getGroups(rightExpr);
           
            if (leftGroups.isEmpty() || rightGroups.isEmpty()) {
View Full Code Here

   
  static void filterOptionalCriteria(List<Criteria> crits) {
    for (Iterator<Criteria> iter = crits.iterator(); iter.hasNext();) {
      Criteria crit = iter.next();
      if (crit instanceof CompareCriteria) {
        CompareCriteria cc = (CompareCriteria) crit;
        if (cc.isOptional()) {
          iter.remove();
        }
      }
    }
  }
View Full Code Here

        assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(new Insert())); //$NON-NLS-1$
    }

    public void testHasNoCriteria2() {
        Query query = new Query();
        CompareCriteria crit = new CompareCriteria(new Constant("a"), CompareCriteria.EQ, new Constant("b")); //$NON-NLS-1$ //$NON-NLS-2$
        query.setCriteria(crit);       
        assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(query)); //$NON-NLS-1$
    }
View Full Code Here

   
    // Create criteria
         ElementSymbol es = new ElementSymbol("Catalogs.Catalog.Items.Item.Name"); //$NON-NLS-1$
        es.setGroupSymbol(doc);
        es.setMetadataID(metadata.getElementID("xmltest.doc1.Catalogs.Catalog.Items.Item.Name")); //$NON-NLS-1$
    CompareCriteria crit = new CompareCriteria(es, CompareCriteria.EQ, new Constant("abc")); //$NON-NLS-1$
 
    helpTestMapping(crit, "xmltest.\"group\".items.itemName = 'abc'", mappingDoc, metadata); //$NON-NLS-1$
  }
View Full Code Here

        }
        if (expr2 == null) {
            return expr1;
        }
       
        Criteria crit = new CompareCriteria(expr1, CompareCriteria.LT, expr2);
        SearchedCaseExpression sce = new SearchedCaseExpression(Arrays.asList(new Object[] {crit}), Arrays.asList(new Object[] {expr1}));
        sce.setElseExpression(expr2);
        sce.setType(expr1.getType());
        return evaluateIfPossible(sce);
    }
View Full Code Here

           
        if(crits != null && !crits.isEmpty()) {
          for (Criteria crit : crits) {
                if (!isSupportedJoinCriteria(sjc, crit, accessModelID, metadata, capFinder, record)) {
                  if (crit instanceof CompareCriteria) {
                  CompareCriteria cc = (CompareCriteria) crit;
                  if (cc.isOptional()) {
                    cc.setOptional(true);
                    continue;
                  }
                }
                  return null;
                } else if (crit instanceof CompareCriteria) {
View Full Code Here

        }
        //theta join must be between elements with a compare predicate
      if (!(crit instanceof CompareCriteria)) {
        return false;
      }
      CompareCriteria cc = (CompareCriteria)crit;
      if (!(cc.getLeftExpression() instanceof ElementSymbol)) {
        return false;
      }
      if (!(cc.getRightExpression() instanceof ElementSymbol)) {
        return false;
      }
      if (sjc == SupportedJoinCriteria.THETA) {
        return true;
      }
      //equi must use the equality operator
      if (cc.getOperator() != CompareCriteria.EQ) {
        return false;
      }
    return true;
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.CompareCriteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.