chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1026325 [1/2] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/ chemistry-opencmis-server-inmemory/src/test/java/org/apache/ch...
Date Fri, 22 Oct 2010 13:52:34 GMT
Author: jens
Date: Fri Oct 22 13:52:33 2010
New Revision: 1026325

URL: http://svn.apache.org/viewvc?rev=1026325&view=rev
Log:
cleanup walker and fully switch to PredicateWalker:
 (1) removed the old walker code
 (2) changed walker grammar so that PredicateWalker is now used.
 (3) splitted interface PredicateWalter and let it inherit from PredicateWalkerBase 
     so that people can implement their own walking logic if they like without changing grammar
 (4) moved code from (1) to test classes so that we have an example for (3)
 (5) changed return value of all boolean methods in interface to Boolean so that you can 
     return null

Added:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryConditionProcessor.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalkerBase.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
Removed:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractQueryConditionProcessor.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryConditionProcessor.java
Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractPredicateWalker.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalker.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java?rev=1026325&r1=1026324&r2=1026325&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java Fri Oct 22 13:52:33 2010
@@ -54,15 +54,14 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.impl.ObjectStoreImpl;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
 import org.apache.chemistry.opencmis.server.support.TypeManager;
-import org.apache.chemistry.opencmis.server.support.query.AbstractQueryConditionProcessor;
 import org.apache.chemistry.opencmis.server.support.query.AbstractPredicateWalker;
-import org.apache.chemistry.opencmis.server.support.query.CalendarHelper;
 import org.apache.chemistry.opencmis.server.support.query.CmisQueryWalker;
 import org.apache.chemistry.opencmis.server.support.query.CmisSelector;
 import org.apache.chemistry.opencmis.server.support.query.ColumnReference;
 import org.apache.chemistry.opencmis.server.support.query.FunctionReference;
 import org.apache.chemistry.opencmis.server.support.query.QueryObject;
 import org.apache.chemistry.opencmis.server.support.query.QueryObject.SortSpec;
