Package org.apache.ws.jaxme.sqls

Examples of org.apache.ws.jaxme.sqls.CombinedConstraint


        return type;
    }
   
    public CombinedConstraint createAndConstraint() {
        ObjectFactory f = getConstrainedStatement().getSQLFactory().getObjectFactory();
        CombinedConstraint result = f.newCombinedConstraint(getConstrainedStatement(),
                CombinedConstraint.Type.AND);
        parts.add(result);
        return result;
    }
View Full Code Here


        return result;
    }
   
    public CombinedConstraint createOrConstraint() {
        ObjectFactory f = getConstrainedStatement().getSQLFactory().getObjectFactory();
        CombinedConstraint result = f.newCombinedConstraint(getConstrainedStatement(),
                CombinedConstraint.Type.OR);
        parts.add(result);
        return result;
    }
View Full Code Here

        return parts.iterator();
    }
   
    public void addConstraint(Map pMap, Constraint pConstraint) {
        if (pConstraint instanceof CombinedConstraint) {
            CombinedConstraint source = (CombinedConstraint) pConstraint;
            CombinedConstraint target;
            if (source.getType().equals(getType())) {
                target = this;
            } else if (source.getType().equals(CombinedConstraint.Type.AND)) {
                target = createAndConstraint();
            } else if (source.getType().equals(CombinedConstraint.Type.OR)) {
                target = createOrConstraint();
            } else {
                throw new IllegalStateException("Unknown combined constraint type: " +
                        source.getType());
            }
            for (Iterator iter = source.getParts();  iter.hasNext()) {
                Object o = iter.next();
                if (o instanceof CombinedConstraint) {
                    target.addConstraint(pMap, (CombinedConstraint) o);
                } else if (o instanceof BooleanConstraint) {
                    target.addConstraint(pMap, (BooleanConstraint) o);
                } else {
                    throw new IllegalArgumentException("Invalid part: " + o.getClass().getName());
                }
            }
        } else if (pConstraint instanceof BooleanConstraint) {
            BooleanConstraint source = (BooleanConstraint) pConstraint;
            BooleanConstraint target;
            BooleanConstraint.Type sourceType = source.getType();
            if (BooleanConstraint.Type.EQ.equals(sourceType)) {
                target = createEQ();
            } else if (BooleanConstraint.Type.NE.equals(sourceType)) {
                target = createNE();
            } else if (BooleanConstraint.Type.GT.equals(sourceType)) {
                target = createGT();
            } else if (BooleanConstraint.Type.LT.equals(sourceType)) {
                target = createLT();
            } else if (BooleanConstraint.Type.GE.equals(sourceType)) {
                target = createGE();
            } else if (BooleanConstraint.Type.LE.equals(sourceType)) {
                target = createLE();
            } else if (BooleanConstraint.Type.LIKE.equals(sourceType)) {
                target = createLIKE();
            else if (BooleanConstraint.Type.ISNULL.equals(sourceType)) {
                target = createISNULL();
            } else if (BooleanConstraint.Type.IN.equals(sourceType)) {
                target = createIN();
            } else {
                throw new IllegalArgumentException("Invalid boolean constraint type: " + sourceType);
            }
            for (Iterator iter = source.getParts();  iter.hasNext()) {
                Object o = iter.next();
                if (o instanceof Value) {
                    target.addPart((Value) o);
                } else if (o instanceof ColumnReference) {
                    ColumnReference colRef = (ColumnReference) o;
                    TableReference tableRef = (TableReference) pMap.get(colRef.getTableReference());
                    if (tableRef == null) {
                        throw new IllegalStateException("Unknown reference to table " + colRef.getTableReference().getTable().getQName());
                    }
                    target.addPart(tableRef.newColumnReference(colRef.getColumn()));
                } else {
                    throw new IllegalStateException("Unknown part type: " + o.getClass().getName());
                }
            }
        } else {
View Full Code Here

  public CombinedConstraint.Type getType() {
    return type;
  }

  public CombinedConstraint createAndConstraint() {
    CombinedConstraint result = new CombinedConstraintImpl(getConstrainedStatement(),
                                                           CombinedConstraint.Type.AND);
    parts.add(result);
    return result;
  }
View Full Code Here

    parts.add(result);
    return result;
  }

  public CombinedConstraint createOrConstraint() {
      CombinedConstraint result = new CombinedConstraintImpl(getConstrainedStatement(),
                                                             CombinedConstraint.Type.OR);
      parts.add(result);
      return result;
  }
View Full Code Here

    return parts.iterator();
  }

  public void addConstraint(Map pMap, Constraint pConstraint) {
    if (pConstraint instanceof CombinedConstraint) {
      CombinedConstraint source = (CombinedConstraint) pConstraint;
      CombinedConstraint target;
      if (source.getType().equals(getType())) {
        target = this;
      } else if (source.getType().equals(CombinedConstraint.Type.AND)) {
        target = createAndConstraint();
      } else if (source.getType().equals(CombinedConstraint.Type.OR)) {
        target = createOrConstraint();
      } else {
        throw new IllegalStateException("Unknown combined constraint type: " +
                                        source.getType());
      }
      for (Iterator iter = source.getParts();  iter.hasNext()) {
        Object o = iter.next();
        if (o instanceof CombinedConstraint) {
          target.addConstraint(pMap, (CombinedConstraint) o);
        } else if (o instanceof BooleanConstraint) {
          target.addConstraint(pMap, (BooleanConstraint) o);
        } else {
          throw new IllegalArgumentException("Invalid part: " + o.getClass().getName());
        }
      }
    } else if (pConstraint instanceof BooleanConstraint) {
      BooleanConstraint source = (BooleanConstraint) pConstraint;
      BooleanConstraint target;
      BooleanConstraint.Type sourceType = source.getType();
      if (BooleanConstraint.Type.EQ.equals(sourceType)) {
        target = createEQ();
      } else if (BooleanConstraint.Type.NE.equals(sourceType)) {
        target = createNE();
      } else if (BooleanConstraint.Type.GT.equals(sourceType)) {
        target = createGT();
      } else if (BooleanConstraint.Type.LT.equals(sourceType)) {
        target = createLT();
      } else if (BooleanConstraint.Type.GE.equals(sourceType)) {
        target = createGE();
      } else if (BooleanConstraint.Type.LE.equals(sourceType)) {
        target = createLE();
      } else if (BooleanConstraint.Type.LIKE.equals(sourceType)) {
        target = createLIKE();
      else if (BooleanConstraint.Type.ISNULL.equals(sourceType)) {
        target = createISNULL();
      } else if (BooleanConstraint.Type.IN.equals(sourceType)) {
        target = createIN();
      } else {
        throw new IllegalArgumentException("Invalid boolean constraint type: " + sourceType);
      }
      for (Iterator iter = source.getParts();  iter.hasNext()) {
        Object o = iter.next();
        if (o instanceof Value) {
          target.addPart((Value) o);
        } else if (o instanceof ColumnReference) {
           ColumnReference colRef = (ColumnReference) o;
           TableReference tableRef = (TableReference) pMap.get(colRef.getTableReference());
           if (tableRef == null) {
             throw new IllegalStateException("Unknown reference to table " + colRef.getTableReference().getTable().getQName());
           }
           target.addPart(tableRef.newColumnReference(colRef.getColumn()));
        } else {
           throw new IllegalStateException("Unknown part type: " + o.getClass().getName());
        }
      }
    } else {
View Full Code Here

     TableReference refLocal = tableReference;
     TableReference refRef = tableReference.getRightJoinedTableReference();

     joinReference.getOn().addJoin((ForeignKey) otherTable.getForeignKeys().next(),
                                   refLocal, refRef);
     CombinedConstraint cc = statement.getWhere();
     BooleanConstraint bc = cc.createEQ();
     bc.addPart(tableReference.newColumnReference("MyIndex"));
     bc.addPlaceholder();

     SQLGenerator generator = getSQLGenerator();
     generator.setLineTerminator("\n");
View Full Code Here

     TableReference refLocal = tableReference;
     TableReference refRef = tableReference.getRightJoinedTableReference();

     joinReference.getOn().addJoin((ForeignKey) otherTable.getForeignKeys().next(),
                                   refLocal, refRef);
     CombinedConstraint cc = statement.getWhere();
     BooleanConstraint bc = cc.createEQ();
     bc.addPart(tableReference.newColumnReference("MyIndex"));
     bc.addPlaceholder();

     SQLGenerator generator = getSQLGenerator();
     generator.setLineTerminator("\n");
View Full Code Here

    return Collections.EMPTY_SET;
  }

  public String getConstraint(Constraint pConstraint) {
    if (pConstraint instanceof CombinedConstraint) {
      CombinedConstraint cc = (CombinedConstraint) pConstraint;
      Statement st = cc.getConstrainedStatement();
      if (st instanceof SelectStatement) {
        SelectStatementMetaData selectStatementMetaData = new SelectStatementMetaData((SelectStatement) st);
        return getCombinedConstraint(selectStatementMetaData, cc);
      } else {
        return getCombinedConstraint(null, cc);
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.sqls.CombinedConstraint

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.