jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r781369 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/s...
Date Wed, 03 Jun 2009 13:33:47 GMT
Author: mreutegg
Date: Wed Jun  3 13:33:46 2009
New Revision: 781369

URL: http://svn.apache.org/viewvc?rev=781369&view=rev
Log:
JCR-2076: JSR 283: Joins
- columns

Added:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/RowTest.java   (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiColumnQueryResult.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.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/QueryResultImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingleColumnQueryResult.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ColumnImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiColumnQueryResult.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiColumnQueryResult.java?rev=781369&r1=781368&r2=781369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiColumnQueryResult.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiColumnQueryResult.java Wed Jun  3 13:33:46 2009
@@ -23,8 +23,8 @@
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.security.AccessManager;
-import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
 
 /**
  * <code>MultiColumnQueryResult</code> implements a query result that executes
@@ -44,14 +44,14 @@
                                   AbstractQueryImpl queryImpl,
                                   MultiColumnQuery query,
                                   SpellSuggestion spellSuggestion,
-                                  Name[] selectProps,
+                                  ColumnImpl[] columns,
                                   Path[] orderProps,
                                   boolean[] orderSpecs,
                                   boolean documentOrder,
                                   long offset,
                                   long limit) throws RepositoryException {
         super(index, itemMgr, session, accessMgr, queryImpl, spellSuggestion,
-                selectProps, orderProps, orderSpecs, documentOrder, offset, limit);
+                columns, orderProps, orderSpecs, documentOrder, offset, limit);
         this.query = query;
         // if document order is requested get all results right away
         getResults(docOrder ? Integer.MAX_VALUE : index.getResultFetchSize());

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java?rev=781369&r1=781368&r2=781369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java Wed Jun  3 13:33:46 2009
@@ -16,14 +16,14 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.Map;
+import java.util.LinkedHashMap;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.QueryObjectModelFactory;
 
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
@@ -42,6 +42,7 @@
 import org.apache.jackrabbit.spi.commons.query.QueryNodeFactory;
 import org.apache.jackrabbit.spi.commons.query.QueryParser;
 import org.apache.jackrabbit.spi.commons.query.QueryRootNode;
+import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
 import org.apache.lucene.search.Query;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -131,21 +132,27 @@
         return new SingleColumnQueryResult(index, itemMgr,
                 session, session.getAccessManager(),
                 this, query, new SpellSuggestion(index.getSpellChecker(), root),
-                getSelectProperties(), orderProperties, ascSpecs,
+                getColumns(), orderProperties, ascSpecs,
                 getRespectDocumentOrder(), offset, limit);
     }
 
     /**
-     * Returns the select properties for this query.
+     * Returns the columns for this query.
      *
-     * @return array of select property names.
+     * @return array of columns.
      * @throws RepositoryException if an error occurs.
      */
-    protected Name[] getSelectProperties() throws RepositoryException {
-        // get select properties
-        List selectProps = new ArrayList();
-        selectProps.addAll(Arrays.asList(root.getSelectProperties()));
-        if (selectProps.size() == 0) {
+    protected ColumnImpl[] getColumns() throws RepositoryException {
+        QueryObjectModelFactory qomFactory = session.getWorkspace().getQueryManager().getQOMFactory();
+        // get columns
+        Map<Name, ColumnImpl> columns = new LinkedHashMap<Name, ColumnImpl>();
+        for (Name name : root.getSelectProperties()) {
+            String pn = session.getJCRName(name);
+            ColumnImpl col = (ColumnImpl) qomFactory.column(
+                    session.getJCRName(DEFAULT_SELECTOR_NAME), pn, pn);
+            columns.put(name, col);
+        }
+        if (columns.size() == 0) {
             // use node type constraint
             LocationStepQueryNode[] steps = root.getLocationNode().getPathSteps();
             final Name[] ntName = new Name[1];
@@ -165,23 +172,23 @@
             }
             NodeTypeImpl nt = session.getNodeTypeManager().getNodeType(ntName[0]);
             PropertyDefinition[] propDefs = nt.getPropertyDefinitions();
-            for (int i = 0; i < propDefs.length; i++) {
-                PropertyDefinitionImpl propDef = (PropertyDefinitionImpl) propDefs[i];
+            for (PropertyDefinition pd : propDefs) {
+                PropertyDefinitionImpl propDef = (PropertyDefinitionImpl) pd;
                 if (!propDef.definesResidual() && !propDef.isMultiple()) {
-                    selectProps.add(propDef.getQName());
+                    columns.put(propDef.getQName(), columnForName(propDef.getQName()));
                 }
             }
         }
 
         // add jcr:path and jcr:score if not selected already
-        if (!selectProps.contains(NameConstants.JCR_PATH)) {
-            selectProps.add(NameConstants.JCR_PATH);
+        if (!columns.containsKey(NameConstants.JCR_PATH)) {
+            columns.put(NameConstants.JCR_PATH, columnForName(NameConstants.JCR_PATH));
         }
-        if (!selectProps.contains(NameConstants.JCR_SCORE)) {
-            selectProps.add(NameConstants.JCR_SCORE);
+        if (!columns.containsKey(NameConstants.JCR_SCORE)) {
+            columns.put(NameConstants.JCR_SCORE, columnForName(NameConstants.JCR_SCORE));
         }
 
-        return (Name[]) selectProps.toArray(new Name[selectProps.size()]);
+        return columns.values().toArray(new ColumnImpl[columns.size()]);
     }
 
     /**
@@ -195,4 +202,18 @@
         return this.root.needsSystemTree();
     }
 
+    /**
+     * Returns a column for the given property name and the default selector
+     * name.
+     *
+     * @param propertyName the name of the property as well as the column.
+     * @return a column.
+     * @throws RepositoryException if an error occurs while creating the column.
+     */
+    protected ColumnImpl columnForName(Name propertyName) throws RepositoryException {
+        QueryObjectModelFactory qomFactory = session.getWorkspace().getQueryManager().getQOMFactory();
+        String name = session.getJCRName(propertyName);
+        return (ColumnImpl) qomFactory.column(
+                session.getJCRName(DEFAULT_SELECTOR_NAME), name, name);
+    }
 }

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=781369&r1=781368&r2=781369&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 Wed Jun  3 13:33:46 2009
@@ -16,18 +16,25 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
+import java.util.List;
+import java.util.ArrayList;
+
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.PropertyValue;
 import javax.jcr.query.qom.QueryObjectModelConstants;
+import javax.jcr.query.qom.QueryObjectModelFactory;
 
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
+import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.core.query.PropertyTypeRegistry;
 import org.apache.jackrabbit.core.query.lucene.constraint.Constraint;
 import org.apache.jackrabbit.core.query.lucene.constraint.ConstraintBuilder;
-import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.BindVariableValueImpl;
@@ -35,6 +42,7 @@
 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;
+import org.apache.jackrabbit.spi.commons.query.qom.SelectorImpl;
 
 /**
  * <code>QueryObjectModelImpl</code>...
@@ -106,10 +114,25 @@
         }
 
 
-        ColumnImpl[] columns = qomTree.getColumns();
-        Name[] selectProps = new Name[columns.length];
-        for (int i = 0; i < columns.length; i++) {
-            selectProps[i] = columns[i].getPropertyQName();
+        List<ColumnImpl> columns = new ArrayList<ColumnImpl>();
+        // expand columns without name
+        for (ColumnImpl column : qomTree.getColumns()) {
+            if (column.getColumnName() == null) {
+                QueryObjectModelFactory qomFactory = session.getWorkspace().getQueryManager().getQOMFactory();
+                NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
+                SelectorImpl selector = qomTree.getSelector(column.getSelectorQName());
+                NodeTypeImpl nt = ntMgr.getNodeType(selector.getNodeTypeQName());
+                for (PropertyDefinition pd : nt.getPropertyDefinitions()) {
+                    PropertyDefinitionImpl propDef = (PropertyDefinitionImpl) pd;
+                    if (!propDef.definesResidual() && !propDef.isMultiple()) {
+                        String sn = selector.getSelectorName();
+                        String pn = propDef.getName();
+                        columns.add((ColumnImpl) qomFactory.column(sn, pn, sn + "." + pn));
+                    }
+                }
+            } else {
+                columns.add(column);
+            }
         }
         OrderingImpl[] orderings = qomTree.getOrderings();
         // TODO: there are many kinds of DynamicOperand that can be ordered by
@@ -130,7 +153,8 @@
         return new MultiColumnQueryResult(index, itemMgr,
                 session, session.getAccessManager(),
                 // TODO: spell suggestion missing
-                this, query, null, selectProps, orderProps, orderSpecs,
+                this, query, null, columns.toArray(new ColumnImpl[columns.size()]),
+                orderProps, orderSpecs,
                 getRespectDocumentOrder(), offset, limit);
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java?rev=781369&r1=781368&r2=781369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java Wed Jun  3 13:33:46 2009
@@ -21,11 +21,11 @@
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.ItemNotFoundException;
-import javax.jcr.NamespaceException;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.query.QueryResult;
@@ -34,6 +34,8 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.NoSuchElementException;
+import java.util.Map;
+import java.util.LinkedHashMap;
 
 /**
  * Implements the <code>QueryResult</code> interface.
@@ -76,9 +78,9 @@
     protected final SpellSuggestion spellSuggestion;
 
     /**
-     * The select properties
+     * The columns to select.
      */
-    protected final Name[] selectProps;
+    protected final Map<String, ColumnImpl> columns = new LinkedHashMap<String, ColumnImpl>();
 
     /**
      * The relative paths of properties to use for ordering the result set.
@@ -96,7 +98,7 @@
      * <p/>
      * The exact type is: <code>List&lt;ScoreNode[]></code>
      */
-    private final List resultNodes = new ArrayList();
+    private final List<ScoreNode[]> resultNodes = new ArrayList<ScoreNode[]>();
 
     /**
      * This is the raw number of results that matched the query. This number
@@ -151,7 +153,7 @@
      *                        result.
      * @param spellSuggestion the spell suggestion or <code>null</code> if none
      *                        is available.
-     * @param selectProps     the select properties of the query.
+     * @param columns         the select properties of the query.
      * @param orderProps      the relative paths of the order properties.
      * @param orderSpecs      the order specs, one for each order property
      *                        name.
@@ -161,6 +163,8 @@
      * @param offset          the offset in the total result set
      * @throws RepositoryException if an error occurs while reading from the
      *                             repository.
+     * @throws IllegalArgumentException if any of the columns does not have a
+     *                                  column name.
      */
     public QueryResultImpl(SearchIndex index,
                            ItemManager itemMgr,
@@ -168,7 +172,7 @@
                            AccessManager accessMgr,
                            AbstractQueryImpl queryImpl,
                            SpellSuggestion spellSuggestion,
-                           Name[] selectProps,
+                           ColumnImpl[] columns,
                            Path[] orderProps,
                            boolean[] orderSpecs,
                            boolean documentOrder,
@@ -180,29 +184,27 @@
         this.accessMgr = accessMgr;
         this.queryImpl = queryImpl;
         this.spellSuggestion = spellSuggestion;
-        this.selectProps = selectProps;
         this.orderProps = orderProps;
         this.orderSpecs = orderSpecs;
         this.docOrder = orderProps.length == 0 && documentOrder;
         this.offset = offset;
         this.limit = limit;
+        for (ColumnImpl column : columns) {
+            String cn = column.getColumnName();
+            if (cn == null) {
+                String msg = column + " does not have a column name";
+                throw new IllegalArgumentException(msg);
+            }
+            this.columns.put(cn, column);
+
+        }
     }
 
     /**
      * {@inheritDoc}
      */
     public String[] getColumnNames() throws RepositoryException {
-        try {
-            String[] propNames = new String[selectProps.length];
-            for (int i = 0; i < selectProps.length; i++) {
-                propNames[i] = session.getJCRName(selectProps[i]);
-            }
-            return propNames;
-        } catch (NamespaceException npde) {
-            String msg = "encountered invalid property name";
-            log.debug(msg);
-            throw new RepositoryException(msg, npde);
-        }
+        return columns.keySet().toArray(new String[columns.size()]);
     }
 
     /**
@@ -223,7 +225,7 @@
                 throw new RepositoryException(e);
             }
         }
-        return new RowIteratorImpl(getScoreNodes(), selectProps,
+        return new RowIteratorImpl(getScoreNodes(), columns,
                 selectorNames, itemMgr,
                 index.getContext().getHierarchyManager(), session, session.getValueFactory(),
                 excerptProvider, spellSuggestion);
@@ -276,7 +278,7 @@
      */
     protected void getResults(long size) throws RepositoryException {
         if (log.isDebugEnabled()) {
-            log.debug("getResults({}) limit={}", new Long(size), new Long(limit));
+            log.debug("getResults({}) limit={}", size, limit);
         }
 
         long maxResultSize = size;
@@ -297,13 +299,13 @@
             long time = System.currentTimeMillis();
             result = executeQuery(maxResultSize);
             log.debug("query executed in {} ms",
-                    new Long(System.currentTimeMillis() - time));
+                    System.currentTimeMillis() - time);
             // set selector names
             selectorNames = result.getSelectorNames();
 
             if (resultNodes.isEmpty() && offset > 0) {
                 // collect result offset into dummy list
-                collectScoreNodes(result, new ArrayList(), offset);
+                collectScoreNodes(result, new ArrayList<ScoreNode[]>(), offset);
             } else {
                 int start = resultNodes.size() + invalid + (int) offset;
                 result.skip(start);
@@ -312,7 +314,7 @@
             time = System.currentTimeMillis();
             collectScoreNodes(result, resultNodes, maxResultSize);
             log.debug("retrieved ScoreNodes in {} ms",
-                    new Long(System.currentTimeMillis() - time));
+                    System.currentTimeMillis() - time);
 
             // update numResults
             numResults = result.getSize();
@@ -342,7 +344,7 @@
      * @throws RepositoryException if an error occurs while checking access rights.
      */
     private void collectScoreNodes(MultiColumnQueryHits hits,
-                                   List collector,
+                                   List<ScoreNode[]> collector,
                                    long maxResults)
             throws IOException, RepositoryException {
         while (collector.size() < maxResults) {
@@ -371,10 +373,10 @@
      */
     private boolean isAccessGranted(ScoreNode[] nodes)
             throws RepositoryException {
-        for (int i = 0; i < nodes.length; i++) {
+        for (ScoreNode node : nodes) {
             try {
                 // TODO: rather use AccessManager.canRead(Path)
-                if (nodes[i] != null && !accessMgr.isGranted(nodes[i].getNodeId(), AccessManager.READ)) {
+                if (node != null && !accessMgr.isGranted(node.getNodeId(), AccessManager.READ)) {
                     return false;
                 }
             } catch (ItemNotFoundException e) {
@@ -540,7 +542,7 @@
                         break;
                     }
                 }
-                next = (ScoreNode[]) resultNodes.get(nextPos);
+                next = resultNodes.get(nextPos);
             }
             position++;
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java?rev=781369&r1=781368&r2=781369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java Wed Jun  3 13:33:46 2009
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.query.lucene;
 
 import org.apache.jackrabbit.core.NodeImpl;
-import org.apache.jackrabbit.core.PropertyImpl;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.HierarchyManager;
@@ -30,6 +29,7 @@
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
 import org.apache.jackrabbit.util.ISO9075;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
@@ -46,11 +46,10 @@
 import javax.jcr.query.Row;
 import javax.jcr.query.RowIterator;
 import java.util.Arrays;
-import java.util.HashSet;
 import java.util.NoSuchElementException;
-import java.util.Set;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.io.IOException;
 
 /**
@@ -87,19 +86,15 @@
     private final ScoreNodeIterator scoreNodes;
 
     /**
-     * Array of select property names
+     * Linked map of {@link ColumnImpl columns}, indexed by their column name
+     * (String).
      */
-    private final Name[] properties;
-
-    /**
-     * Set of select property <code>Name</code>s.
-     */
-    private Set propertySet;
+    private final Map<String, ColumnImpl> columns;
 
     /**
      * List of valid selector {@link Name}s.
      */
-    private final List selectorNames = new ArrayList();
+    private final List<Name> selectorNames = new ArrayList<Name>();
 
     /**
      * The item manager of the session that executes the query.
@@ -137,29 +132,33 @@
      *
      * @param scoreNodes      a <code>ScoreNodeIterator</code> that contains the
      *                        nodes of the query result.
-     * @param properties      <code>Name</code> of the select properties.
+     * @param columns         the columns to select.
      * @param selectorNames   the selector names.
      * @param itemMgr         the item manager of the session that executes the
      *                        query.
      * @param hmgr            the hierarchy manager of the workspace.
      * @param resolver        <code>NamespaceResolver</code> of the user
      *                        <code>Session</code>.
+     * @param valueFactory    the value factory of the current session.
      * @param exProvider      the excerpt provider associated with the query
      *                        result that created this row iterator.
      * @param spellSuggestion the spell suggestion associated with the query
      *                        result or <code>null</code> if none is available.
+     * @throws NamespaceException if an error occurs while translating a JCR
+     *                            name.
      */
     RowIteratorImpl(ScoreNodeIterator scoreNodes,
-                    Name[] properties,
+                    Map<String, ColumnImpl> columns,
                     Name[] selectorNames,
                     ItemManager itemMgr,
                     HierarchyManager hmgr,
                     NamePathResolver resolver,
                     ValueFactory valueFactory,
                     ExcerptProvider exProvider,
-                    SpellSuggestion spellSuggestion) {
+                    SpellSuggestion spellSuggestion)
+            throws NamespaceException {
         this.scoreNodes = scoreNodes;
-        this.properties = properties;
+        this.columns = columns;
         this.selectorNames.addAll(Arrays.asList(selectorNames));
         this.itemMgr = itemMgr;
         this.hmgr = hmgr;
@@ -296,35 +295,10 @@
          */
         public Value[] getValues() throws RepositoryException {
             if (values == null) {
-                Value[] tmp = new Value[properties.length];
-                for (int i = 0; i < properties.length; i++) {
-                    if (getNodeImpl().hasProperty(properties[i])) {
-                        PropertyImpl prop = getNodeImpl().getProperty(properties[i]);
-                        if (!prop.getDefinition().isMultiple()) {
-                            if (prop.getDefinition().getRequiredType() == PropertyType.UNDEFINED) {
-                                tmp[i] = valueFactory.createValue(prop.getString());
-                            } else {
-                                tmp[i] = prop.getValue();
-                            }
-                        } else {
-                            // mvp values cannot be returned
-                            tmp[i] = null;
-                        }
-                    } else {
-                        // property not set or one of the following:
-                        // jcr:path / jcr:score / rep:excerpt / rep:spellcheck
-                        if (NameConstants.JCR_PATH.equals(properties[i])) {
-                            tmp[i] = valueFactory.createValue(getNodeImpl().getPath(), PropertyType.PATH);
-                        } else if (NameConstants.JCR_SCORE.equals(properties[i])) {
-                            tmp[i] = valueFactory.createValue(Math.round(score * 1000f));
-                        } else if (isExcerptFunction(properties[i])) {
-                            tmp[i] = getExcerpt();
-                        } else if (isSpellCheckFunction(properties[i])) {
-                            tmp[i] = getSpellCheckedStatement();
-                        } else {
-                            tmp[i] = null;
-                        }
-                    }
+                Value[] tmp = new Value[columns.size()];
+                int i = 0;
+                for (String columnName : columns.keySet()) {
+                    tmp[i++] = getValue(columnName);
                 }
                 values = tmp;
             }
@@ -335,45 +309,50 @@
         }
 
         /**
-         * Returns the value of the indicated  property in this <code>Row</code>.
+         * Returns the value of the indicated  column in this <code>Row</code>.
          * <p/>
-         * If <code>propertyName</code> is not among the column names of the
+         * If <code>columnbName</code> is not among the column names of the
          * query result table, an <code>ItemNotFoundException</code> is thrown.
          *
          * @return a <code>Value</code>
-         * @throws ItemNotFoundException if <code>propertyName</code> is not
+         * @throws ItemNotFoundException if <code>columnName</code> is not
          *                               among the column names of the query result table.
-         * @throws RepositoryException   if <code>propertyName</code> is not a
-         *                               valid property name.
+         * @throws RepositoryException   if another error occurs.
          */
-        public Value getValue(String propertyName) throws ItemNotFoundException, RepositoryException {
-            if (propertySet == null) {
-                // create the set first
-                Set tmp = new HashSet();
-                tmp.addAll(Arrays.asList(properties));
-                propertySet = tmp;
-            }
+        public Value getValue(String columnName) throws ItemNotFoundException, RepositoryException {
             try {
-                Name prop = resolver.getQName(propertyName);
-                if (!propertySet.contains(prop)) {
-                    if (isExcerptFunction(propertyName)) {
+                ColumnImpl col = columns.get(columnName);
+                if (col == null) {
+                    if (isExcerptFunction(columnName)) {
                         // excerpt function with parameter
-                        return getExcerpt(propertyName);
+                        return getExcerpt(columnName);
                     } else {
-                        throw new ItemNotFoundException(propertyName);
+                        throw new ItemNotFoundException(columnName);
                     }
                 }
-                if (NameConstants.JCR_PATH.equals(prop)) {
-                    QValue p = valueFactory.getQValueFactory().create(hmgr.getPath(sn[0].getNodeId()));
+                Node n = getNode(col.getSelectorName());
+                if (n == null) {
+                    return null;
+                }
+
+                if (NameConstants.JCR_PATH.equals(col.getPropertyQName())) {
+                    int idx = getSelectorIndex(col.getSelectorName());
+                    QValue p = valueFactory.getQValueFactory().create(hmgr.getPath(sn[idx].getNodeId()));
                     return valueFactory.createValue(p);
-                } else if (getNodeImpl().hasProperty(prop)) {
-                    Property p = getNodeImpl().getProperty(prop);
-                    if (p.getDefinition().getRequiredType() == PropertyType.UNDEFINED) {
-                        return valueFactory.createValue(p.getString());
+                } else if (n.hasProperty(col.getPropertyName())) {
+                    Property p = n.getProperty(col.getPropertyName());
+                    if (p.getDefinition().isMultiple()) {
+                        // mvp values cannot be returned
+                        return null;
                     } else {
-                        return p.getValue();
+                        if (p.getDefinition().getRequiredType() == PropertyType.UNDEFINED) {
+                            return valueFactory.createValue(p.getString());
+                        } else {
+                            return p.getValue();
+                        }
                     }
                 } else {
+                    Name prop = resolver.getQName(columnName);
                     // either jcr:score, rep:excerpt,
                     // rep:spellcheck or not set
                     if (NameConstants.JCR_SCORE.equals(prop)) {
@@ -387,9 +366,9 @@
                     }
                 }
             } catch (NameException e) {
-                if (isExcerptFunction(propertyName)) {
+                if (isExcerptFunction(columnName)) {
                     // excerpt function with parameter
-                    return getExcerpt(propertyName);
+                    return getExcerpt(columnName);
                 } else {
                     throw new RepositoryException(e.getMessage(), e);
                 }
@@ -427,7 +406,6 @@
         public Node getNode(String selectorName) throws RepositoryException {
             ScoreNode s = sn[getSelectorIndex(selectorName)];
             if (s == null) {
-                // TODO correct?
                 return null;
             }
             return (Node) itemMgr.getItem(s.getNodeId());
@@ -517,8 +495,7 @@
         public double getScore(String selectorName) throws RepositoryException {
             ScoreNode s = sn[getSelectorIndex(selectorName)];
             if (s == null) {
-                // TODO correct?
-                return Double.NaN;
+                return 0;
             }
             return s.getScore();
         }
@@ -644,6 +621,7 @@
         /**
          * Creates an excerpt for node with the given <code>id</code>.
          *
+         * @param id a node id.
          * @return a StringValue or <code>null</code> if the excerpt cannot be
          *         created or an error occurs.
          */
@@ -655,7 +633,7 @@
                 long time = System.currentTimeMillis();
                 String excerpt = excerptProvider.getExcerpt(id, 3, 150);
                 time = System.currentTimeMillis() - time;
-                log.debug("Created excerpt in {} ms.", new Long(time));
+                log.debug("Created excerpt in {} ms.", time);
                 if (excerpt != null) {
                     return valueFactory.createValue(excerpt);
                 } else {
@@ -669,6 +647,7 @@
         /**
          * Highlights the matching terms in the passed <code>text</code>.
          *
+         * @param text the text where to apply highlighting.
          * @return a StringValue or <code>null</code> if highlighting fails.
          */
         private Value highlight(String text) {
@@ -681,7 +660,7 @@
                 long time = System.currentTimeMillis();
                 text = hep.highlight(text);
                 time = System.currentTimeMillis() - time;
-                log.debug("Highlighted text in {} ms.", new Long(time));
+                log.debug("Highlighted text in {} ms.", time);
                 return valueFactory.createValue(text);
             } catch (IOException e) {
                 return null;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingleColumnQueryResult.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingleColumnQueryResult.java?rev=781369&r1=781368&r2=781369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingleColumnQueryResult.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingleColumnQueryResult.java Wed Jun  3 13:33:46 2009
@@ -23,8 +23,8 @@
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.security.AccessManager;
-import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
 import org.apache.lucene.search.Query;
 
 /**
@@ -45,14 +45,14 @@
                                    AbstractQueryImpl queryImpl,
                                    Query query,
                                    SpellSuggestion spellSuggestion,
-                                   Name[] selectProps,
+                                   ColumnImpl[] columns,
                                    Path[] orderProps,
                                    boolean[] orderSpecs,
                                    boolean documentOrder,
                                    long offset,
                                    long limit) throws RepositoryException {
         super(index, itemMgr, session, accessMgr, queryImpl, spellSuggestion,
-                selectProps, orderProps, orderSpecs, documentOrder, offset, limit);
+                columns, orderProps, orderSpecs, documentOrder, offset, limit);
         this.query = query;
         // if document order is requested get all results right away
         getResults(docOrder ? Integer.MAX_VALUE : index.getResultFetchSize());

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java?rev=781369&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java Wed Jun  3 13:33:46 2009
@@ -0,0 +1,129 @@
+/*
+ * 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.jackrabbit.test.api.query.qom;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.query.qom.Column;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelConstants;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.RowIterator;
+import javax.jcr.query.Row;
+
+/**
+ * <code>ColumnTest</code> contains test cases related to QOM column.
+ */
+public class ColumnTest extends AbstractQOMTest {
+
+    private static final String SELECTOR_1 = "s";
+
+    private static final String SELECTOR_2 = "p";
+
+    private static final String TEST_VALUE = "value";
+
+    /**
+     * From the spec:
+     * <p/>
+     * If propertyName is not specified, a column is included for each
+     * single-valued non-residual property of the node type specified by the
+     * nodeType attribute of the selector selectorName.
+     * <p/>
+     * [..] If propertyName is not specified,
+     * columnName must not be specified, and the included columns will be
+     * named "selectorName.propertyName".
+     */
+    public void testExpandColumnsForNodeType() throws RepositoryException {
+        QueryObjectModel qom = qomFactory.createQuery(
+                qomFactory.selector(testNodeType, SELECTOR_1),
+                null,
+                null,
+                new Column[]{qomFactory.column(SELECTOR_1, null, null)});
+        QueryResult result = qom.execute();
+        List names = new ArrayList(Arrays.asList(result.getColumnNames()));
+        NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
+        NodeType nt = ntMgr.getNodeType(testNodeType);
+        PropertyDefinition[] propDefs = nt.getPropertyDefinitions();
+        for (int i = 0; i < propDefs.length; i++) {
+            PropertyDefinition propDef = propDefs[i];
+            if (!propDef.isMultiple() && !propDef.getName().equals("*")) {
+                String columnName = SELECTOR_1 + "." + propDef.getName();
+                assertTrue("Missing column: " + columnName,
+                        names.remove(columnName));
+            }
+        }
+        for (Iterator it = names.iterator(); it.hasNext(); ) {
+            fail(it.next() + " is not a property on node type " + testNodeType);
+        }
+    }
+
+    /**
+     * From the spec:
+     * <p/>
+     * If propertyName is specified, columnName is required and used to name
+     * the column in the tabular results.
+     */
+    public void testColumnNames() throws RepositoryException {
+        QueryObjectModel qom = qomFactory.createQuery(
+                qomFactory.selector(testNodeType, SELECTOR_1),
+                null,
+                null,
+                new Column[]{qomFactory.column(SELECTOR_1, propertyName1, propertyName1)});
+        QueryResult result = qom.execute();
+        List names = new ArrayList(Arrays.asList(result.getColumnNames()));
+        assertTrue("Missing column: " + propertyName1, names.remove(propertyName1));
+        for (Iterator it = names.iterator(); it.hasNext(); ) {
+            fail(it.next() + " was not declared as a column");
+        }
+    }
+
+    public void testMultiColumn() throws RepositoryException {
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.setProperty(propertyName1, TEST_VALUE);
+        superuser.save();
+
+        String columnName1 = SELECTOR_1 + "." + propertyName1;
+        String columnName2 = SELECTOR_2 + "." + propertyName1;
+        QueryObjectModel qom = qomFactory.createQuery(
+                qomFactory.join(
+                        qomFactory.selector(testNodeType, SELECTOR_1),
+                        qomFactory.selector(testNodeType, SELECTOR_2),
+                        QueryObjectModelConstants.JCR_JOIN_TYPE_INNER,
+                        qomFactory.equiJoinCondition(SELECTOR_1, propertyName1, SELECTOR_2, propertyName1)
+                ),
+                qomFactory.descendantNode(SELECTOR_1, testRoot),
+                null,
+                new Column[]{
+                        qomFactory.column(SELECTOR_1, propertyName1, columnName1),
+                        qomFactory.column(SELECTOR_2, propertyName1, columnName2)
+                }
+        );
+        RowIterator rows = qom.execute().getRows();
+        assertTrue("empty result", rows.hasNext());
+        Row r = rows.nextRow();
+        assertEquals("unexpected value", TEST_VALUE, r.getValue(columnName1).getString());
+        assertEquals("unexpected value", TEST_VALUE, r.getValue(columnName2).getString());
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/RowTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/RowTest.java?rev=781369&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/RowTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/RowTest.java Wed Jun  3 13:33:46 2009
@@ -0,0 +1,103 @@
+/*
+ * 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.jackrabbit.test.api.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.query.RowIterator;
+import javax.jcr.query.Row;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.Column;
+
+/**
+ * <code>RowIteratorTest</code> contains test cases for {@link Row}.
+ */
+public class RowTest extends AbstractQOMTest {
+
+    private static final String TEST_VALUE = "value";
+
+    private static final String SELECTOR_NAME = "s";
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.setProperty(propertyName1, TEST_VALUE);
+        superuser.save();
+    }
+
+    public void testGetValues() throws RepositoryException {
+        Row r = getRow();
+        Value[] values = r.getValues();
+        assertEquals("wrong number of columns", 1, values.length);
+        assertEquals("property value does not match", TEST_VALUE, values[0].getString());
+    }
+
+    public void testGetValue() throws RepositoryException {
+        Row r = getRow();
+        assertEquals("property value does not match", TEST_VALUE, r.getValue(propertyName1).getString());
+    }
+
+    public void testGetNode() throws RepositoryException {
+        Row r = getRow();
+        String expectedPath = testRootNode.getNode(nodeName1).getPath();
+        assertEquals("unexpected result node", expectedPath, r.getNode().getPath());
+    }
+
+    public void testGetNodeWithSelector() throws RepositoryException {
+        Row r = getRow();
+        String expectedPath = testRootNode.getNode(nodeName1).getPath();
+        assertEquals("unexpected result node", expectedPath, r.getNode(SELECTOR_NAME).getPath());
+    }
+
+    public void testGetPath() throws RepositoryException {
+        Row r = getRow();
+        String expectedPath = testRootNode.getNode(nodeName1).getPath();
+        assertEquals("unexpected result node", expectedPath, r.getPath());
+    }
+
+    public void testGetPathWithSelector() throws RepositoryException {
+        Row r = getRow();
+        String expectedPath = testRootNode.getNode(nodeName1).getPath();
+        assertEquals("unexpected result node", expectedPath, r.getPath(SELECTOR_NAME));
+    }
+
+    public void testGetScore() throws RepositoryException {
+        Row r = getRow();
+        // value is implementation dependent, simply call method...
+        r.getScore();
+    }
+
+    public void testGetScoreWithSelector() throws RepositoryException {
+        Row r = getRow();
+        // value is implementation dependent, simply call method...
+        r.getScore(SELECTOR_NAME);
+    }
+
+    private Row getRow() throws RepositoryException {
+        QueryObjectModel qom = qomFactory.createQuery(
+                qomFactory.selector(testNodeType, SELECTOR_NAME),
+                qomFactory.descendantNode(SELECTOR_NAME, testRoot),
+                null,
+                new Column[]{qomFactory.column(SELECTOR_NAME, propertyName1, propertyName1)});
+        RowIterator rows = qom.execute().getRows();
+        assertTrue("empty result", rows.hasNext());
+        Row r = rows.nextRow();
+        assertFalse("result must not contain more than one row", rows.hasNext());
+        return r;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/RowTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java?rev=781369&r1=781368&r2=781369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java Wed Jun  3 13:33:46 2009
@@ -32,6 +32,7 @@
         suite.addTestSuite(BindVariableValueTest.class);
         suite.addTestSuite(ChildNodeJoinConditionTest.class);
         suite.addTestSuite(ChildNodeTest.class);
+        suite.addTestSuite(ColumnTest.class);
         suite.addTestSuite(DescendantNodeJoinConditionTest.class);
         suite.addTestSuite(DescendantNodeTest.class);
         suite.addTestSuite(EquiJoinConditionTest.class);
@@ -40,6 +41,7 @@
         suite.addTestSuite(NodeNameTest.class);
         suite.addTestSuite(PropertyExistenceTest.class);
         suite.addTestSuite(QueryObjectModelFactoryTest.class);
+        suite.addTestSuite(RowTest.class);
         suite.addTestSuite(SameNodeJoinConditionTest.class); 
         suite.addTestSuite(SameNodeTest.class);
         suite.addTestSuite(SelectorTest.class);

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ColumnImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ColumnImpl.java?rev=781369&r1=781368&r2=781369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ColumnImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ColumnImpl.java Wed Jun  3 13:33:46 2009
@@ -44,12 +44,12 @@
     /**
      * The name of the column.
      */
-    private final Name columnName;
+    private final String columnName;
 
     ColumnImpl(NamePathResolver resolver,
                Name selectorName,
                Name propertyName,
-               Name columnName) {
+               String columnName) {
         super(resolver);
         this.selectorName = selectorName;
         this.propertyName = propertyName;
@@ -75,18 +75,6 @@
         return propertyName;
     }
 
-    /**
-     * Gets the column name.
-     * <p/>
-     *
-     * @return the column name; must be null if <code>getPropertyName</code> is
-     *         null and non-null otherwise
-     */
-    public Name getColumnQName() {
-        return columnName;
-    }
-
-
     //---------------------------< Column >-------------------------------------
 
     /**
@@ -116,7 +104,7 @@
      *         null and non-null otherwise
      */
     public String getColumnName() {
-        return getJCRName(columnName);
+        return columnName;
     }
 
     //------------------------< AbstractQOMNode >-------------------------------

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java?rev=781369&r1=781368&r2=781369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java Wed Jun  3 13:33:46 2009
@@ -60,22 +60,12 @@
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * <code>QueryObjectModelFactoryImpl</code> implements the query object model
  * factory from JSR 283.
  */
 public abstract class QueryObjectModelFactoryImpl implements QueryObjectModelFactory {
 
-    private static final Set<String> VALID_ORDERS = new HashSet<String>();
-
-    static {
-        VALID_ORDERS.add(QueryObjectModelConstants.JCR_ORDER_ASCENDING);
-        VALID_ORDERS.add(QueryObjectModelConstants.JCR_ORDER_DESCENDING);
-    }
-
     /**
      * The name and path resolver for this QOM factory.
      */
@@ -151,8 +141,7 @@
                                         Column[] columns)
             throws InvalidQueryException, RepositoryException {
         if (source == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("source must not be null");
+            throw new InvalidQueryException("source must not be null");
         }
         if (!(source instanceof SourceImpl)) {
             throw new RepositoryException("Unknown Source implementation");
@@ -378,8 +367,7 @@
     public And and(Constraint constraint1, Constraint constraint2)
             throws InvalidQueryException, RepositoryException {
         if (constraint1 == null || constraint2 == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("Constraints must not be null");
+            throw new InvalidQueryException("Constraints must not be null");
         }
         if (constraint1 instanceof ConstraintImpl
                 && constraint2 instanceof ConstraintImpl) {
@@ -404,8 +392,7 @@
     public Or or(Constraint constraint1, Constraint constraint2)
             throws InvalidQueryException, RepositoryException {
         if (constraint1 == null || constraint2 == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("Constraints must not be null");
+            throw new InvalidQueryException("Constraints must not be null");
         }
         if (constraint1 instanceof ConstraintImpl
                 && constraint2 instanceof ConstraintImpl) {
@@ -851,8 +838,7 @@
     public BindVariableValue bindVariable(String bindVariableName)
             throws InvalidQueryException, RepositoryException {
         if (bindVariableName == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("bindVariableName must not be null");
+            throw new InvalidQueryException("bindVariableName must not be null");
         }
         try {
             return new BindVariableValueImpl(
@@ -873,8 +859,7 @@
     public Literal literal(Value value)
             throws InvalidQueryException, RepositoryException {
         if (value == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("value must not be null");
+            throw new InvalidQueryException("value must not be null");
         }
         return new LiteralImpl(resolver, value);
     }
@@ -940,7 +925,7 @@
                 throw new InvalidQueryException(e.getMessage());
             }
         }
-        return new ColumnImpl(resolver, null, propName, propName);
+        return new ColumnImpl(resolver, null, propName, propertyName);
     }
 
     /**
@@ -961,8 +946,7 @@
     public Column column(String propertyName, String columnName)                  // CM
             throws InvalidQueryException, RepositoryException {
         if (propertyName == null && columnName != null) {
-            // TODO: correct exception?
-            throw new RepositoryException(
+            throw new InvalidQueryException(
                     "columnName must be null if propertyName is null");
         }
         Name propName = null;
@@ -973,15 +957,7 @@
                 throw new InvalidQueryException(e.getMessage());
             }
         }
-        Name colName = null;
-        if (columnName != null) {
-            try {
-                colName = resolver.getQName(columnName);
-            } catch (NameException e) {
-                throw new InvalidQueryException(e.getMessage());
-            }
-        }
-        return new ColumnImpl(resolver, null, propName, colName);
+        return new ColumnImpl(resolver, null, propName, columnName);
     }
 
     /**
@@ -1003,8 +979,7 @@
                          String propertyName,
                          String columnName) throws InvalidQueryException, RepositoryException {
         if (propertyName == null && columnName != null) {
-            // TODO: correct exception?
-            throw new RepositoryException(
+            throw new InvalidQueryException(
                     "columnName must be null if propertyName is null");
         }
         Name propName = null;
@@ -1015,16 +990,8 @@
                 throw new InvalidQueryException(e.getMessage());
             }
         }
-        Name colName = null;
-        if (columnName != null) {
-            try {
-                colName = resolver.getQName(columnName);
-            } catch (NameException e) {
-                throw new InvalidQueryException(e.getMessage());
-            }
-        }
         return new ColumnImpl(resolver, checkSelectorName(selectorName),
-                propName, colName);
+                propName, columnName);
     }
 
     //------------------------------< internal >--------------------------------
@@ -1032,8 +999,7 @@
     private Name checkSelectorName(String selectorName)
             throws RepositoryException {
         if (selectorName == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("selectorName must not be null");
+            throw new InvalidQueryException("selectorName must not be null");
         }
         try {
             return resolver.getQName(selectorName);
@@ -1045,8 +1011,7 @@
     private Name checkNodeTypeName(String nodeTypeName)
             throws RepositoryException {
         if (nodeTypeName == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("nodeTypeName must not be null");
+            throw new InvalidQueryException("nodeTypeName must not be null");
         }
         try {
             return resolver.getQName(nodeTypeName);
@@ -1057,8 +1022,7 @@
 
     private Path checkPath(String path) throws RepositoryException {
         if (path == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("path must not be null");
+            throw new InvalidQueryException("path must not be null");
         }
         try {
             return resolver.getQPath(path);
@@ -1070,8 +1034,7 @@
     private Name checkPropertyName(String propertyName)
             throws RepositoryException {
         if (propertyName == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("propertyName must not be null");
+            throw new InvalidQueryException("propertyName must not be null");
         }
         try {
             return resolver.getQName(propertyName);
@@ -1083,8 +1046,7 @@
     private StaticOperand checkFullTextSearchExpression(StaticOperand fullTextSearchExpression)
             throws RepositoryException {
         if (fullTextSearchExpression == null) {
-            // TODO: correct exception?
-            throw new RepositoryException(
+            throw new InvalidQueryException(
                     "fullTextSearchExpression must not be null");
         }
         return fullTextSearchExpression;



Mime
View raw message