chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1082900 - /chemistry/site/trunk/content/java/how-to/how-to-process-query.mdtext
Date Fri, 18 Mar 2011 13:06:18 GMT
Author: jens
Date: Fri Mar 18 13:06:18 2011
New Revision: 1082900

URL: http://svn.apache.org/viewvc?rev=1082900&view=rev
Log:
add one more section to test 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=1082900&r1=1082899&r2=1082900&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 13:06:18
2011
@@ -123,3 +123,51 @@ your walker:
 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.
+



Mime
View raw message