[dna-commits] DNA SVN: r1469 - in trunk: dna-integration-tests/src/test/java/org/jboss/dna/test/integration and 7 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Mon Dec 21 09:23:43 EST 2009


Author: bcarothers
Date: 2009-12-21 09:23:42 -0500 (Mon, 21 Dec 2009)
New Revision: 1469

Added:
   trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JdbcMetadataRepositoryTckTest.java
   trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/
   trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/configRepository.xml
   trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/repositoryOverlay.properties
   trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/meta/jdbc/connector-metajdbc.cnd
Modified:
   trunk/dna-integration-tests/pom.xml
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java
   trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_metadata.xml
   trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataLexicon.java
   trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java
Log:
DNA-37 Federate schema information from relational sources

Applied patch that adds custom node types, a JCR integration test for the connector, a provision to the integration test framework to allow for the importing of a custom node types file, and a minor fix to getProperties().

Modified: trunk/dna-integration-tests/pom.xml
===================================================================
--- trunk/dna-integration-tests/pom.xml	2009-12-21 01:36:32 UTC (rev 1468)
+++ trunk/dna-integration-tests/pom.xml	2009-12-21 14:23:42 UTC (rev 1469)
@@ -91,6 +91,12 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.jboss.dna</groupId>
+            <artifactId>dna-connector-jdbc-metadata</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
 
 		<!-- 
           JPA Connector Dependencies

Added: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JdbcMetadataRepositoryTckTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JdbcMetadataRepositoryTckTest.java	                        (rev 0)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JdbcMetadataRepositoryTckTest.java	2009-12-21 14:23:42 UTC (rev 1469)
@@ -0,0 +1,32 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.test.integration;
+
+import junit.framework.Test;
+
+public class JdbcMetadataRepositoryTckTest {
+    public static Test suite() {
+        return AbstractRepositoryTckTest.readOnlyRepositorySuite("jdbcmeta");
+    }
+}


