jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r770284 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: ./ constraint/ join/
Date Thu, 30 Apr 2009 15:29:09 GMT
Author: jukka
Date: Thu Apr 30 15:29:09 2009
New Revision: 770284

URL: http://svn.apache.org/viewvc?rev=770284&view=rev
Log:
JCR-2092: make spi query code compatible with JCR 2.0

Update jackrabbit-core to use JCR 2.0 interfaces instead of the SPI versions

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JoinQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryObjectModelImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/Join.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JoinQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JoinQuery.java?rev=770284&r1=770283&r2=770284&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JoinQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JoinQuery.java
Thu Apr 30 15:29:09 2009
@@ -43,7 +43,7 @@
     /**
      * The join type.
      */
-    private final int joinType;
+    private final String joinType;
 
     /**
      * The QOM join condition.
@@ -72,7 +72,7 @@
      */
     public JoinQuery(MultiColumnQuery left,
                      MultiColumnQuery right,
-                     int joinType,
+                     String joinType,
                      JoinConditionImpl joinCondition,
                      SortComparatorSource scs,
                      HierarchyManager hmgr) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryObjectModelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryObjectModelImpl.java?rev=770284&r1=770283&r2=770284&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryObjectModelImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryObjectModelImpl.java
Thu Apr 30 15:29:09 2009
@@ -16,25 +16,25 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.PropertyValue;
+import javax.jcr.query.qom.QueryObjectModelConstants;
+
+import org.apache.jackrabbit.core.ItemManager;
+import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.query.PropertyTypeRegistry;
-import org.apache.jackrabbit.core.query.lucene.constraint.ConstraintBuilder;
 import org.apache.jackrabbit.core.query.lucene.constraint.Constraint;
-import org.apache.jackrabbit.spi.commons.query.jsr283.qom.QueryObjectModelConstants;
-import org.apache.jackrabbit.spi.commons.query.jsr283.qom.PropertyValue;
-import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree;
-import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.DefaultTraversingQOMTreeVisitor;
-import org.apache.jackrabbit.spi.commons.query.qom.BindVariableValueImpl;
-import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
-import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.ItemManager;
+import org.apache.jackrabbit.core.query.lucene.constraint.ConstraintBuilder;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.query.QueryResult;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.BindVariableValueImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.DefaultTraversingQOMTreeVisitor;
+import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree;
 
 /**
  * <code>QueryObjectModelImpl</code>...
@@ -116,7 +116,9 @@
         Path[] orderProps = new Path[orderings.length];
         boolean[] orderSpecs = new boolean[orderings.length];
         for (int i = 0; i < orderings.length; i++) {
-            orderSpecs[i] = orderings[i].getOrder() == QueryObjectModelConstants.ORDER_ASCENDING;
+            orderSpecs[i] = 
+                QueryObjectModelConstants.JCR_ORDER_ASCENDING.equals(
+                        orderings[i].getOrder());
             if (orderings[i].getOperand() instanceof PropertyValue) {
                 PropertyValue pv = (PropertyValue) orderings[i].getOperand();
                 orderProps[i] = PathFactoryImpl.getInstance().create(pv.getPropertyName());

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java?rev=770284&r1=770283&r2=770284&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
Thu Apr 30 15:29:09 2009
@@ -18,14 +18,14 @@
 
 import java.io.IOException;
 
-import javax.jcr.Value;
 import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.query.qom.QueryObjectModelConstants;
 
-import org.apache.jackrabbit.spi.commons.query.jsr283.qom.QueryObjectModelConstants;
-import org.apache.jackrabbit.spi.commons.query.qom.SelectorImpl;
-import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.core.query.lucene.ScoreNode;
 import org.apache.jackrabbit.core.query.lucene.Util;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.query.qom.SelectorImpl;
 
 /**
  * <code>ComparisonConstraint</code> implements a comparison constraint.
@@ -41,7 +41,7 @@
     /**
      * The operator.
      */
