You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2011/03/18 13:58:13 UTC

svn commit: r1082898 - /chemistry/site/trunk/content/java/how-to/how-to-process-query.mdtext

Author: jens
Date: Fri Mar 18 12:58:12 2011
New Revision: 1082898

URL: http://svn.apache.org/viewvc?rev=1082898&view=rev
Log:
Trying to debug failing page

Modified:
    chemistry/site/trunk/content/java/how-to/how-to-process-query.mdtext

Modified: chemistry/site/trunk/content/java/how-to/how-to-process-query.mdtext
URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/how-to/how-to-process-query.mdtext?rev=1082898&r1=1082897&r2=1082898&view=diff
==============================================================================
--- chemistry/site/trunk/content/java/how-to/how-to-process-query.mdtext (original)
+++ chemistry/site/trunk/content/java/how-to/how-to-process-query.mdtext Fri Mar 18 12:58:12 2011
@@ -80,107 +80,3 @@ Note: There is currently no predefined w
 you need to support JOINS you have to build your own walker for this part
 as outlined in the previous section.
 
-## Using QueryObject
-
-The class `QueryObject` provides all the basic functionality for resolving
-types and properties and performs common validation tasks. The `QueryObject`
-processes the `SELECT` and `FROM` parts as well as all property references from
-the `WHERE` part. It maintains a list of Java objects and interface that you
-can use to access the property and type definitions given your current
-position in the statement. For an example refer to the class
-`StoreManagerImpl` of the InMemory Server and method `query()`.
-To be able to use this object `QueryObj` needs to get access to the types contained in your
-repository. For this purpose you need to pass an interface to a `TypeManager`
-as input parameter. The second parameter is your query walker implementing
-`IQueryConditionProcessor`. Your code will typically look like this:
-
-    :::java
-    TypeManager tm = new MyTypeManager(); // implements interface TypeManager
-    
-    IQueryConditionProcessor myWalker = new MyWalker();
-                             // implements interface IQueryConditionProcessor
-                             // or extends AbstractQueryConditionProcessor
-    
-    queryObj = new QueryObject(tm, myWalker);
-
-
-`queryObj` then will process the statement and call the interface methods of
-your walker:
-
-    :::java
-    try {
-    
-        CmisQueryWalker walker = QueryObject.getWalker(statement);
-        walker.query(queryObj);
-    
-    } catch (RecognitionException e) {
-        throw new RuntimeException("Walking of statement failed with RecognitionException error:\n " + e);
-    } catch (Exception e) {
-        throw new RuntimeException("Walking of statement failed with exception:\n " + e);
-    }
-
-
-After this method returns you may for example ask your walker object
-`myWalker` for the generated SQL string.
-
-## Processing a node and referencing types and properties
-
-While traversing the tree you often will need to access the property and
-type definitions that are referenced in the where clause. The `QueryObject`
-provides the necessary information for resolving the references. For
-example the statement
-
-    `... WHERE x < 123`
-
-
-will result in calling the method `onLessThan()` in your walker callback
-implementation:
-
-    :::java
-    public void onLessThan(Tree ltNode, Tree leftNode, Tree rightNode) {
-    
-        Object rVal = onLiteral(rightChild);
-        ColumnReference colRef;
-    
-        CmisSelector sel = queryObj.getColumnReference(columnNode
-			     .getTokenStartIndex());
-    
-        if (null == sel)
-           throw new RuntimeException("Unknown property query name " +
-		          columnNode.getChild(0));
-        else if (sel instanceof ColumnReference)
-           colRef = (ColumnReference) sel;
-    
-    
-       TypeDefinition td = colRef.getTypeDefinition();
-       PropertyDefinition pd =
-           td.getPropertyDefinitions().get(colRef.getPropertyId());
-    
-    
-       // … process the statement, for example append it to a WHERE
-       // in your generated SQL statement.
-    }
-
-
-The right child node is a literal and you will get an Integer object with
-value 123. The left node is a reference to property and
-`getColumnReference()` will either give you a function (currently the only
-supported function is `SCORE()`) or a reference to a property in a type of
-your type system. The query object maintains several maps to resolve
-references. The key to the map is always the token index in the incoming
-token stream (an integer value). You can get the token index for each node
-by calling `getTokenStartIndex()` on the node.
-
-## Building the result list
-
-After processing the query an `ObjectList` has to be returned containing the
-requested properties and function results. You can ask the query object for
-the requested information:
-
-    :::java
-    Map props = queryObj.getRequestedProperties();
-    Map funcs = queryObj.getRequestedFuncs();
-
-
-Key of the map is the query name and value is the alias if an alias was
-used in the statement or the query name otherwise.