chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1444504 [2/2] - in /chemistry/opencmis/trunk: chemistry-opencmis-samples/chemistry-opencmis-queryparser/ chemistry-opencmis-samples/chemistry-opencmis-queryparser/src/ chemistry-opencmis-samples/chemistry-opencmis-queryparser/src/main/ che...
Date Sun, 10 Feb 2013 08:24:29 GMT
Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java?rev=1444504&r1=1444503&r2=1444504&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryConditionProcessor.java
Sun Feb 10 08:24:28 2013
@@ -18,118 +18,161 @@
  */
 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.chemistry.opencmis.server.support.query.PredicateWalkerBase;
 import org.apache.chemistry.opencmis.server.support.query.StringUtil;
 import org.apache.chemistry.opencmis.server.support.query.TextSearchLexer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractQueryConditionProcessor implements QueryConditionProcessor
{
+public abstract class AbstractQueryConditionProcessor implements PredicateWalkerBase {
 
     private static final Logger LOG = LoggerFactory.getLogger(ProcessQueryTest.class);
     
-    public abstract void onStartProcessing(Tree whereNode);
-    public abstract void onStopProcessing();
+    protected abstract void onStartProcessing(Tree whereNode);
+    protected abstract void onStopProcessing();
 
     // Compare operators
-    public abstract void onEquals(Tree eqNode, Tree leftNode, Tree rightNode);
-    public abstract void onNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
-    public abstract void onGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
-    public abstract void onGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
-    public abstract void onLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
-    public abstract void onLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
+    protected void onPreEquals(Tree eqNode, Tree leftNode, Tree rightNode) {        
+    }
+    protected abstract void onEquals(Tree eqNode, Tree leftNode, Tree rightNode);
+    protected void onPostEquals(Tree eqNode, Tree leftNode, Tree rightNode) {        
+    }
 
-    // Boolean operators
-    public void onPreNot(Tree opNode, Tree leftNode) {
+    protected void onPreNotEquals(Tree neNode, Tree leftNode, Tree rightNode) {        
+    }
+    protected abstract void onNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
+    protected void onPostNotEquals(Tree neNode, Tree leftNode, Tree rightNode) {        
+    }
+ 
+    protected void onPreGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode) {       

+    }
+    protected abstract void onGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
+    protected void onPostGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode) {      
 
+    }
+
+    protected void onPreGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode) {   
    
+    }
+    protected abstract void onGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
+    protected void onPostGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode) {  
     
+    }
+
+    protected void onPreLessThan(Tree ltNode, Tree leftNode, Tree rightNode)  {        
+    }
+    protected abstract void onLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
+    protected void onPostLessThan(Tree ltNode, Tree leftNode, Tree rightNode) {        
+    }
+
+    protected void onPreLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode) {     
  
+    }
+    protected abstract void onLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
+    protected void onPostLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode) {    
   
     }