+import org.apache.chemistry.opencmis.server.support.query.QueryUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -91,7 +90,7 @@ public class InMemoryQueryProcessor {
             String statement, Boolean searchAllVersions, Boolean includeAllowableActions,
             IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems, BigInteger skipCount) {
 
-        queryObj = new QueryObject(tm, null);
+        queryObj = new QueryObject(tm);
         processQueryAndCatchExc(statement); // calls query processor
 
         // iterate over all the objects and check for each if the query matches
@@ -108,14 +107,14 @@ public class InMemoryQueryProcessor {
 
     public CmisQueryWalker processQuery(String statement) throws UnsupportedEncodingException, IOException,
             RecognitionException {
-        CmisQueryWalker walker = AbstractQueryConditionProcessor.getWalker(statement);
-        walker.query(queryObj);
+        CmisQueryWalker walker = QueryUtil.getWalker(statement);
+        walker.query(queryObj, null);
         String errMsg = walker.getErrorMessageString();
         if (null != errMsg) {
             throw new RuntimeException("Walking of statement failed with error: \n   " + errMsg
                     + "\n   Statement was: " + statement);
         }
-        whereTree = queryObj.getWhereTree();
+        whereTree = walker.getWherePredicateTree();
         return walker;
     }
 
@@ -222,7 +221,7 @@ public class InMemoryQueryProcessor {
      * Check for each object contained in the in-memory repository if it matches
      * the current query expression. If yes add it to the list of matched
      * objects.
-     *
+     * 
      * @param so
      *            object stored in the in-memory repository
      */
@@ -230,13 +229,13 @@ public class InMemoryQueryProcessor {
         // log.debug("checkMatch() for object: " + so.getId());
         // first check if type is matching...
         String queryName = queryObj.getTypes().values().iterator().next(); // as
-                                                                            // we
-                                                                            // don't
-                                                                            // support
-                                                                            // JOINS
-                                                                            // take
-                                                                            // first
-                                                                            // type
+                                                                           // we
+                                                                           // don't
+                                                                           // support
+                                                                           // JOINS
+                                                                           // take
+                                                                           // first
+                                                                           // type
         TypeDefinition td = queryObj.getTypeDefinitionFromQueryName(queryName);
         boolean skip = so instanceof VersionedDocument; // we are only
                                                         // interested in
@@ -254,7 +253,7 @@ public class InMemoryQueryProcessor {
     private void evalWhereTree(Tree node, StoredObject so) {
         boolean match = true;
         if (null != node)
-            match = evalWhereNode(so, node.getChild(0));
+            match = evalWhereNode(so, node);
         if (match)
             matches.add(so); // add to list
     }
@@ -263,7 +262,7 @@ public class InMemoryQueryProcessor {
      * For each object check if it matches and append it to match-list if it
      * does. We do here our own walking mechanism so that we can pass additional
      * parameters and define the return types.
-     *
+     * 
      * @param node
      *            node in where clause
      * @return true if it matches, false if it not matches
@@ -281,63 +280,63 @@ public class InMemoryQueryProcessor {
         }
 
         @Override
-        public boolean walkNot(Tree opNode, Tree node) {
+        public Boolean walkNot(Tree opNode, Tree node) {
             boolean matches = walkPredicate(node);
             return !matches;
         }
 
         @Override
-        public boolean walkAnd(Tree opNode, Tree leftNode, Tree rightNode) {
+        public Boolean walkAnd(Tree opNode, Tree leftNode, Tree rightNode) {
             boolean matches1 = walkPredicate(leftNode);
             boolean matches2 = walkPredicate(rightNode);
             return matches1 && matches2;
         }
 
         @Override
-        public boolean walkOr(Tree opNode, Tree leftNode, Tree rightNode) {
+        public Boolean walkOr(Tree opNode, Tree leftNode, Tree rightNode) {
             boolean matches1 = walkPredicate(leftNode);
             boolean matches2 = walkPredicate(rightNode);
             return matches1 || matches2;
         }
 
         @Override
-        public boolean walkEquals(Tree opNode, Tree leftNode, Tree rightNode) {
+        public Boolean walkEquals(Tree opNode, Tree leftNode, Tree rightNode) {
             Integer cmp = compareTo(leftNode, rightNode);
             return cmp == null ? false : cmp == 0;
         }
 
         @Override
-        public boolean walkNotEquals(Tree opNode, Tree leftNode, Tree rightNode) {
+        public Boolean walkNotEquals(Tree opNode, Tree leftNode, Tree rightNode) {
             Integer cmp = compareTo(leftNode, rightNode);
             return cmp == null ? false : cmp != 0;
         }
 
         @Override
-        public boolean walkGreaterThan(Tree opNode, Tree leftNode, Tree rightNode) {
+        public Boolean walkGreaterThan(Tree opNode, Tree leftNode, Tree rightNode) {
             Integer cmp = compareTo(leftNode, rightNode);
             return cmp == null ? false : cmp > 0;
         }
 
         @Override
-        public boolean walkGreaterOrEquals(Tree opNode, Tree leftNode, Tree rightNode) {
+        public Boolean walkGreaterOrEquals(Tree opNode, Tree leftNode, Tree rightNode) {
             Integer cmp = compareTo(leftNode, rightNode);
             return cmp == null ? false : cmp >= 0;
         }
 
         @Override
-        public boolean walkLessThan(Tree opNode, Tree leftNode, Tree rightNode) {
+        public Boolean walkLessThan(Tree opNode, Tree leftNode, Tree rightNode) {
             Integer cmp = compareTo(leftNode, rightNode);
             return cmp == null ? false : cmp < 0;
         }
 
         @Override
-        public boolean walkLessOrEquals(Tree opNode, Tree leftNode, Tree rightNode) {
+        public Boolean walkLessOrEquals(Tree opNode, Tree leftNode, Tree rightNode) {
             Integer cmp = compareTo(leftNode, rightNode);
             return cmp == null ? false : cmp <= 0;
         }
 
         @Override
-        public boolean walkIn(Tree opNode, Tree colNode, Tree listNode) {
+        public Boolean walkIn(Tree opNode, Tree colNode, Tree listNode) {
             ColumnReference colRef = getColumnReference(colNode);
             PropertyDefinition<?> pd = colRef.getPropertyDefinition();
             PropertyData<?> lVal = so.getProperties().get(colRef.getPropertyId());
@@ -356,7 +355,7 @@ public class InMemoryQueryProcessor {
         }
 
         @Override
-        public boolean walkNotIn(Tree opNode, Tree colNode, Tree listNode) {
+        public Boolean walkNotIn(Tree opNode, Tree colNode, Tree listNode) {
             // Note just return !walkIn(node, colNode, listNode) is wrong,
             // because
             // then it evaluates to true for null values (not set properties).
@@ -378,7 +377,7 @@ public class InMemoryQueryProcessor {
         }
 
         @Override
-        public boolean walkInAny(Tree opNode, Tree colNode, Tree listNode) {
+        public Boolean walkInAny(Tree opNode, Tree colNode, Tree listNode) {
             ColumnReference colRef = getColumnReference(colNode);
             PropertyDefinition<?> pd = colRef.getPropertyDefinition();
             PropertyData<?> lVal = so.getProperties().get(colRef.getPropertyId());
@@ -399,7 +398,7 @@ public class InMemoryQueryProcessor {
         }
 
         @Override
-        public boolean walkNotInAny(Tree opNode, Tree colNode, Tree listNode) {
+        public Boolean walkNotInAny(Tree opNode, Tree colNode, Tree listNode) {
             // Note just return !walkNotInAny(node, colNode, listNode) is
             // wrong, because
             // then it evaluates to true for null values (not set properties).
@@ -423,7 +422,7 @@ public class InMemoryQueryProcessor {
         }
 
         @Override
-        public boolean walkEqAny(Tree opNode, Tree literalNode, Tree colNode) {
+        public Boolean walkEqAny(Tree opNode, Tree literalNode, Tree colNode) {
             ColumnReference colRef = getColumnReference(colNode);
             PropertyDefinition<?> pd = colRef.getPropertyDefinition();
             PropertyData<?> lVal = so.getProperties().get(colRef.getPropertyId());
@@ -442,19 +441,19 @@ public class InMemoryQueryProcessor {
         }
 
         @Override
-        public boolean walkIsNull(Tree opNode, Tree colNode) {
+        public Boolean walkIsNull(Tree opNode, Tree colNode) {
             Object propVal = getPropertyValue(colNode, so);
             return propVal == null;
         }
 
         @Override
-        public boolean walkIsNotNull(Tree opNode, Tree colNode) {
+        public Boolean walkIsNotNull(Tree opNode, Tree colNode) {
             Object propVal = getPropertyValue(colNode, so);
             return propVal != null;
         }
 
         @Override
-        public boolean walkLike(Tree opNode, Tree colNode, Tree stringNode) {
+        public Boolean walkLike(Tree opNode, Tree colNode, Tree stringNode) {
             Object rVal = walkExpr(stringNode);
             if (!(rVal instanceof String))
                 throw new RuntimeException("LIKE operator requires String literal on right hand side.");
@@ -470,24 +469,24 @@ public class InMemoryQueryProcessor {
 
             String propVal = (String) so.getProperties().get(colRef.getPropertyId()).getFirstValue();
             String pattern = translatePattern((String) rVal); // SQL to Java
-                                                                // regex
-                                                                // syntax
+                                                              // regex
+                                                              // syntax
             Pattern p = Pattern.compile(pattern);
             return p.matcher(propVal).matches();
         }
 
         @Override
-        public boolean walkNotLike(Tree opNode, Tree colNode, Tree stringNode) {
+        public Boolean walkNotLike(Tree opNode, Tree colNode, Tree stringNode) {
             return !walkLike(opNode, colNode, stringNode);
         }
 
         @Override
-        public boolean walkContains(Tree qualNode, Tree colNode, Tree queryNode) {
+        public Boolean walkContains(Tree qualNode, Tree colNode, Tree queryNode) {
             throw new RuntimeException("Operator CONTAINS not supported in InMemory server.");
         }
 
         @Override
-        public boolean walkInFolder(Tree opNode, Tree qualNode, Tree paramNode) {
+        public Boolean walkInFolder(Tree opNode, Tree qualNode, Tree paramNode) {
             if (null != qualNode) {
                 getTableReference(qualNode);
                 // just for error checking we do not evaluate this, there is
@@ -506,7 +505,7 @@ public class InMemoryQueryProcessor {
         }
 
         @Override
-        public boolean walkInTree(Tree opNode, Tree qualNode, Tree paramNode) {
+        public Boolean walkInTree(Tree opNode, Tree qualNode, Tree paramNode) {
             if (null != qualNode) {
                 getTableReference(qualNode);
                 // just for error checking we do not evaluate this, there is

Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java?rev=1026325&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java Fri Oct 22 13:52:33 2010
@@ -0,0 +1,311 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.inmemory.query;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import org.antlr.runtime.ANTLRInputStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenSource;
+import org.antlr.runtime.TokenStream;
+import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.CommonTreeNodeStream;
+import org.antlr.runtime.tree.Tree;
+import org.apache.chemistry.opencmis.server.support.query.CalendarHelper;
+import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictLexer;
+import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser;
+import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser_CmisBaseGrammar.query_return;
+import org.apache.chemistry.opencmis.server.support.query.CmisQueryWalker;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class AbstractQueryConditionProcessor implements QueryConditionProcessor {
+
+    private static Log LOG = LogFactory.getLog(ProcessQueryTest.class);
+    abstract public void onStartProcessing(Tree whereNode);
+    abstract public void onStopProcessing();
+
+    // Compare operators
+    abstract public void onEquals(Tree eqNode, Tree leftNode, Tree rightNode);
+    abstract public void onNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
+    abstract public void onGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
+    abstract public void onGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
+    abstract public void onLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
+    abstract public void onLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
+
+    // Boolean operators
+    public void onPreNot(Tree opNode, Tree leftNode) {
+    }
+    abstract public void onNot(Tree opNode, Tree leftNode);
+    public void onPostNot(Tree opNode, Tree leftNode) {
+    }
+    public void onPreAnd(Tree opNode, Tree leftNode, Tree rightNode) {
+    }
+    abstract public void onAnd(Tree opNode, Tree leftNode, Tree rightNode);
+    public void onPostAnd(Tree opNode, Tree leftNode, Tree rightNode) {
+    }
+    public void onPreOr(Tree opNode, Tree leftNode, Tree rightNode) {
+    }
+    abstract public void onOr(Tree opNode, Tree leftNode, Tree rightNode);
+    public void onPostOr(Tree opNode, Tree leftNode, Tree rightNode) {
+    }
+
+    // Multi-value:
+    abstract public void onIn(Tree node, Tree colNode, Tree listNode);
+    abstract public void onNotIn(Tree node, Tree colNode, Tree listNode);
+    abstract public void onInAny(Tree node, Tree colNode, Tree listNode);
+    abstract public void onNotInAny(Tree node, Tree colNode, Tree listNode);
+    abstract public void onEqAny(Tree node, Tree literalNode, Tree colNode);
+
+    // Null comparisons:
+    abstract public void onIsNull(Tree nullNode, Tree colNode);
+    abstract public void onIsNotNull(Tree notNullNode, Tree colNode);
+
+    // String matching:
+    abstract public void onIsLike(Tree node, Tree colNode, Tree stringNode);
+    abstract public void onIsNotLike(Tree node, Tree colNode, Tree stringNode);
+
+    // Functions:
+    abstract public void onContains(Tree node, Tree colNode, Tree paramNode);
+    abstract public void onInFolder(Tree node, Tree colNode, Tree paramNode);
+    abstract public void onInTree(Tree node, Tree colNode, Tree paramNode);
+    abstract public void onScore(Tree node);
+
+    // convenience method because everybody needs this piece of code
+    static public CmisQueryWalker getWalker(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
+        CharStream input = new ANTLRInputStream(new ByteArrayInputStream(statement.getBytes("UTF-8")));
+        TokenSource lexer = new CmisQlStrictLexer(input);
+        TokenStream tokens = new CommonTokenStream(lexer);
+        CmisQlStrictParser parser = new CmisQlStrictParser(tokens);
+        CommonTree parserTree; // the ANTLR tree after parsing phase
+
+        query_return parsedStatement = parser.query();
+//        if (parser.errorMessage != null) {
+//            throw new RuntimeException("Cannot parse query: " + statement + " (" + parser.errorMessage + ")");
+//        }
+        parserTree = (CommonTree) parsedStatement.getTree();
+
+        CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
+        nodes.setTokenStream(tokens);
+        CmisQueryWalker walker = new CmisQueryWalker(nodes);
+        return walker;
+    }
+
+
+    // Base interface called from query parser
+    public Boolean walkPredicate(Tree whereNode) {
+        if (null != whereNode) {
+            onStartProcessing(whereNode);
+            evalWhereNode(whereNode);
+            onStopProcessing();
+        }
+        return null; // unused 
+    }
+
+    // ///////////////////////////////////////////////////////
+    // Processing the WHERE clause
+
+    protected void evalWhereNode(Tree node) {
+        // Ensure that we receive only valid tokens and nodes in the where
+        // clause:
+        LOG.debug("evaluating node: " + node.toString());
+        switch (node.getType()) {
+        case CmisQlStrictLexer.WHERE:
+            break; // ignore
+        case CmisQlStrictLexer.EQ:
+            evalWhereNode(node.getChild(0));
+            onEquals(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.NEQ:
+            evalWhereNode(node.getChild(0));
+            onNotEquals(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.GT:
+            evalWhereNode(node.getChild(0));
+            onGreaterThan(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.GTEQ:
+            evalWhereNode(node.getChild(0));
+            onGreaterOrEquals(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.LT:
+            evalWhereNode(node.getChild(0));
+            onLessThan(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.LTEQ:
+            evalWhereNode(node.getChild(0));
+            onLessOrEquals(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+
+        case CmisQlStrictLexer.NOT:
+            onPreNot(node, node.getChild(0));
+            onNot(node, node.getChild(0));
+            evalWhereNode(node.getChild(0));
+            onPostNot(node, node.getChild(0));
+            break;
+        case CmisQlStrictLexer.AND:
+            onPreAnd(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(0));
+            onAnd(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            onPostAnd(node, node.getChild(0), node.getChild(1));
+            break;
+        case CmisQlStrictLexer.OR:
+            onPreOr(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(0));
+            onOr(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            onPostOr(node, node.getChild(0), node.getChild(1));
+            break;
+
+        // Multi-value:
+        case CmisQlStrictLexer.IN:
+            evalWhereNode(node.getChild(0));
+            onIn(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.NOT_IN:
+            evalWhereNode(node.getChild(0));
+            onNotIn(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.IN_ANY:
+            evalWhereNode(node.getChild(0));
+            onInAny(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.NOT_IN_ANY:
+            evalWhereNode(node.getChild(0));
+            onNotInAny(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.EQ_ANY:
+            evalWhereNode(node.getChild(0));
+            onEqAny(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+
+        // Null comparisons:
+        case CmisQlStrictLexer.IS_NULL:
+            onIsNull(node, node.getChild(0));
+            evalWhereNode(node.getChild(0));
+            break;
+        case CmisQlStrictLexer.IS_NOT_NULL:
+            onIsNotNull(node, node.getChild(0));
+            evalWhereNode(node.getChild(0));
+            break;
+
+        // String matching
+        case CmisQlStrictLexer.LIKE:
+            evalWhereNode(node.getChild(0));
+            onIsLike(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.NOT_LIKE:
+            evalWhereNode(node.getChild(0));
+            onIsNotLike(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+
+        // Functions
+        case CmisQlStrictLexer.CONTAINS:
+            if (node.getChildCount() == 1) {
+                onContains(node, null, node.getChild(0));
+                evalWhereNode(node.getChild(0));
+            } else {
+                evalWhereNode(node.getChild(0));
+                onContains(node, node.getChild(0), node.getChild(1));
+                evalWhereNode(node.getChild(1));
+            }
+            break;
+        case CmisQlStrictLexer.IN_FOLDER:
+            if (node.getChildCount() == 1) {
+                onInFolder(node, null, node.getChild(0));
+                evalWhereNode(node.getChild(0));
+            } else {
+                evalWhereNode(node.getChild(0));
+                onInFolder(node, node.getChild(0), node.getChild(1));
+                evalWhereNode(node.getChild(1));
+            }
+            break;
+        case CmisQlStrictLexer.IN_TREE:
+            if (node.getChildCount() == 1) {
+                onInTree(node, null, node.getChild(0));
+                evalWhereNode(node.getChild(0));
+            } else {
+                evalWhereNode(node.getChild(0));
+                onInTree(node, node.getChild(0), node.getChild(1));
+                evalWhereNode(node.getChild(1));
+            }
+            break;
+        case CmisQlStrictLexer.SCORE:
+            onScore(node);
+            break;
+
+        default:
+            // do nothing;
+        }
+    }
+
+    // helper functions that are needed by most query tree walkers
+
+    protected Object onLiteral(Tree node) {
+        int type = node.getType();
+        String text = node.getText();
+        switch (type) {
+        case CmisQlStrictLexer.BOOL_LIT:
+            return Boolean.parseBoolean(node.getText());
+        case CmisQlStrictLexer.NUM_LIT:
+            if (text.contains(".") || text.contains("e") || text.contains("E"))
+                return Double.parseDouble(text);
+            else
+                return Long.parseLong(text);
+        case CmisQlStrictLexer.STRING_LIT:
+            return text.substring(1, text.length()-1);
+        case CmisQlStrictLexer.TIME_LIT:
+            GregorianCalendar gc = CalendarHelper.fromString(text.substring(text.indexOf('\'')+1, text.lastIndexOf('\'')));
+            return gc;
+        default:
+            throw new RuntimeException("Unknown literal. " + node);
+        }
+    }
+
+    protected List<Object> onLiteralList(Tree node) {
+        List<Object> res = new ArrayList<Object>(node.getChildCount());
+        for (int i=0; i<node.getChildCount(); i++) {
+            Tree literal =  node.getChild(i);
+            res.add(onLiteral(literal));
+        }
+        return res;
+    }
+
+}

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java?rev=1026325&r1=1026324&r2=1026325&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java Fri Oct 22 13:52:33 2010
@@ -49,6 +49,7 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictLexer;
 import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser;
 import org.apache.chemistry.opencmis.server.support.query.CmisQueryWalker;
+import org.apache.chemistry.opencmis.server.support.query.PredicateWalkerBase;
 import org.apache.chemistry.opencmis.server.support.query.QueryObject;
 import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser_CmisBaseGrammar.query_return;
 
@@ -57,6 +58,7 @@ public abstract class AbstractQueryTest 
     protected CommonTree parserTree; // the ANTLR tree after parsing phase
     protected CommonTree walkerTree; // the ANTLR tree after walking phase
     protected QueryObject queryObj;
+    PredicateWalkerBase predicateWalker;
     protected TypeDefinition myType, myTypeCopy, bookType;
 
     protected static final String MY_DOC_TYPE = "MyDocType";
@@ -71,8 +73,9 @@ public abstract class AbstractQueryTest 
     protected static final String ISBN_PROP = "ISBN";
     protected static final String PUB_DATE_PROP = "PublishingDate";
     
-    protected void setUp(QueryObject qo) throws Exception {
+    protected void setUp(QueryObject qo, PredicateWalkerBase pw) throws Exception {
             queryObj = qo;
+            predicateWalker = pw;
     }
 
     protected void tearDown() throws Exception {
@@ -99,7 +102,7 @@ public abstract class AbstractQueryTest 
 
     protected CmisQueryWalker traverseStatement(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
         CmisQueryWalker walker = getWalker(statement);
-        walker.query(queryObj);
+        walker.query(queryObj, predicateWalker);
         String errMsg = walker.getErrorMessageString();
         if (null != errMsg) {
             fail("Walking of statement failed with error: \n   " + errMsg + 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java?rev=1026325&r1=1026324&r2=1026325&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java Fri Oct 22 13:52:33 2010
@@ -31,7 +31,6 @@ import java.util.Map.Entry;
 import org.antlr.runtime.tree.Tree;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.TypeManagerImpl;
-import org.apache.chemistry.opencmis.server.support.query.AbstractQueryConditionProcessor;
 import org.apache.chemistry.opencmis.server.support.query.CalendarHelper;
 import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictLexer;
 import org.apache.chemistry.opencmis.server.support.query.QueryObject;
@@ -43,7 +42,7 @@ import org.junit.Test;
 
 public class ProcessQueryTest extends AbstractQueryTest {
 
-    private static Log log = LogFactory.getLog(ProcessQueryTest.class);
+    private static Log LOG = LogFactory.getLog(ProcessQueryTest.class);
 
     static private class TestQueryProcessor extends AbstractQueryConditionProcessor {
 
@@ -111,13 +110,13 @@ public class ProcessQueryTest extends Ab
 
 
        public void onStartProcessing(Tree node) {
-            log.debug("TestQueryProcessor:onStartProcessing()");
+            LOG.debug("TestQueryProcessor:onStartProcessing()");
             rulesTrackerMap.put(ON_START, counter++);
-            assertEquals(CmisQlStrictLexer.WHERE, node.getType());
+            assertEquals(CmisQlStrictLexer.WHERE, node.getParent().getType());
        }
 
        public void onStopProcessing() {
-           log.debug("TestQueryProcessor:onStopProcessing()");
+           LOG.debug("TestQueryProcessor:onStopProcessing()");
            rulesTrackerMap.put(ON_STOP, counter++);
        }
 
@@ -329,7 +328,7 @@ public class ProcessQueryTest extends Ab
            case CmisQlStrictLexer.TIME_LIT:
                return clazz==GregorianCalendar.class ?  CalendarHelper.fromString(node.getText()) : null;
            default:
-               log.error("Unknown literal. " + node);
+               LOG.error("Unknown literal. " + node);
                return null;
            }
        }
@@ -351,8 +350,8 @@ public class ProcessQueryTest extends Ab
 
         // initialize query object with type manager
         queryProcessor = new TestQueryProcessor();
-        QueryObject qo = new QueryObject(tm, queryProcessor);
-        super.setUp(qo);
+        QueryObject qo = new QueryObject(tm);
+        super.setUp(qo, queryProcessor);
     }
 
     @After
@@ -532,7 +531,6 @@ public class ProcessQueryTest extends Ab
 
     private void testStatementMultiRule(String statement, String ruleAssertion) {
         traverseStatementAndCatchExc(statement); // calls query processor
-        Tree whereRoot = getWhereTree(parserTree);
         assertTrue(queryProcessor.rulesTrackerMap.get(ruleAssertion) > 0);
     }
 

Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryConditionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryConditionProcessor.java?rev=1026325&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryConditionProcessor.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryConditionProcessor.java Fri Oct 22 13:52:33 2010
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.inmemory.query;
+
+import org.antlr.runtime.tree.Tree;
+import org.apache.chemistry.opencmis.server.support.query.PredicateWalkerBase;
+
+/**
+ * An interface used by the walker when traversing the AST from the grammar.
+ * The interface consists of callback methods that are called when a rule
+ * is processed (as part of the WHERE statement)
+ * @author Jens
+ *
+ */
+public interface QueryConditionProcessor extends PredicateWalkerBase {
+
+    void onStartProcessing(Tree whereNode);
+    void onStopProcessing();
+
+    // Compare operators
+    void onEquals(Tree eqNode, Tree leftNode, Tree rightNode);
+    void onNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
+    void onGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
+    void onGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
+    void onLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
+    void onLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
+
+    // Boolean operators
+    void onPreNot(Tree opNode, Tree leftNode);
+    void onNot(Tree opNode, Tree leftNode);
+    void onPostNot(Tree opNode, Tree leftNode);
+    void onPreAnd(Tree opNode, Tree leftNode, Tree rightNode);
+    void onAnd(Tree opNode, Tree leftNode, Tree rightNode);
+    void onPostAnd(Tree opNode, Tree leftNode, Tree rightNode);
+    void onPreOr(Tree opNode, Tree leftNode, Tree rightNode);
+    void onOr(Tree opNode, Tree leftNode, Tree rightNode);
+    void onPostOr(Tree opNode, Tree leftNode, Tree rightNode);
+
+    // Multi-value:
+    void onIn(Tree node, Tree colNode, Tree listNode);
+    void onNotIn(Tree node, Tree colNode, Tree listNode);
+    void onInAny(Tree node, Tree colNode, Tree listNode);
+    void onNotInAny(Tree node, Tree colNode, Tree listNode);
+    void onEqAny(Tree node, Tree literalNode, Tree colNode);
+
+    // Null comparisons:
+    public void onIsNull(Tree nullNode, Tree colNode);
+    public void onIsNotNull(Tree notNullNode, Tree colNode);
+
+    // String matching:
+    void onIsLike(Tree node, Tree colNode, Tree stringNode);
+    void onIsNotLike(Tree node, Tree colNode, Tree stringNode);
+
+    // Functions:
+    void onContains(Tree node, Tree colNode, Tree paramNode);
+    void onInFolder(Tree node, Tree colNode, Tree paramNode);
+    void onInTree(Tree node, Tree colNode, Tree paramNode);
+    void onScore(Tree node);
+}

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java?rev=1026325&r1=1026324&r2=1026325&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java Fri Oct 22 13:52:33 2010
@@ -51,7 +51,7 @@ public class QueryParseTest extends Abst
     @Before
     public void setUp() throws Exception {
         // initialize query object, we do not need a type manager for just testing parsing
-        super.setUp(new QueryObject(null, null));
+        super.setUp(new QueryObject(null), null);
     }
 
     @After
@@ -64,8 +64,7 @@ public class QueryParseTest extends Abst
         String statement = "SELECT SCORE() FROM cmis:document";
 
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject select = walker.queryObj;
-        List<CmisSelector> selects = select.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(1 == selects.size());
         assertTrue(selects.get(0) instanceof FunctionReference);
         FunctionReference funcRef = ((FunctionReference)selects.get(0));
@@ -76,11 +75,10 @@ public class QueryParseTest extends Abst
     public void simpleSelectTest2() throws Exception {
         String statement = "SELECT abc FROM cmis:document";
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject select = walker.queryObj;
         List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(1 == selects.size());
         // nothing should be in where references
-        assertTrue(0 == select.getWhereReferences().size());
+        assertTrue(0 == queryObj.getWhereReferences().size());
 
         ColumnReference colRef = ((ColumnReference)selects.get(0));
         assertTrue(selects.get(0) instanceof ColumnReference);
@@ -92,11 +90,10 @@ public class QueryParseTest extends Abst
     public void simpleSelectTest3() throws Exception {
         String statement = "SELECT t1.abc FROM cmis:document";
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject select = walker.queryObj;
-        List<CmisSelector> selects = select.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(1 == selects.size());
         // nothing should be in where references
-        assertTrue(0 == select.getWhereReferences().size());
+        assertTrue(0 == queryObj.getWhereReferences().size());
         assertTrue(selects.get(0) instanceof ColumnReference);
         ColumnReference colRef = ((ColumnReference)selects.get(0));
         assertEquals("t1", colRef.getTypeQueryName());
@@ -108,11 +105,10 @@ public class QueryParseTest extends Abst
     public void simpleSelectTest4() throws Exception {
         String statement = "SELECT * FROM cmis:document";
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject select = walker.queryObj;
-        List<CmisSelector> selects = select.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(1 == selects.size());
         // nothing should be in where references
-        assertTrue(0 == select.getWhereReferences().size());
+        assertTrue(0 == queryObj.getWhereReferences().size());
         ColumnReference colRef = ((ColumnReference)selects.get(0));
         assertTrue(selects.get(0) instanceof ColumnReference);
         assertEquals(null, colRef.getTypeQueryName());
@@ -125,11 +121,10 @@ public class QueryParseTest extends Abst
     public void simpleSelectTest5() throws Exception {
         String statement = "SELECT t1.* FROM cmis:document";
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject select = walker.queryObj;
-        List<CmisSelector> selects = select.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(1 == selects.size());
         // nothing should be in where references
-        assertTrue(0 == select.getWhereReferences().size());
+        assertTrue(0 == queryObj.getWhereReferences().size());
         assertTrue(selects.get(0) instanceof ColumnReference);
         ColumnReference colRef = ((ColumnReference)selects.get(0));
         assertEquals("t1", colRef.getTypeQueryName());
@@ -141,11 +136,10 @@ public class QueryParseTest extends Abst
     public void simpleSelectTest6() throws Exception {
         String statement = "SELECT t2.aaa myalias FROM cmis:document";
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject select = walker.queryObj;
-        List<CmisSelector> selects = select.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(1 == selects.size());
         // nothing should be in where references
-        assertTrue(0 == select.getWhereReferences().size());
+        assertTrue(0 == queryObj.getWhereReferences().size());
         assertTrue(selects.get(0) instanceof ColumnReference);
         ColumnReference colRef = ((ColumnReference)selects.get(0));
         assertEquals("t2", colRef.getTypeQueryName());
@@ -171,8 +165,7 @@ public class QueryParseTest extends Abst
         String statement = "SELECT * FROM MyType MyAlias";
 
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject from = walker.queryObj;
-        Map<String,String> types = from.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(1 == types.size());
         String key = types.keySet().iterator().next();
         assertEquals("MyAlias", key);
@@ -183,8 +176,7 @@ public class QueryParseTest extends Abst
     public void simpleFromTest2() throws Exception {
         String statement = "SELECT * FROM MyType";
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject from = walker.queryObj;
-        Map<String,String> types = from.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(1 == types.size());
         String key = types.keySet().iterator().next();
         assertEquals("MyType", key);
@@ -196,8 +188,7 @@ public class QueryParseTest extends Abst
     public void simpleFromTest3() throws Exception {
         String statement = "SELECT t2.aaa FROM MyType abc123";
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject from = walker.queryObj;
-        Map<String,String> types = from.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(1 == types.size());
         String key = types.keySet().iterator().next();
         assertEquals("abc123", key);
@@ -209,15 +200,14 @@ public class QueryParseTest extends Abst
         String statement = "SELECT * FROM MyType WHERE MyProp1=123";
 
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject qo = walker.queryObj;
-        List<CmisSelector> whereRefs = qo.getWhereReferences();
-        Map<Integer, CmisSelector> colRefs = qo.getColumnReferences();
+        List<CmisSelector> whereRefs = queryObj.getWhereReferences();
+        Map<Integer, CmisSelector> colRefs = queryObj.getColumnReferences();
         assertTrue(1 == whereRefs.size());
         CmisSelector value = whereRefs.iterator().next();
         assertTrue(value instanceof ColumnReference);
         assertEquals("MyProp1", ((ColumnReference)value).getPropertyQueryName());
         // only "*" should be in select references
-        assertTrue(1 == qo.getSelectReferences().size());
+        assertTrue(1 == queryObj.getSelectReferences().size());
 
         CommonTree tree = (CommonTree) walker.getTreeNodeStream().getTreeSource();
 
@@ -269,7 +259,7 @@ public class QueryParseTest extends Abst
         String statement = "SELECT * FROM MyType ORDER BY abc.def ASC";
 
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        List<SortSpec> orderBys = walker.queryObj.getOrderBys();
+        List<SortSpec> orderBys = queryObj.getOrderBys();
         assertTrue(1 == orderBys.size());
         SortSpec sp = orderBys.get(0);
         assertTrue(sp.isAscending());
@@ -283,7 +273,7 @@ public class QueryParseTest extends Abst
     public void simpleSortTest2() throws Exception {
         String statement = "SELECT * FROM MyType ORDER BY def DESC";
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        List<SortSpec> orderBys = walker.queryObj.getOrderBys();
+        List<SortSpec> orderBys = queryObj.getOrderBys();
         assertTrue(1 == orderBys.size());
         SortSpec sp = orderBys.get(0);
         assertFalse(sp.isAscending());
@@ -456,7 +446,7 @@ public class QueryParseTest extends Abst
         String statement = "SELECT * FROM MyType JOIN YourType WHERE a='1'";
 
         CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
-        QueryObject from = walker.queryObj;
+        QueryObject from = queryObj;
         Map<String,String> types = from.getTypes();
         assertTrue(2 == types.size());
     }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java?rev=1026325&r1=1026324&r2=1026325&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java Fri Oct 22 13:52:33 2010
@@ -52,7 +52,7 @@ public class QueryTypesTest extends Abst
             tm.addTypeDefinition(typeDef);
         
         // initialize query object with type manager
-        super.setUp(new QueryObject(tm, null));
+        super.setUp(new QueryObject(tm), null);
     }
 
     @After
@@ -133,10 +133,9 @@ public class QueryTypesTest extends Abst
 
     private void verifyResolveSelect(String statement) throws Exception {
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        Map<String,String> types = qo.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(1 == types.size());
-        List<CmisSelector> selects = qo.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(2 == selects.size());
         for (CmisSelector select : selects) {
             assertTrue(select instanceof ColumnReference);
@@ -151,10 +150,9 @@ public class QueryTypesTest extends Abst
         String statement = "SELECT BookType.Title, MyDocType.MyStringProp FROM BookType JOIN MyDocType WHERE BookType.ISBN = '100'"; 
         
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        Map<String,String> types = qo.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(2 == types.size());
-        List<CmisSelector> selects = qo.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(2 == selects.size());
 
         ColumnReference colRef = ((ColumnReference) selects.get(0));
@@ -171,10 +169,9 @@ public class QueryTypesTest extends Abst
         String statement = "SELECT Title, MyStringProp FROM BookType JOIN MyDocType AS MyDocAlias WHERE BookType.ISBN = '100'"; 
         
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        Map<String,String> types = qo.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(2 == types.size());
-        List<CmisSelector> selects = qo.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(2 == selects.size());
 
         ColumnReference colRef = ((ColumnReference) selects.get(0));
@@ -204,10 +201,9 @@ public class QueryTypesTest extends Abst
         String statement = "SELECT MyDocType.MyStringProp FROM MyDocTypeCopy JOIN MyDocType"; 
         
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        Map<String,String> types = qo.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(2 == types.size());
-        List<CmisSelector> selects = qo.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(1 == selects.size());
         ColumnReference colRef = ((ColumnReference) selects.get(0));
         assertEquals(myType, colRef.getTypeDefinition());
@@ -218,10 +214,9 @@ public class QueryTypesTest extends Abst
     public void resolveTypesTest11() throws Exception {
         String statement = "SELECT BookType.* FROM BookType WHERE ISBN = '100'"; 
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        Map<String,String> types = qo.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(1 == types.size());
-        List<CmisSelector> selects = qo.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(1 == selects.size());
         ColumnReference colRef = ((ColumnReference) selects.get(0));
         assertTrue(colRef.getPropertyQueryName().equals("*"));        
@@ -232,10 +227,9 @@ public class QueryTypesTest extends Abst
     public void resolveTypesTest12() throws Exception {
         String statement = "SELECT * FROM MyDocTypeCopy JOIN MyDocType"; 
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        Map<String,String> types = qo.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(2 == types.size());
-        List<CmisSelector> selects = qo.getSelectReferences();
+        List<CmisSelector> selects = queryObj.getSelectReferences();
         assertTrue(1 == selects.size());
         ColumnReference colRef = ((ColumnReference) selects.get(0));
         assertTrue(colRef.getPropertyQueryName().equals("*"));        
@@ -270,8 +264,7 @@ public class QueryTypesTest extends Abst
     public void resolveTypesWhereWithTwoFromsUnqualified() throws Exception {
         String statement = "SELECT * FROM BookType JOIN MyDocType WHERE ISBN = '100'"; 
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        List<CmisSelector> wheres = qo.getWhereReferences();
+        List<CmisSelector> wheres = queryObj.getWhereReferences();
         assertTrue(1 == wheres.size());
         for (CmisSelector where : wheres) {
             assertTrue(where instanceof ColumnReference);
@@ -285,8 +278,7 @@ public class QueryTypesTest extends Abst
     public void resolveTypesWhereWithTwoFromsQualified() throws Exception {
         String statement = "SELECT * FROM BookType JOIN MyDocType AS MyDocAlias WHERE BookType.ISBN = '100'"; 
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        List<CmisSelector> wheres = qo.getWhereReferences();
+        List<CmisSelector> wheres = queryObj.getWhereReferences();
         assertTrue(1 == wheres.size());
         for (CmisSelector where : wheres) {
             assertTrue(where instanceof ColumnReference);
@@ -301,8 +293,7 @@ public class QueryTypesTest extends Abst
     public void resolveTypesWhereWithTwoFromsQualifiedWithAlias() throws Exception {
         String statement = "SELECT * FROM BookType AS MyBookAlias JOIN MyDocType  WHERE MyBookAlias.ISBN = '100'"; 
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        List<CmisSelector> wheres = qo.getWhereReferences();
+        List<CmisSelector> wheres = queryObj.getWhereReferences();
         assertTrue(1 == wheres.size());
         for (CmisSelector where : wheres) {
             assertTrue(where instanceof ColumnReference);
@@ -314,10 +305,9 @@ public class QueryTypesTest extends Abst
 
     private void verifyResolveWhere(String statement) throws Exception {
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        Map<String,String> types = qo.getTypes();
+        Map<String,String> types = queryObj.getTypes();
         assertTrue(1 == types.size());
-        List<CmisSelector> wheres = qo.getWhereReferences();
+        List<CmisSelector> wheres = queryObj.getWhereReferences();
         assertTrue(1 == wheres.size());
         for (CmisSelector where : wheres) {
             assertTrue(where instanceof ColumnReference);
@@ -344,8 +334,7 @@ public class QueryTypesTest extends Abst
     public void resolveTypesWhereWithTwoFromsUniqueByQualifying() throws Exception {
         String statement = "SELECT * FROM MyDocTypeCopy JOIN MyDocType WHERE MyDocType.MyStringProp = '100'";         
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        List<CmisSelector> wheres = qo.getWhereReferences();
+        List<CmisSelector> wheres = queryObj.getWhereReferences();
         assertTrue(1 == wheres.size());
         for (CmisSelector where : wheres) {
             assertTrue(where instanceof ColumnReference);
@@ -359,8 +348,7 @@ public class QueryTypesTest extends Abst
     public void resolveTypesOrderBy() throws Exception {
         String statement = "SELECT Title AS TitleAlias FROM BookType WHERE Author = 'Jim' ORDER BY TitleAlias";         
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        List<SortSpec> sorts = qo.getOrderBys();
+        List<SortSpec> sorts = queryObj.getOrderBys();
         assertTrue(1 == sorts.size());
         for (SortSpec sort : sorts) {
             assertTrue(sort.getSelector() instanceof ColumnReference);
@@ -374,8 +362,7 @@ public class QueryTypesTest extends Abst
     public void resolveTypesOrderBy2() throws Exception {
         String statement = "SELECT Title AS TitleAlias FROM BookType WHERE Author = 'Jim' ORDER BY BookType.Author";         
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        List<SortSpec> sorts = qo.getOrderBys();
+        List<SortSpec> sorts = queryObj.getOrderBys();
         assertTrue(1 == sorts.size());
         for (SortSpec sort : sorts) {
             assertTrue(sort.getSelector() instanceof ColumnReference);
@@ -389,8 +376,7 @@ public class QueryTypesTest extends Abst
     public void resolveTypesOrderBy3() throws Exception {
         String statement = "SELECT Title FROM BookType WHERE ISBN < '100' ORDER BY Author";         
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        List<SortSpec> sorts = qo.getOrderBys();
+        List<SortSpec> sorts = queryObj.getOrderBys();
         assertTrue(1 == sorts.size());
         for (SortSpec sort : sorts) {
             assertTrue(sort.getSelector() instanceof ColumnReference);
@@ -404,8 +390,7 @@ public class QueryTypesTest extends Abst
     public void resolveJoinTypesSimple() throws Exception {
         String statement = "SELECT * FROM MyDocType JOIN BookType ON MyDocType.MyStringProp = BookType.Title";         
         CmisQueryWalker walker = traverseStatement(statement);
-        QueryObject qo = walker.queryObj;
-        List<CmisSelector> joins = qo.getJoinReferences();
+        List<CmisSelector> joins = queryObj.getJoinReferences();
         assertTrue(2 == joins.size());
         for (CmisSelector join : joins) {
             assertTrue(join instanceof ColumnReference);

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g?rev=1026325&r1=1026324&r2=1026325&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g Fri Oct 22 13:52:33 2010
@@ -74,9 +74,14 @@ import org.apache.chemistry.opencmis.ser
 @members {
     private static Log LOG = LogFactory.getLog(CmisQueryWalker.class);
 
-    public QueryObject queryObj;
+    private QueryObject queryObj;
+    private Tree wherePredicateTree;
     public String errorMessage;
 
+    public Tree getWherePredicateTree() {
+    	return wherePredicateTree;
+    }
+    
     @Override
     public void displayRecognitionError(String[] tokenNames,
             RecognitionException e) {
@@ -111,14 +116,16 @@ import org.apache.chemistry.opencmis.ser
     }
 }
 
-query [QueryObject qo]
+query [QueryObject qo, PredicateWalkerBase pw]
     @init {
         queryObj = qo;
     }:
     ^(SELECT select_list from_clause order_by_clause? where_clause)
     {
+        wherePredicateTree = $where_clause.tree==null ? null : $where_clause.tree.getChild(0);
         queryObj.resolveTypes();
-        queryObj.processWhereClause($where_clause.tree);
+        if (null != pw && null != $where_clause.tree)
+            pw.walkPredicate(wherePredicateTree);
     }
     ;
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractPredicateWalker.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractPredicateWalker.java?rev=1026325&r1=1026324&r2=1026325&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractPredicateWalker.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractPredicateWalker.java Fri Oct 22 13:52:33 2010
@@ -34,7 +34,7 @@ import org.apache.chemistry.opencmis.com
  */
 public abstract class AbstractPredicateWalker implements PredicateWalker {
 
-    public boolean walkPredicate(Tree node) {
+    public Boolean walkPredicate(Tree node) {
         switch (node.getType()) {
         case CmisQlStrictLexer.NOT:
             return walkNot(node, node.getChild(0));
@@ -96,22 +96,22 @@ public abstract class AbstractPredicateW
     }
 
     /** For extensibility. */
-    protected boolean walkOtherPredicate(Tree node) {
+    protected Boolean walkOtherPredicate(Tree node) {
         throw new CmisRuntimeException("Unknown node type: " + node.getType() + " (" + node.getText() + ")");
     }
 
-    public boolean walkNot(Tree opNode, Tree node) {
+    public Boolean walkNot(Tree opNode, Tree node) {
         walkPredicate(node);
         return false;
     }
 
-    public boolean walkAnd(Tree opNode, Tree leftNode, Tree rightNode) {
+    public Boolean walkAnd(Tree opNode, Tree leftNode, Tree rightNode) {
         walkPredicate(leftNode);
         walkPredicate(rightNode);
         return false;
     }
 
-    public boolean walkOr(Tree opNode, Tree leftNode, Tree rightNode) {
+    public Boolean walkOr(Tree opNode, Tree leftNode, Tree rightNode) {
         walkPredicate(leftNode);
         walkPredicate(rightNode);
         return false;
@@ -141,109 +141,109 @@ public abstract class AbstractPredicateW
         throw new CmisRuntimeException("Unknown node type: " + node.getType() + " (" + node.getText() + ")");
     }
 
-    public boolean walkEquals(Tree opNode, Tree leftNode, Tree rightNode) {
+    public Boolean walkEquals(Tree opNode, Tree leftNode, Tree rightNode) {
         walkExpr(leftNode);
         walkExpr(rightNode);
         return false;
     }
 
-    public boolean walkNotEquals(Tree opNode, Tree leftNode, Tree rightNode) {
+    public Boolean walkNotEquals(Tree opNode, Tree leftNode, Tree rightNode) {
         walkExpr(leftNode);
         walkExpr(rightNode);
         return false;
     }
 
-    public boolean walkGreaterThan(Tree opNode, Tree leftNode, Tree rightNode) {
+    public Boolean walkGreaterThan(Tree opNode, Tree leftNode, Tree rightNode) {
         walkExpr(leftNode);
         walkExpr(rightNode);
         return false;
     }
 
-    public boolean walkGreaterOrEquals(Tree opNode, Tree leftNode, Tree rightNode) {
+    public Boolean walkGreaterOrEquals(Tree opNode, Tree leftNode, Tree rightNode) {
         walkExpr(leftNode);
         walkExpr(rightNode);
         return false;
     }
 
-    public boolean walkLessThan(Tree opNode, Tree leftNode, Tree rightNode) {
+    public Boolean walkLessThan(Tree opNode, Tree leftNode, Tree rightNode) {
         walkExpr(leftNode);
         walkExpr(rightNode);
         return false;
     }
 
-    public boolean walkLessOrEquals(Tree opNode, Tree leftNode, Tree rightNode) {
+    public Boolean walkLessOrEquals(Tree opNode, Tree leftNode, Tree rightNode) {
         walkExpr(leftNode);
         walkExpr(rightNode);
         return false;
     }
 
-    public boolean walkIn(Tree opNode, Tree colNode, Tree listNode) {
+    public Boolean walkIn(Tree opNode, Tree colNode, Tree listNode) {
         walkExpr(colNode);
         walkExpr(listNode);
         return false;
     }
 
-    public boolean walkNotIn(Tree opNode, Tree colNode, Tree listNode) {
+    public Boolean walkNotIn(Tree opNode, Tree colNode, Tree listNode) {
         walkExpr(colNode);
         walkExpr(listNode);
         return false;
     }
 
-    public boolean walkInAny(Tree opNode, Tree colNode, Tree listNode) {
+    public Boolean walkInAny(Tree opNode, Tree colNode, Tree listNode) {
         walkExpr(colNode);
         walkExpr(listNode);
         return false;
     }
 
-    public boolean walkNotInAny(Tree opNode, Tree colNode, Tree listNode) {
+    public Boolean walkNotInAny(Tree opNode, Tree colNode, Tree listNode) {
         walkExpr(colNode);
         walkExpr(listNode);
         return false;
     }
 
-    public boolean walkEqAny(Tree opNode, Tree literalNode, Tree colNode) {
+    public Boolean walkEqAny(Tree opNode, Tree literalNode, Tree colNode) {
         walkExpr(literalNode);
         walkExpr(colNode);
         return false;
     }
 
-    public boolean walkIsNull(Tree opNode, Tree colNode) {
+    public Boolean walkIsNull(Tree opNode, Tree colNode) {
         walkExpr(colNode);
         return false;
     }
 
-    public boolean walkIsNotNull(Tree opNode, Tree colNode) {
+    public Boolean walkIsNotNull(Tree opNode, Tree colNode) {
         walkExpr(colNode);
         return false;
     }
 
-    public boolean walkLike(Tree opNode, Tree colNode, Tree stringNode) {
+    public Boolean walkLike(Tree opNode, Tree colNode, Tree stringNode) {
         walkExpr(colNode);
         walkExpr(stringNode);
         return false;
     }
 
-    public boolean walkNotLike(Tree opNode, Tree colNode, Tree stringNode) {
+    public Boolean walkNotLike(Tree opNode, Tree colNode, Tree stringNode) {
         walkExpr(colNode);
         walkExpr(stringNode);
         return false;
     }
 
-    public boolean walkContains(Tree opNode, Tree qualNode, Tree queryNode) {
+    public Boolean walkContains(Tree opNode, Tree qualNode, Tree queryNode) {
         if (qualNode != null)
             walkExpr(qualNode);
         walkExpr(queryNode);
         return false;
     }
 
-    public boolean walkInFolder(Tree opNode, Tree qualNode, Tree paramNode) {
+    public Boolean walkInFolder(Tree opNode, Tree qualNode, Tree paramNode) {
         if (qualNode != null)
             walkExpr(qualNode);
         walkExpr(paramNode);
         return false;
     }
 
-    public boolean walkInTree(Tree opNode, Tree qualNode, Tree paramNode) {
+    public Boolean walkInTree(Tree opNode, Tree qualNode, Tree paramNode) {
         if (qualNode != null)
             walkExpr(qualNode);
         walkExpr(paramNode);

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalker.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalker.java?rev=1026325&r1=1026324&r2=1026325&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalker.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalker.java Fri Oct 22 13:52:33 2010
@@ -31,53 +31,51 @@ import org.antlr.runtime.tree.Tree;
  * <p>
  * The method {@link walkClause} is the entry point.
  */
-public interface PredicateWalker {
+public interface PredicateWalker extends PredicateWalkerBase {
 
-    boolean walkPredicate(Tree node);
+    Boolean walkNot(Tree opNode, Tree leftNode);
 
-    boolean walkNot(Tree opNode, Tree leftNode);
+    Boolean walkAnd(Tree opNode, Tree leftNode, Tree rightNode);
 
-    boolean walkAnd(Tree opNode, Tree leftNode, Tree rightNode);
-
-    boolean walkOr(Tree opNode, Tree leftNode, Tree rightNode);
+    Boolean walkOr(Tree opNode, Tree leftNode, Tree rightNode);
 
     Object walkExpr(Tree node);
 
-    boolean walkEquals(Tree eqNode, Tree leftNode, Tree rightNode);
+    Boolean walkEquals(Tree eqNode, Tree leftNode, Tree rightNode);
 
-    boolean walkNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
+    Boolean walkNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
 
-    boolean walkGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
+    Boolean walkGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
 
-    boolean walkGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
+    Boolean walkGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
 
-    boolean walkLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
+    Boolean walkLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
 
-    boolean walkLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
+    Boolean walkLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
 
-    boolean walkIn(Tree node, Tree colNode, Tree listNode);
+    Boolean walkIn(Tree node, Tree colNode, Tree listNode);
 
-    boolean walkNotIn(Tree node, Tree colNode, Tree listNode);
+    Boolean walkNotIn(Tree node, Tree colNode, Tree listNode);
 
-    boolean walkInAny(Tree node, Tree colNode, Tree listNode);
+    Boolean walkInAny(Tree node, Tree colNode, Tree listNode);
 
-    boolean walkNotInAny(Tree node, Tree colNode, Tree listNode);
+    Boolean walkNotInAny(Tree node, Tree colNode, Tree listNode);
 
-    boolean walkEqAny(Tree node, Tree literalNode, Tree colNode);
+    Boolean walkEqAny(Tree node, Tree literalNode, Tree colNode);
 
-    boolean walkIsNull(Tree nullNode, Tree colNode);
+    Boolean walkIsNull(Tree nullNode, Tree colNode);
 
-    boolean walkIsNotNull(Tree notNullNode, Tree colNode);
+    Boolean walkIsNotNull(Tree notNullNode, Tree colNode);
 
-    boolean walkLike(Tree node, Tree colNode, Tree stringNode);
+    Boolean walkLike(Tree node, Tree colNode, Tree stringNode);
 
-    boolean walkNotLike(Tree node, Tree colNode, Tree stringNode);
+    Boolean walkNotLike(Tree node, Tree colNode, Tree stringNode);
 
-    boolean walkContains(Tree node, Tree qualNode, Tree paramNode);
+    Boolean walkContains(Tree node, Tree qualNode, Tree paramNode);
 
-    boolean walkInFolder(Tree node, Tree qualNode, Tree paramNode);
+    Boolean walkInFolder(Tree node, Tree qualNode, Tree paramNode);
 
-    boolean walkInTree(Tree node, Tree qualNode, Tree paramNode);
+    Boolean walkInTree(Tree node, Tree qualNode, Tree paramNode);
 
     Object walkList(Tree node);
 

Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalkerBase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalkerBase.java?rev=1026325&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalkerBase.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/PredicateWalkerBase.java Fri Oct 22 13:52:33 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.server.support.query;
+
+import org.antlr.runtime.tree.Tree;
+
+/**
+ * Base interface for a tree walker of a WHERE clause.
+ * <p>
+ * COntains only a single method used by the ANTLR query walker to
+ * initiate a tree walk for evaluating the query. You can inherit from
+ * this interface if you want to have your own walking mechanism
+ * <p>
+ * The method {@link walkClause} is the entry point.
+ */
+public interface PredicateWalkerBase {
+
+    Boolean walkPredicate(Tree whereNode);
+
+}

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java?rev=1026325&r1=1026324&r2=1026325&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java Fri Oct 22 13:52:33 2010
@@ -54,7 +54,6 @@ public class QueryObject {
     protected List<CmisSelector> joinReferences = new ArrayList<CmisSelector>();
     // --> Join not implemented yet
     protected Map<String, CmisSelector> colOrFuncAlias = new HashMap<String, CmisSelector>();
-    protected QueryConditionProcessor queryProcessor;
 
     // from part
     /** map from alias name to type query name */
@@ -67,7 +66,6 @@ public class QueryObject {
 
     // where part
     protected Map<Integer, CmisSelector> columnReferences = new HashMap<Integer, CmisSelector>();
-    protected Tree whereTree;
 
     // order by part
     protected List<SortSpec> sortSpecs = new ArrayList<SortSpec>();
@@ -123,9 +121,8 @@ public class QueryObject {
     public QueryObject() {
     }
 
-    public QueryObject(TypeManager tm, QueryConditionProcessor wp) {
+    public QueryObject(TypeManager tm) {
         typeMgr = tm;
-        queryProcessor = wp;
     }
 
     public Map<Integer, CmisSelector> getColumnReferences() {
@@ -293,10 +290,6 @@ public class QueryObject {
     // WHERE part
 
 
-    public Tree getWhereTree() {
-        return whereTree;
-    }
-
     public void addWhereReference(Tree node, CmisSelector reference) {
         LOG.debug("add node to where: " + System.identityHashCode(node));
 
@@ -482,172 +475,4 @@ public class QueryObject {
             return typeQueryName;
     }
 
-    public void processWhereClause(Tree whereRoot) {
-        this.whereTree = whereRoot;
-        if (null != queryProcessor && null != whereRoot) {
-            queryProcessor.onStartProcessing(whereRoot);
-            processWhereNode(whereRoot);
-            queryProcessor.onStopProcessing();
-        }
-    }
-
-    protected void processWhereNode(Tree root) {
-        int count = root.getChildCount();
-        for (int i = 0; i < count; i++) {
-            Tree child = root.getChild(i);
-            evalWhereNode(child);
-            // processWhereNode(child); // recursive descent
-        }
-    }
-
-    // ///////////////////////////////////////////////////////
-    // Processing the WHERE clause
-
-    protected void evalWhereNode(Tree node) {
-        // Ensure that we receive only valid tokens and nodes in the where
-        // clause:
-        LOG.debug("evaluating node: " + node.toString());
-        switch (node.getType()) {
-        case CmisQlStrictLexer.WHERE:
-            break; // ignore
-        case CmisQlStrictLexer.EQ:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onEquals(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.NEQ:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onNotEquals(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.GT:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onGreaterThan(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.GTEQ:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onGreaterOrEquals(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.LT:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onLessThan(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.LTEQ:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onLessOrEquals(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-
-        case CmisQlStrictLexer.NOT:
-            queryProcessor.onPreNot(node, node.getChild(0));
-            queryProcessor.onNot(node, node.getChild(0));
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onPostNot(node, node.getChild(0));
-            break;
-        case CmisQlStrictLexer.AND:
-            queryProcessor.onPreAnd(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onAnd(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            queryProcessor.onPostAnd(node, node.getChild(0), node.getChild(1));
-            break;
-        case CmisQlStrictLexer.OR:
-            queryProcessor.onPreOr(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onOr(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            queryProcessor.onPostOr(node, node.getChild(0), node.getChild(1));
-            break;
-
-        // Multi-value:
-        case CmisQlStrictLexer.IN:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onIn(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.NOT_IN:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onNotIn(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.IN_ANY:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onInAny(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.NOT_IN_ANY:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onNotInAny(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.EQ_ANY:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onEqAny(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-
-        // Null comparisons:
-        case CmisQlStrictLexer.IS_NULL:
-            queryProcessor.onIsNull(node, node.getChild(0));
-            evalWhereNode(node.getChild(0));
-            break;
-        case CmisQlStrictLexer.IS_NOT_NULL:
-            queryProcessor.onIsNotNull(node, node.getChild(0));
-            evalWhereNode(node.getChild(0));
-            break;
-
-        // String matching
-        case CmisQlStrictLexer.LIKE:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onIsLike(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-        case CmisQlStrictLexer.NOT_LIKE:
-            evalWhereNode(node.getChild(0));
-            queryProcessor.onIsNotLike(node, node.getChild(0), node.getChild(1));
-            evalWhereNode(node.getChild(1));
-            break;
-
-        // Functions
-        case CmisQlStrictLexer.CONTAINS:
-            if (node.getChildCount() == 1) {
-                queryProcessor.onContains(node, null, node.getChild(0));
-                evalWhereNode(node.getChild(0));
-            } else {
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onContains(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-            }
-            break;
-        case CmisQlStrictLexer.IN_FOLDER:
-            if (node.getChildCount() == 1) {
-                queryProcessor.onInFolder(node, null, node.getChild(0));
-                evalWhereNode(node.getChild(0));
-            } else {
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onInFolder(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-            }
-            break;
-        case CmisQlStrictLexer.IN_TREE:
-            if (node.getChildCount() == 1) {
-                queryProcessor.onInTree(node, null, node.getChild(0));
-                evalWhereNode(node.getChild(0));
-            } else {
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onInTree(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-            }
-            break;
-        case CmisQlStrictLexer.SCORE:
-            queryProcessor.onScore(node);
-            break;
-
-        default:
-            // do nothing;
-        }
-    }
 }



Mime
View raw message