jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r381292 - in /incubator/jackrabbit/trunk/jackrabbit: applications/test/repository/nodetypes/ src/main/java/org/apache/jackrabbit/core/query/lucene/ src/test/java/org/apache/jackrabbit/core/query/
Date Mon, 27 Feb 2006 08:58:20 GMT
Author: mreutegg
Date: Mon Feb 27 00:58:19 2006
New Revision: 381292

URL: http://svn.apache.org/viewcvs?rev=381292&view=rev
Log:
JCR-327: Mixins as supertypes do not appear to be queryable
- also search for mixins that extend the mixin of the element test

Added:
    incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
  (with props)
Modified:
    incubator/jackrabbit/trunk/jackrabbit/applications/test/repository/nodetypes/custom_nodetypes.xml
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java

Modified: incubator/jackrabbit/trunk/jackrabbit/applications/test/repository/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/applications/test/repository/nodetypes/custom_nodetypes.xml?rev=381292&r1=381291&r2=381292&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/applications/test/repository/nodetypes/custom_nodetypes.xml
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/applications/test/repository/nodetypes/custom_nodetypes.xml
Mon Feb 27 00:58:19 2006
@@ -244,5 +244,17 @@
     </childNodeDefinition>
   </nodeType>  
 
+  
+  <!-- ======================================================== -->
+  <!-- Node type definitions only required for jackrabbit core  -->
+  <!-- (internal) test cases.                                   -->
+  <!-- ======================================================== -->
+  
+  <!-- Defines a mixin node type that extends mix:referenceable -->
+  <nodeType isMixin="true" name="test:referenceable" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>mix:referenceable</supertype>
+    </supertypes>
+  </nodeType>
 </nodeTypes>
 

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java?rev=381292&r1=381291&r2=381292&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
Mon Feb 27 00:58:19 2006
@@ -271,16 +271,20 @@
             NodeTypeIterator allTypes = ntMgr.getAllNodeTypes();
             while (allTypes.hasNext()) {
                 NodeType nt = allTypes.nextNodeType();
-                // only interested in types that can be used to create nodes
-                if (nt.isMixin()) {
-                    continue;
-                }
                 NodeType[] superTypes = nt.getSupertypes();
                 if (Arrays.asList(superTypes).contains(base)) {
                     String ntName = nsMappings.translatePropertyName(nt.getName(),
                             session.getNamespaceResolver());
-                    Term t = new Term(FieldNames.PROPERTIES,
-                            FieldNames.createNamedValue(primaryTypeField, ntName));
+                    Term t;
+                    if (nt.isMixin()) {
+                        // search on jcr:mixinTypes
+                        t = new Term(FieldNames.PROPERTIES,
+                                FieldNames.createNamedValue(mixinTypesField, ntName));
+                    } else {
+                        // search on jcr:primaryType
+                        t = new Term(FieldNames.PROPERTIES,
+                                FieldNames.createNamedValue(primaryTypeField, ntName));
+                    }
                     terms.add(t);
                 }
             }

Added: incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java?rev=381292&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
(added)
+++ incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
Mon Feb 27 00:58:19 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.core.query;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import java.io.ByteArrayInputStream;
+import java.util.Calendar;
+
+/**
+ * Tests if mixin types are queried correctly when using element test: element()
+ */
+public class MixinTest extends AbstractQueryTest {
+
+    public void testBuiltInMixin() throws RepositoryException {
+        // nt:resoure is referenceable by its node type definition
+        Node n1 = testRootNode.addNode("n1", "nt:resource");
+        n1.setProperty("jcr:data", new ByteArrayInputStream("hello world".getBytes()));
+        n1.setProperty("jcr:lastModified", Calendar.getInstance());
+        n1.setProperty("jcr:mimeType", "application/octet-stream");
+
+        // assign mix:referenceable to arbitrary node
+        Node n2 = testRootNode.addNode("n2");
+        n2.addMixin("mix:referenceable");
+
+        // make node referenceable using a mixin that extends from mix:referenceable
+        Node n3 = testRootNode.addNode("n3");
+        n3.addMixin("test:referenceable");
+
+        testRootNode.save();
+
+        String query = testPath + "//element(*, mix:referenceable)";
+        executeXPathQuery(query, new Node[]{n1, n2, n3});
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message