You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2003/11/28 07:41:59 UTC

cvs commit: ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl SQLGeneratorImpl.java

jochen      2003/11/27 22:41:59

  Modified:    src/js/org/apache/ws/jaxme/sqls SQLGenerator.java
               src/js/org/apache/ws/jaxme/sqls/impl SQLGeneratorImpl.java
  Log:
  Added SQLGenerator.getConstraint(Constraint)
  
  Revision  Changes    Path
  1.4       +4 -0      ws-jaxme/src/js/org/apache/ws/jaxme/sqls/SQLGenerator.java
  
  Index: SQLGenerator.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/SQLGenerator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SQLGenerator.java	24 Nov 2003 08:40:08 -0000	1.3
  +++ SQLGenerator.java	28 Nov 2003 06:41:58 -0000	1.4
  @@ -138,6 +138,10 @@
      */
     public String getQuery(Statement pStatement);
   
  +  /** <p>Generates the WHERE clause of a SELECT, UPDATE, or DELETE statement.</p>
  +   */
  +  public String getConstraint(Constraint pConstraint);
  +
     /** <p>Sets the statement terminator. A non-null value will be
      * appended to all generated statements. Defaults to null.</p>
      */
  
  
  
  1.6       +35 -10    ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/SQLGeneratorImpl.java
  
  Index: SQLGeneratorImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/SQLGeneratorImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SQLGeneratorImpl.java	24 Nov 2003 08:40:08 -0000	1.5
  +++ SQLGeneratorImpl.java	28 Nov 2003 06:41:58 -0000	1.6
  @@ -781,15 +781,15 @@
       protected void addBooleanConstraint(BooleanConstraint pConstraint) {
         BooleanConstraint.Type type = pConstraint.getType();
         if (BooleanConstraint.Type.EQ.equals(type)
  -           ||  BooleanConstraint.Type.EXISTS.equals(type)
  -           ||  BooleanConstraint.Type.GE.equals(type)
  -           ||  BooleanConstraint.Type.GT.equals(type)
  -           ||  BooleanConstraint.Type.IN.equals(type)
  -           ||  BooleanConstraint.Type.ISNULL.equals(type)
  -           ||  BooleanConstraint.Type.LE.equals(type)
  -           ||  BooleanConstraint.Type.LIKE.equals(type)
  -           ||  BooleanConstraint.Type.LT.equals(type)
  -           ||  BooleanConstraint.Type.NE.equals(type)) {
  +          ||  BooleanConstraint.Type.EXISTS.equals(type)
  +          ||  BooleanConstraint.Type.GE.equals(type)
  +          ||  BooleanConstraint.Type.GT.equals(type)
  +          ||  BooleanConstraint.Type.IN.equals(type)
  +          ||  BooleanConstraint.Type.ISNULL.equals(type)
  +          ||  BooleanConstraint.Type.LE.equals(type)
  +          ||  BooleanConstraint.Type.LIKE.equals(type)
  +          ||  BooleanConstraint.Type.LT.equals(type)
  +          ||  BooleanConstraint.Type.NE.equals(type)) {
           for (Iterator iter = pConstraint.getParts();  iter.hasNext();  ) {
             Object o = iter.next();
             if (o instanceof SelectStatement) {
  @@ -797,7 +797,8 @@
             } else if (o instanceof CombinedConstraint) {
               addCombinedConstraint((CombinedConstraint) o);
             } else if (o instanceof ColumnReference
  -                      ||  o instanceof Value) {
  +                      ||  o instanceof Value
  +                      ||  o instanceof RawSQLCode) {
               // Ignore me
             } else {
               throw new IllegalStateException("Invalid part in boolean constraint: " + o);
  @@ -1056,5 +1057,29 @@
   
     public Collection getDrop(ForeignKey pKey) {
       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);
  +      }
  +    } else if (pConstraint instanceof BooleanConstraint) {
  +      BooleanConstraint bc = (BooleanConstraint) pConstraint;
  +      Statement st = bc.getConstrainedStatement();
  +      if (st instanceof SelectStatement) {
  +        SelectStatementMetaData selectStatementMetaData = new SelectStatementMetaData((SelectStatement) st);
  +        return getBooleanConstraint(selectStatementMetaData, bc);
  +      } else {
  +        return getBooleanConstraint(null, bc);
  +      }
  +     } else {
  +       throw new IllegalStateException("Invalid type of Constraint: " + pConstraint);
  +     }
     }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org