-    private final int operator;
+    private final String operator;
 
     /**
      * The static operand.
@@ -49,7 +49,7 @@
     private final Value operand2;
 
     /**
-     * Creates a new comparision constraint.
+     * Creates a new comparison constraint.
      *
      * @param operand1 the dynamic operand.
      * @param operator the operator.
@@ -57,7 +57,7 @@
      * @param selector the selector for this constraint.
      */
     public ComparisonConstraint(DynamicOperand operand1,
-                                int operator,
+                                String operator,
                                 Value operand2,
                                 SelectorImpl selector) {
         super(selector);
@@ -101,21 +101,20 @@
      */
     protected boolean evaluate(Value op1) throws RepositoryException {
         int c = Util.compare(op1, operand2);
-        switch (operator) {
-            case OPERATOR_EQUAL_TO:
-                return c == 0;
-            case OPERATOR_GREATER_THAN:
-                return c > 0;
-            case OPERATOR_GREATER_THAN_OR_EQUAL_TO:
-                return c >= 0;
-            case OPERATOR_LESS_THAN:
-                return c < 0;
-            case OPERATOR_LESS_THAN_OR_EQUAL_TO:
-                return c <= 0;
-            case OPERATOR_NOT_EQUAL_TO:
-                return c != 0;
-            default:
-                throw new IllegalStateException("unsupported operation: " + operator);
+        if (JCR_OPERATOR_EQUAL_TO.equals(operator)) {
+            return c == 0;
+        } else if (JCR_OPERATOR_GREATER_THAN.equals(operator)) {
+            return c > 0;
+        } else if (JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO.equals(operator)) {
+            return c >= 0;
+        } else if (JCR_OPERATOR_LESS_THAN.equals(operator)) {
+            return c < 0;
+        } else if (JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO.equals(operator)) {
+            return c <= 0;
+        } else if (JCR_OPERATOR_NOT_EQUAL_TO.equals(operator)) {
+            return c != 0;
+        } else {
+            throw new IllegalStateException("unsupported operation: " + operator);
         }
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java?rev=770284&r1=770283&r2=770284&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
Thu Apr 30 15:29:09 2009
@@ -18,23 +18,26 @@
 
 import java.util.Map;
 
+import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.PropertyType;
-import javax.jcr.ValueFormatException;
 import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
 import javax.jcr.query.InvalidQueryException;
+import javax.jcr.query.qom.QueryObjectModelConstants;
 
-import org.apache.jackrabbit.spi.commons.query.qom.ConstraintImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.QOMTreeVisitor;
+import org.apache.jackrabbit.core.query.lucene.LuceneQueryFactory;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.query.qom.AndImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.BindVariableValueImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.ChildNodeImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.ChildNodeJoinConditionImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.ComparisonImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.ConstraintImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.DescendantNodeImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.DescendantNodeJoinConditionImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.DynamicOperandImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.EquiJoinConditionImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.FullTextSearchImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.FullTextSearchScoreImpl;
@@ -45,20 +48,17 @@
 import org.apache.jackrabbit.spi.commons.query.qom.NodeLocalNameImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.NodeNameImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.NotImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.OrImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.PropertyExistenceImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.PropertyValueImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.QOMTreeVisitor;
 import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree;
 import org.apache.jackrabbit.spi.commons.query.qom.SameNodeImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.SameNodeJoinConditionImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.SelectorImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.DynamicOperandImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.StaticOperandImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.UpperCaseImpl;
-import org.apache.jackrabbit.spi.commons.query.jsr283.qom.QueryObjectModelConstants;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.core.query.lucene.LuceneQueryFactory;
 
 /**
  * <code>ConstraintBuilder</code> builds a {@link Constraint} from a tree of
@@ -173,7 +173,7 @@
 
             DynamicOperand dynOp = (DynamicOperand) op1.accept(this, staticValue);
             SelectorImpl selector = getSelector(op1.getSelectorQName());
-            if (node.getOperator() == QueryObjectModelConstants.OPERATOR_LIKE) {
+            if (QueryObjectModelConstants.JCR_OPERATOR_LIKE.equals(node.getOperator())) {
                 return new LikeConstraint(dynOp, staticValue, selector);
             } else {
                 return new ComparisonConstraint(dynOp, node.getOperator(),
@@ -230,7 +230,7 @@
         }
 
         public Object visit(LiteralImpl node, Object data) throws Exception {
-            return node.getValue();
+            return node.getLiteralValue();
         }
 
         public Object visit(LowerCaseImpl node, Object data) throws Exception {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java?rev=770284&r1=770283&r2=770284&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java
Thu Apr 30 15:29:09 2009
@@ -46,7 +46,7 @@
     public LikeConstraint(DynamicOperand operand1,
                           Value operand2,
                           SelectorImpl selector) throws RepositoryException {
-        super(operand1, OPERATOR_LIKE, operand2, selector);
+        super(operand1, JCR_OPERATOR_LIKE, operand2, selector);
         this.matcher = Util.createRegexp(operand2.getString()).matcher("");
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/Join.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/Join.java?rev=770284&r1=770283&r2=770284&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/Join.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/Join.java
Thu Apr 30 15:29:09 2009
@@ -21,6 +21,8 @@
 import java.util.Arrays;
 import java.util.LinkedList;
 
+import javax.jcr.query.qom.QueryObjectModelConstants;
+
 import org.apache.jackrabbit.core.query.lucene.MultiColumnQueryHits;
 import org.apache.jackrabbit.core.query.lucene.ScoreNode;
 import org.apache.jackrabbit.core.query.lucene.HierarchyResolver;
@@ -32,7 +34,6 @@
 import org.apache.jackrabbit.spi.commons.query.qom.EquiJoinConditionImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.ChildNodeJoinConditionImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.SameNodeJoinConditionImpl;
-import org.apache.jackrabbit.spi.commons.query.jsr283.qom.QueryObjectModelConstants;
 import org.apache.lucene.search.SortComparatorSource;
 import org.apache.lucene.index.IndexReader;
 
@@ -119,7 +120,7 @@
      */
     public static Join create(final MultiColumnQueryHits left,
                               final MultiColumnQueryHits right,
-                              final int joinType,
+                              final String joinType,
                               final JoinConditionImpl condition,
                               final IndexReader reader,
                               final HierarchyResolver resolver,
@@ -129,7 +130,8 @@
         try {
             return (Join) condition.accept(new DefaultQOMTreeVisitor() {
 
-                private boolean isInner = joinType == JOIN_TYPE_INNER;
+                private boolean isInner =
+                    JCR_JOIN_TYPE_INNER.equals(joinType);
                 private MultiColumnQueryHits outer;
                 private int outerIdx;
 
@@ -138,8 +140,10 @@
                     MultiColumnQueryHits ancestor = getSourceWithName(node.getAncestorSelectorQName(),
left, right);
                     MultiColumnQueryHits descendant = getSourceWithName(node.getDescendantSelectorQName(),
left, right);
                     Condition c;
-                    if (isInner || descendant == left && joinType == JOIN_TYPE_LEFT_OUTER
-                            || descendant == right && joinType == JOIN_TYPE_RIGHT_OUTER)
{
+                    if (isInner || descendant == left
+                            && JCR_JOIN_TYPE_LEFT_OUTER.equals(joinType)
+                            || descendant == right
+                            && JCR_JOIN_TYPE_RIGHT_OUTER.equals(joinType)) {
                         // also applies to inner join
                         // assumption: DescendantNodeJoin is more
                         // efficient than AncestorNodeJoin, TODO: verify
@@ -163,8 +167,10 @@
                     Name innerName;
                     Name innerPropName;
                     Name outerPropName;
-                    if (isInner || src1 == left && joinType == JOIN_TYPE_LEFT_OUTER
-                            || src1 == right && joinType == JOIN_TYPE_RIGHT_OUTER)
{
+                    if (isInner || src1 == left
+                            && JCR_JOIN_TYPE_LEFT_OUTER.equals(joinType)
+                            || src1 == right
+                            && JCR_JOIN_TYPE_RIGHT_OUTER.equals(joinType)) {
                         outer = src1;
                         outerIdx = getIndex(outer, node.getSelector1QName());
                         inner = src2;
@@ -190,8 +196,10 @@
                     MultiColumnQueryHits child = getSourceWithName(node.getChildSelectorQName(),
left, right);
                     MultiColumnQueryHits parent = getSourceWithName(node.getParentSelectorQName(),
left, right);
                     Condition c;
-                    if (child == left && joinType == JOIN_TYPE_LEFT_OUTER
-                            || child == right && joinType == JOIN_TYPE_RIGHT_OUTER)
{
+                    if (child == left
+                            && JCR_JOIN_TYPE_LEFT_OUTER.equals(joinType)
+                            || child == right
+                            && JCR_JOIN_TYPE_RIGHT_OUTER.equals(joinType)) {
                         outer = child;
                         outerIdx = getIndex(outer, node.getChildSelectorQName());
                         c = new ChildNodeJoin(parent, reader, resolver, node);
@@ -211,8 +219,10 @@
                     MultiColumnQueryHits src1 = getSourceWithName(node.getSelector1QName(),
left, right);
                     MultiColumnQueryHits src2 = getSourceWithName(node.getSelector2QName(),
left, right);
                     Condition c;
-                    if (isInner || src1 == left && joinType == JOIN_TYPE_LEFT_OUTER
-                            || src1 == right && joinType == JOIN_TYPE_RIGHT_OUTER)
{
+                    if (isInner || src1 == left
+                            && JCR_JOIN_TYPE_LEFT_OUTER.equals(joinType)
+                            || src1 == right
+                            && JCR_JOIN_TYPE_RIGHT_OUTER.equals(joinType)) {
                         outer = src1;
                         outerIdx = getIndex(outer, node.getSelector1QName());
                         if (node.getSelector2QPath() != null) {



Mime
View raw message