Property changes on: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JdbcMetadataRepositoryTckTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/configRepository.xml
===================================================================
--- trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/configRepository.xml	                        (rev 0)
+++ trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/configRepository.xml	2009-12-21 14:23:42 UTC (rev 1469)
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+  ~ JBoss DNA (http://www.jboss.org/dna)
+  ~
+  ~ See the COPYRIGHT.txt file distributed with this work for information
+  ~ regarding copyright ownership.  Some portions may be licensed
+  ~ to Red Hat, Inc. under one or more contributor license agreements.
+  ~ See the AUTHORS.txt file in the distribution for a full listing of 
+  ~ individual contributors.
+  ~
+  ~ JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+  ~ is licensed to you under the terms of the GNU Lesser General Public License as
+  ~ published by the Free Software Foundation; either version 2.1 of 
+  ~ the License, or (at your option) any later version.
+  ~
+  ~ JBoss DNA is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+  ~ or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+  ~ for more details.
+  ~
+  ~ You should have received a copy of the GNU Lesser General Public License
+  ~ along with this distribution; if not, write to:
+  ~ Free Software Foundation, Inc.
+  ~ 51 Franklin Street, Fifth Floor
+  ~ Boston, MA  02110-1301  USA
+  -->
+<configuration xmlns:dna="http://www.jboss.org/dna/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
+    <!-- 
+    Define the sources for the content.  These sources are directly accessible using the DNA-specific Graph API.
+    In fact, this is how the DNA JCR implementation works.  You can think of these as being similar to
+    JDBC DataSource objects, except that they expose graph content via the Graph API instead of records via SQL or JDBC. 
+    -->
+    <dna:sources jcr:primaryType="nt:unstructured">
+        <!-- 
+        The 'JCR' repository is a JBoss Cache source with a single default workspace (though others could be created, too).
+        -->
+        <dna:source jcr:name="Store" dna:classname="org.jboss.dna.connector.meta.jdbc.JdbcMetadataSource"
+        	dna:driverClassName="org.hsqldb.jdbcDriver"
+        	dna:username="sa"
+        	dna:password=""
+        	dna:url="jdbc:hsqldb:mem:."
+        	dna:defaultWorkspaceName="default"/>    
+<!-- 
+        <dna:source jcr:name="Store" dna:classname="org.jboss.dna.connector.meta.jdbc.JdbcMetadataSource"
+        	dna:driverClassName="${jpaSource.driverClassName}"
+        	dna:username="${jpaSource.username}"
+        	dna:password="${jpaSource.password}"
+        	dna:url="${jpaSource.url}"
+        	dna:maximumConnectionsInPool="${jpaSource.maximumConnectionsInPool}"
+        	dna:retryLimit="${jpaSource.retryLimit}"
+        	dna:metadataCollectorClassName="${metadata.collectorClassName}"
+        	dna:defaultWorkspaceName="default"/>    
+ -->
+     </dna:sources>
+    <!-- 
+    Define the mime type detectors. This is an optional section.  By default, each engine will use the 
+    MIME type detector that uses filename extensions.  So we wouldn't need to define the same detector again,
+    but this is how you'd define another extension.
+    -->
+    <dna:mimeTypeDetectors>
+        <dna:mimeTypeDetector jcr:name="Detector">
+            <dna:description>Standard extension-based MIME type detector</dna:description>        
+            <!-- 
+            Specify the implementation class (required), as a child element or attribute on parent element.
+            -->
+            <dna:classname>org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector</dna:classname>
+            <!-- 
+            Specify the classpath (optional) as an ordered list of 'names', where each name is significant to 
+            the classpath factory.  For example, a name could be an OSGI identifier or a Maven coordinate,
+            depending upon the classpath factory being used.  If there is only one 'name' in the classpath,
+            it may be specified as an attribute on the 'mimeTypeDetector' element.  If there is more than one
+            'name', then they must be specified as child 'classpath' elements. Blank or empty values are ignored. 
+             -->
+            <dna:classpath></dna:classpath>
+        </dna:mimeTypeDetector>
+    </dna:mimeTypeDetectors>
+    <!-- 
+    Define the JCR repositories 
+    -->
+    <dna:repositories>
+        <!-- 
+        Define a JCR repository that accesses the 'JCR' source directly.
+        This of course is optional, since we could access the same content through 'JCR'.
+        -->
+        <dna:repository jcr:name="Test Repository Source">
+            <!-- Specify the source that should be used for the repository -->
+            <dna:source>Store</dna:source>
+            <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names
+-->
+            <dna:options jcr:primaryType="dna:options">
+                <jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
+                <projectNodeTypes jcr:primaryType="dna:option" dna:value="false"/>
+            </dna:options>
+            <jcr:nodeTypes />
+            <!-- Define any namespaces for this repository, other than those already defined by JCR or DNA -->
+            <dna:namespaces jcr:primaryType="dna:namespaces">
+                <mj jcr:primaryType="dna:namespace" dna:uri="http://www.jboss.org/dna/connector/meta/jdbc/1.0"/>
+                <dnatest jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/test/1.0"/>
+            </dna:namespaces>
+        </dna:repository>
+    </dna:repositories>
+</configuration>


Property changes on: trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/configRepository.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/repositoryOverlay.properties
===================================================================
--- trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/repositoryOverlay.properties	                        (rev 0)
+++ trunk/dna-integration-tests/src/test/resources/tck/jdbcmeta/repositoryOverlay.properties	2009-12-21 14:23:42 UTC (rev 1469)
@@ -0,0 +1,13 @@
+# Placeholder for any overlaid properties for this repo configuration
+
+javax.jcr.tck.dnaSkipImport=true
+javax.jcr.tck.isReadOnly=true
+javax.jcr.tck.dnaNodeTypePath=/org/jboss/dna/connector/meta/jdbc/connector-metajdbc.cnd
+
+# The fan-out from the tables node is HUGE in HSQLDB.  This allows the tests to complete reasonably quickly.
+javax.jcr.tck.testroot=/default/INFORMATION_SCHEMA/tables/SYSTEM_ALIASES
+
+# There's only one workspace per repository for this connector right now
+javax.jcr.tck.workspacename=default
+
+

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-12-21 01:36:32 UTC (rev 1468)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-12-21 14:23:42 UTC (rev 1469)
@@ -460,6 +460,7 @@
             }
             if (foundMatch) {
                 matchingProperties.add(property);
+            } else {
                 foundMatch = true; // for the next iteration ..
             }
         }

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java	2009-12-21 01:36:32 UTC (rev 1468)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java	2009-12-21 14:23:42 UTC (rev 1469)
@@ -41,11 +41,13 @@
 public class DnaRepositoryStub extends RepositoryStub {
 
     public static final String DNA_SKIP_IMPORT = "javax.jcr.tck.dnaSkipImport";
+    public static final String DNA_NODE_TYPE_PATH = "javax.jcr.tck.dnaNodeTypePath";
     
     private static final String REPOSITORY_SOURCE_NAME = "Test Repository Source";
 
     private static String currentConfigurationName = "default";
 
+
     private Properties configProps;
     private String repositoryConfigurationName;
     private JcrRepository repository;
@@ -85,6 +87,12 @@
 
             // Add the the node types for the source ...
             configuration.repository(REPOSITORY_SOURCE_NAME).addNodeTypes(getClass().getResourceAsStream("/tck/tck_test_types.cnd"));
+
+            String nodeTypePath = configProps.getProperty(DNA_NODE_TYPE_PATH);
+            if (nodeTypePath != null) {
+                configuration.repository(REPOSITORY_SOURCE_NAME).addNodeTypes(getClass().getResourceAsStream(nodeTypePath));
+            }
+
         } catch (SAXException se) {
             se.printStackTrace();
             throw new IllegalStateException(se);

Modified: trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_metadata.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_metadata.xml	2009-12-21 01:36:32 UTC (rev 1468)
+++ trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_metadata.xml	2009-12-21 14:23:42 UTC (rev 1469)
@@ -24,10 +24,8 @@
 <chapter id="jdbc-metadata-connector">
 	<title>JDBC Metadata Connector</title>
 	<para>
-		This connector provides read-only access to the metadata (e.g.,
-		catalogs, schemas, table structures) of a relational database.
-		The
-		connector yields a content graph that looks like this:
+		This connector provides read-only access to the metadata (e.g., catalogs, schemas, table structures) of a relational 
+		database. The connector yields a content graph that looks like this:
 		<programlisting>
 / (root node)
     + &lt;catalog name&gt; - one node for each accessible catalog in the database.
@@ -52,8 +50,13 @@
 			to work around a known bug where that driver returns a list of users from a call to &DatabaseMetaData;.getSchemas() instead of a list of schemas.
 			</para>
 		</note>
-  </para>
+    </para>
 	<para>
+		To use this connector with the DNA JCR layer, you must import the JCR node types that this connector uses.  These are bundled
+		in the JAR for this connector at the path <code>/org/jboss/dna/connector/meta/jdbc/nodeTypes.cnd</code>.  Please see the &GettingStarted; Guide
+		for detailed examples of how to import custom JCR node types.  
+	</para>
+	<para>
 		The &JdbcMetadataSource; class provides a number of JavaBean properties that control its behavior:
 	</para>
 	<table frame='all'>

Modified: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataLexicon.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataLexicon.java	2009-12-21 01:36:32 UTC (rev 1468)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataLexicon.java	2009-12-21 14:23:42 UTC (rev 1469)
@@ -32,7 +32,7 @@
 public class JdbcMetadataLexicon {
 
     public static class Namespace {
-        public static final String URI = "http://www.jboss.org/dna/connector/meta/jdbc";
+        public static final String URI = "http://www.jboss.org/dna/connector/meta/jdbc/1.0";
         public static final String PREFIX = "metajdbc";
     }
 

Modified: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java	2009-12-21 01:36:32 UTC (rev 1468)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java	2009-12-21 14:23:42 UTC (rev 1469)
@@ -110,7 +110,7 @@
             rootNodeProperties.put(propName, propFactory.create(propName, databaseMinorVersion));
 
             rootNodeProperties.put(JcrLexicon.PRIMARY_TYPE, propFactory.create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.ROOT));
-            rootNodeProperties.put(JcrLexicon.MIXIN_TYPES, propFactory.create(JcrLexicon.PRIMARY_TYPE,
+            rootNodeProperties.put(JcrLexicon.MIXIN_TYPES, propFactory.create(JcrLexicon.MIXIN_TYPES,
                                                                               JdbcMetadataLexicon.DATABASE_ROOT));
 
             rootNodeProperties = Collections.unmodifiableMap(rootNodeProperties);

Added: trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/meta/jdbc/connector-metajdbc.cnd
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/meta/jdbc/connector-metajdbc.cnd	                        (rev 0)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/meta/jdbc/connector-metajdbc.cnd	2009-12-21 14:23:42 UTC (rev 1469)
@@ -0,0 +1,74 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors. 
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+ 
+//------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<mj='http://www.jboss.org/dna/connector/meta/jdbc/1.0'>
+
+[mj:databaseRoot] mixin
+- mj:databaseProductName (string) mandatory
+- mj:databaseProductVersion (string) mandatory
+- mj:databaseMajorVersion (long) mandatory
+- mj:databaseMinorVersion (long) mandatory
+
+[mj:catalog] mixin
+
+[mj:schema] mixin
+
+[mj:tables] mixin
+
+[mj:table] mixin
+- mj:tableType (string)
+- mj:description (long)  
+- mj:typeCatalogName (string)  
+- mj:typeSchemaName (string)  
+- mj:typeName (string)
+- mj:selfReferencingColumnName (string)  
+- mj:referenceGenerationStrategyName(string)  
+
+[mj:column] mixin
+- mj:jdbcDataType (long)  
+- mj:typeName (string)  
+- mj:columnSize (long) mandatory  
+- mj:decimalDigits (long) mandatory
+- mj:radix (long) mandatory
+- mj:nullable (boolean)
+- mj:description (string)
+- mj:defaultValue (string)
+- mj:length (long) mandatory
+- mj:ordinalPosition(long) mandatory
+- mj:scopeCatalogName (string)
+- mj:scopeSchemaName (string)
+- mj:scopeTableName (string)
+- mj:sourceJdbcDataType (long)  
+
+[mj:procedures] mixin
+
+[mj:procedure] mixin
+- mj:description (string)
+- mj:returnType (int)  



More information about the dna-commits mailing list