-    public abstract void onNot(Tree opNode, Tree leftNode);
-    public void onPostNot(Tree opNode, Tree leftNode) {
+
+    // Boolean operators
+    protected abstract void onNot(Tree opNode, Tree leftNode);
+    protected void onPostNot(Tree opNode, Tree leftNode) {
     }
-    public void onPreAnd(Tree opNode, Tree leftNode, Tree rightNode) {
+    protected void onPreAnd(Tree opNode, Tree leftNode, Tree rightNode) {
     }
-    public abstract void onAnd(Tree opNode, Tree leftNode, Tree rightNode);
-    public void onPostAnd(Tree opNode, Tree leftNode, Tree rightNode) {
+    protected abstract void onAnd(Tree opNode, Tree leftNode, Tree rightNode);
+    protected void onPostAnd(Tree opNode, Tree leftNode, Tree rightNode) {
     }
-    public void onPreOr(Tree opNode, Tree leftNode, Tree rightNode) {
+    protected void onPreOr(Tree opNode, Tree leftNode, Tree rightNode) {
     }
-    public abstract void onOr(Tree opNode, Tree leftNode, Tree rightNode);
-    public void onPostOr(Tree opNode, Tree leftNode, Tree rightNode) {
+    protected abstract void onOr(Tree opNode, Tree leftNode, Tree rightNode);
+    protected void onPostOr(Tree opNode, Tree leftNode, Tree rightNode) {
     }
 
     // Multi-value:
-    public abstract void onIn(Tree node, Tree colNode, Tree listNode);
-    public abstract void onNotIn(Tree node, Tree colNode, Tree listNode);
-    public abstract void onInAny(Tree node, Tree colNode, Tree listNode);
-    public abstract void onNotInAny(Tree node, Tree colNode, Tree listNode);
-    public abstract void onEqAny(Tree node, Tree literalNode, Tree colNode);
+    protected void onPreIn(Tree node, Tree colNode, Tree listNode) {        
+    }
+    protected abstract void onIn(Tree node, Tree colNode, Tree listNode);
+    protected void onPostIn(Tree node, Tree colNode, Tree listNode) {        
+    }
+
+    protected void onPreNotIn(Tree node, Tree colNode, Tree listNode) {        
+    }
+    protected abstract void onNotIn(Tree node, Tree colNode, Tree listNode);
+    protected void onPostNotIn(Tree node, Tree colNode, Tree listNode) {        
+    }
+
+    protected void onPreInAny(Tree node, Tree colNode, Tree listNode) {        
+    }
+    protected abstract void onInAny(Tree node, Tree colNode, Tree listNode);
+    protected void onPostInAny(Tree node, Tree colNode, Tree listNode) {        
+    }
+
+    protected void onPreNotInAny(Tree node, Tree colNode, Tree listNode) {        
+    }
+    protected abstract void onNotInAny(Tree node, Tree literalNode, Tree colNode);
+    protected void onPostNotInAny(Tree node, Tree colNode, Tree listNode) {        
+    }
+    
+    protected void onPreEqAny(Tree node, Tree literalNode, Tree colNode) {
+    }
+    protected abstract void onEqAny(Tree node, Tree literalNode, Tree colNode);
+    protected void onPostEqAny(Tree node, Tree literalNode, Tree colNode) {        
+    }
 
     // Null comparisons:
-    public abstract void onIsNull(Tree nullNode, Tree colNode);
-    public abstract void onIsNotNull(Tree notNullNode, Tree colNode);
+    protected abstract void onIsNull(Tree nullNode, Tree colNode);
+    protected void onPostIsNull(Tree nullNode, Tree colNode) {
+    }
 
+    protected abstract void onIsNotNull(Tree notNullNode, Tree colNode);
+    protected void onPostIsNotNull(Tree notNullNode, Tree colNode) {
+    }
+    
     // String matching:
-    public abstract void onIsLike(Tree node, Tree colNode, Tree stringNode);
-    public abstract void onIsNotLike(Tree node, Tree colNode, Tree stringNode);
+    protected void onPreIsLike(Tree node, Tree colNode, Tree stringNode) {
+    }
+    protected abstract void onIsLike(Tree node, Tree colNode, Tree stringNode);
+    protected void onPostIsLike(Tree node, Tree colNode, Tree stringNode) {
+    }
 
-    // Functions:
-    public abstract void onInFolder(Tree node, Tree colNode, Tree paramNode);
-    public abstract void onInTree(Tree node, Tree colNode, Tree paramNode);
-    public abstract void onScore(Tree node);
-    
-    public void onPreTextAnd(Tree node, List<Tree> conjunctionNodes) {
+    protected void onPreIsNotLike(Tree node, Tree colNode, Tree stringNode) {
     }
-    public abstract void onTextAnd(Tree node, List<Tree> conjunctionNodes);
-    public void onPostTextAnd(Tree node, List<Tree> conjunctionNodes) {
+    protected abstract void onIsNotLike(Tree node, Tree colNode, Tree stringNode);
+    protected void onPostIsNotLike(Tree node, Tree colNode, Tree stringNode) {
     }
-    public void onPreTextOr(Tree node, List<Tree> termNodes) {
+
+    protected abstract void onInFolder(Tree node, Tree colNode, Tree paramNode);
+    protected void onBetweenInFolder(Tree node, Tree colNode, Tree paramNode) {
     }
-    public abstract void onTextOr(Tree node, List<Tree> termNodes);
-    public void onPostTextOr(Tree node, List<Tree> termNodes) {
-    }
-    public abstract void onTextMinus(Tree node, Tree notNode);
-    public abstract void onTextWord(String word);
-    public abstract void onTextPhrase(String phrase);
-
-    // convenience method because everybody needs this piece of code
-    public static 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;
+    protected void onPostInFolder(Tree node, Tree colNode, Tree paramNode) {
     }
 
+    protected abstract void onInTree(Tree node, Tree colNode, Tree paramNode);
+    protected void onBetweenInTree(Tree node, Tree colNode, Tree paramNode) {
+    }
+    protected void onPostInTree(Tree node, Tree colNode, Tree paramNode) {
+    }
+    
+    protected abstract void onScore(Tree node);
+    protected abstract void onColNode(Tree node);
+    
+    protected void onPreTextAnd(Tree node, List<Tree> conjunctionNodes) {
+    }
+    protected abstract void onTextAnd(Tree node, List<Tree> conjunctionNodes, int index);
+    protected void onPostTextAnd(Tree node, List<Tree> conjunctionNodes) {
+    }
+    protected void onPreTextOr(Tree node, List<Tree> termNodes) {
+    }
+    protected abstract void onTextOr(Tree node, List<Tree> termNodes, int index);
+    protected void onPostTextOr(Tree node, List<Tree> termNodes) {
+    }
+    protected abstract void onTextMinus(Tree node, Tree notNode);
+    protected void onPostTextMinus(Tree node, Tree notNode) {        
+    }
+    protected abstract void onTextWord(String word);
+    protected abstract void onTextPhrase(String phrase);
 
     // Base interface called from query parser
     public Boolean walkPredicate(Tree whereNode) {
@@ -144,12 +187,6 @@ public abstract class AbstractQueryCondi
     // ///////////////////////////////////////////////////////
     // Processing the WHERE clause
 
-    // default implementation for ^ains
-    public void onContains(Tree node, Tree typeNode, Tree searchExprNode) {
-        LOG.debug("evaluating text search node: " + searchExprNode);
-        evalTextSearchNode(searchExprNode);        
-    }
-
     protected void evalWhereNode(Tree node) {
         // Ensure that we receive only valid tokens and nodes in the where
         // clause:
@@ -158,38 +195,49 @@ public abstract class AbstractQueryCondi
         case CmisQlStrictLexer.WHERE:
             break; // ignore
         case CmisQlStrictLexer.EQ:
+            onPreEquals(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onEquals(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostEquals(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.NEQ:
+            onPreNotEquals(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onNotEquals(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostNotEquals(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.GT:
+            onPreGreaterThan(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onGreaterThan(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostGreaterThan(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.GTEQ:
+            onPreGreaterOrEquals(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onGreaterOrEquals(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostGreaterOrEquals(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.LT:
+            onPreLessThan(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onLessThan(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostLessThan(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.LTEQ:
+            onPreLessOrEquals(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onLessOrEquals(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostLessOrEquals(node, node.getChild(0), 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));
@@ -211,87 +259,141 @@ public abstract class AbstractQueryCondi
 
         // Multi-value:
         case CmisQlStrictLexer.IN:
+            onPreIn(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onIn(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostIn(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.NOT_IN:
+            onPreNotIn(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onNotIn(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostNotIn(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.IN_ANY:
+            onPreInAny(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onInAny(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostInAny(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.NOT_IN_ANY:
+            onPreNotInAny(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onNotInAny(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostNotInAny(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.EQ_ANY:
+            onPreEqAny(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onEqAny(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostEqAny(node, node.getChild(0), node.getChild(1));
             break;
 
         // Null comparisons:
         case CmisQlStrictLexer.IS_NULL:
             onIsNull(node, node.getChild(0));
             evalWhereNode(node.getChild(0));
+            onPostIsNull(node, node.getChild(0));
             break;
         case CmisQlStrictLexer.IS_NOT_NULL:
             onIsNotNull(node, node.getChild(0));
             evalWhereNode(node.getChild(0));
+            onPostIsNotNull(node, node.getChild(0));
             break;
 
         // String matching
         case CmisQlStrictLexer.LIKE:
+            onPreIsLike(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onIsLike(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostIsLike(node, node.getChild(0), node.getChild(1));
             break;
         case CmisQlStrictLexer.NOT_LIKE:
+            onPreIsNotLike(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(0));
             onIsNotLike(node, node.getChild(0), node.getChild(1));
             evalWhereNode(node.getChild(1));
+            onPostIsNotLike(node, node.getChild(0), node.getChild(1));
             break;
 
         // Functions
         case CmisQlStrictLexer.CONTAINS:
-            onContains(node, null, node.getChild(0));
+            Tree typeNode = node.getChildCount() == 1 ? null : node.getChild(0);
+            Tree textSearchNode = node.getChildCount() == 1 ? node.getChild(0) : node.getChild(1);
+
+            onPreContains(node, typeNode, textSearchNode);
+            if (node.getChildCount() > 1) {
+                evalWhereNode(typeNode);
+                onBetweenContains(node, typeNode, textSearchNode);
+            }
+            onContains(node, typeNode, textSearchNode);                
             break;
         case CmisQlStrictLexer.IN_FOLDER:
             if (node.getChildCount() == 1) {
                 onInFolder(node, null, node.getChild(0));
                 evalWhereNode(node.getChild(0));
+                onPostInFolder(node, null, node.getChild(0));
             } else {
-                evalWhereNode(node.getChild(0));
                 onInFolder(node, node.getChild(0), node.getChild(1));
+                evalWhereNode(node.getChild(0));
+                onBetweenInFolder(node, node.getChild(0), node.getChild(1));
                 evalWhereNode(node.getChild(1));
+                onPostInFolder(node, node.getChild(0), node.getChild(1));
             }
             break;
         case CmisQlStrictLexer.IN_TREE:
             if (node.getChildCount() == 1) {
                 onInTree(node, null, node.getChild(0));
                 evalWhereNode(node.getChild(0));
+                onPostInTree(node, null, node.getChild(0));
             } else {
-                evalWhereNode(node.getChild(0));
                 onInTree(node, node.getChild(0), node.getChild(1));
+                evalWhereNode(node.getChild(0));
+                onBetweenInTree(node, node.getChild(0), node.getChild(1));
                 evalWhereNode(node.getChild(1));
+                onPostInTree(node, node.getChild(0), node.getChild(1));
             }
             break;
         case CmisQlStrictLexer.SCORE:
             onScore(node);
             break;
-
+        case CmisQlStrictLexer.COL:
+            onColNode(node);
+            break;
+        case CmisQlStrictLexer.BOOL_LIT:
+        case CmisQlStrictLexer.NUM_LIT:
+        case CmisQlStrictLexer.STRING_LIT:
+        case CmisQlStrictLexer.TIME_LIT:
+            onLiteral(node);
+            break;
+        case CmisQlStrictLexer.IN_LIST:
+            onLiteralList(node);
+            break;
+        case CmisQlStrictLexer.ID:
+            onId(node);
+            break;
         default:
             // do nothing;
         }
     }
 
-    protected void evalTextSearchNode(Tree node) {
+    protected void onPreContains(Tree node, Tree typeNode, Tree searchExprNode) {       

+    }
+    
+    protected void onContains(Tree node, Tree typeNode, Tree searchExprNode) {
+        evalTextSearchNode(typeNode, searchExprNode);        
+    }
+    
+    protected void onBetweenContains(Tree node, Tree typeNode, Tree searchExprNode) {   
    
+    }
+
+    protected void evalTextSearchNode(Tree typeNode, Tree node) {
         // Ensure that we receive only valid tokens and nodes in the where
         // clause:
         LOG.debug("evaluating node: " + node.toString());
@@ -299,21 +401,27 @@ public abstract class AbstractQueryCondi
         case TextSearchLexer.TEXT_AND:
             List<Tree> children = getChildrenAsList(node);
             onPreTextAnd(node, children);
-            for (Tree child : children)
-                evalTextSearchNode(child);
-            onTextAnd(node, children);
+            int i=0;
+            for (Tree child : children) {
+                evalTextSearchNode(typeNode, child);
+                onTextAnd(node, children, i++);
+            }
             onPostTextAnd(node, children);
             break;
         case TextSearchLexer.TEXT_OR:
             children = getChildrenAsList(node);
             onPreTextOr(node, children);
-            for (Tree child : children)
-                evalTextSearchNode(child);
-            onTextOr(node, children);
+            int j=0;
+            for (Tree child : children) {
+                evalTextSearchNode(typeNode, child);
+                onTextOr(node, children, j++);
+            }
             onPostTextOr(node, children);
             break;
         case TextSearchLexer.TEXT_MINUS:
             onTextMinus(node, node.getChild(0));
+            evalTextSearchNode(typeNode, node.getChild(0));
+            onPostTextMinus(node, node.getChild(0));
             break;
         case TextSearchLexer.TEXT_SEARCH_PHRASE_STRING_LIT:
             onTextPhrase(onTextLiteral(node));
@@ -326,7 +434,7 @@ public abstract class AbstractQueryCondi
         
     // helper functions that are needed by most query tree walkers
 
-    protected Object onLiteral(Tree node) {
+    protected Object getLiteral(Tree node) {
         int type = node.getType();
         String text = node.getText();
         switch (type) {
@@ -347,6 +455,14 @@ public abstract class AbstractQueryCondi
             throw new RuntimeException("Unknown literal. " + node);
         }
     }
+
+    protected Object onLiteral(Tree node) {
+        return getLiteral(node);
+    }
+    
+    protected String onId(Tree node) {
+        return node.getText();
+    }
     
     protected String onTextLiteral(Tree node) {
         int type = node.getType();
@@ -359,14 +475,13 @@ public abstract class AbstractQueryCondi
         default:
             throw new RuntimeException("Unknown text 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));
+            res.add(getLiteral(literal));
         }
         return res;
     }

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java?rev=1444504&r1=1444503&r2=1444504&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java
Sun Feb 10 08:24:28 2013
@@ -331,14 +331,14 @@ public class ProcessQueryTest extends Ab
        }
 
        @Override
-       public void onTextAnd(Tree node, List<Tree> conjunctionNodes) {
+       public void onTextAnd(Tree node, List<Tree> conjunctionNodes, int index) {
            assertEquals(TextSearchLexer.TEXT_AND, node.getType());
            assertTrue(conjunctionNodes.size() >= 2);
            rulesTrackerMap.put(ON_TEXT_AND, counter++);
        }
 
        @Override
-       public void onTextOr(Tree node, List<Tree> termNodes) {
+       public void onTextOr(Tree node, List<Tree> termNodes, int index) {
            assertEquals(TextSearchLexer.TEXT_OR, node.getType());
            assertTrue(termNodes.size() >= 2);
            rulesTrackerMap.put(ON_TEXT_OR, counter++);
@@ -402,6 +402,10 @@ public class ProcessQueryTest extends Ab
            }
        }
 
+        @Override
+        public void onColNode(Tree node) {
+        }
+
     }
 
     private TypeManagerImpl tm;

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractPredicateWalker.java?rev=1444504&r1=1444503&r2=1444504&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractPredicateWalker.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractPredicateWalker.java
Sun Feb 10 08:24:28 2013
@@ -90,11 +90,35 @@ public abstract class AbstractPredicateW
             } else {
                 return walkInTree(node, node.getChild(0), node.getChild(1));
             }
+        case CmisQlStrictLexer.BOOL_LIT:
+            walkBoolean(node);
+            return false;
+        case CmisQlStrictLexer.NUM_LIT:
+            walkNumber(node);
+            return false;
+        case CmisQlStrictLexer.STRING_LIT:
+            walkString(node);
+            return false;
+        case CmisQlStrictLexer.TIME_LIT:
+            walkTimestamp(node);
+            return false;
+        case CmisQlStrictLexer.IN_LIST:
+            walkList(node);
+            return false;
+        case CmisQlStrictLexer.COL:
+            walkCol(node);
+            return false;
+        case CmisQlStrictLexer.ID:
+            walkId(node);
+            return false;
+        case CmisQlStrictLexer.SCORE:
+            return walkScore(node);
         default:
             return walkOtherPredicate(node);
         }
     }
 
+
     /** For extensibility. */
     protected Boolean walkOtherPredicate(Tree node) {
         throw new CmisRuntimeException("Unknown node type: " + node.getType() + " (" + node.getText()
+ ")");
@@ -335,4 +359,9 @@ public abstract class AbstractPredicateW
     protected Boolean walkTextPhrase(Tree node) {
         return null;
     }
+    
+    protected Boolean walkScore(Tree node) {
+       return false;        
+    }
+
 }



Mime
View raw message