A couple of updates for this.. Required changes to bigbank were not
included in the original patch. Also, a new test added in the patch
needed to be updated because existing registered static types could
cause it to fail.

These two patches replace the patch file I sent earlier.

Brent

On 7/17/06, Brent Daniel <[EMAIL PROTECTED]> wrote:
Attached is a patch to switch our runtime and existing static type
tests over to using an SDO type URI in the config rather than the name
of a single Type.

Brent



Index: src/test/java/org/apache/tuscany/das/rdb/test/ExceptionTests.java
===================================================================
--- src/test/java/org/apache/tuscany/das/rdb/test/ExceptionTests.java   
(revision 422736)
+++ src/test/java/org/apache/tuscany/das/rdb/test/ExceptionTests.java   
(working copy)
@@ -61,7 +61,19 @@
 
     }
 
+    public void testUnregisteredTypes() throws Exception {
+       DAS das = DAS.FACTORY.createDAS(getConfig("staticInvalid.xml"), 
getConnection());
+        Command readCustomers = das.createCommand("select * from CUSTOMER 
where ID = 1");                   
 
+        try {
+                readCustomers.executeQuery();
+            
+            fail("Exception should be thrown");
+        } catch (RuntimeException ex) {
+            assertEquals("SDO Types have not been registered for URI 
invalidURI", ex.getMessage());
+        }
+    }
+
     public void testMissingMapping() throws Exception {
        SDOUtil.registerStaticTypes(CustomerFactory.class);
        DAS das = DAS.FACTORY.createDAS(getConfig("staticCustomer.xml"), 
getConnection());
Index: 
src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java
===================================================================
--- 
src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java
 (revision 422736)
+++ 
src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java
 (working copy)
@@ -48,7 +48,7 @@
                t.setTypeName("Customer");
                mapping.getTable().add(t);
                
-               
mapping.setDataObjectModel("org.apache.tuscany.das.rdb.test.customer.Customer");
+               
mapping.setDataObjectModel("http:///org.apache.tuscany.das.rdb.test/customer.xsd";);
        }
        
        public ReadCustomersStaticTypesCommand() {
Index: src/test/resources/staticInvalid.xml
===================================================================
--- /dev/null   (revision 0)
+++ src/test/resources/staticInvalid.xml        (revision 0)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+  Copyright (c) 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.
+ -->
+<Config 
xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"; 
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
+dataObjectModel="invalidURI">
+  
+       
+</Config>
Index: src/test/resources/staticCustomer.xml
===================================================================
--- src/test/resources/staticCustomer.xml       (revision 422736)
+++ src/test/resources/staticCustomer.xml       (working copy)
@@ -16,7 +16,7 @@
  -->
 <Config 
xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"; 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
-dataObjectModel="org.apache.tuscany.das.rdb.test.customer.Customer">
+dataObjectModel="http:///org.apache.tuscany.das.rdb.test/customer.xsd";>
   
        
 </Config>
Index: src/test/resources/companyMappingWithConverters.xml
===================================================================
--- src/test/resources/companyMappingWithConverters.xml (revision 422736)
+++ src/test/resources/companyMappingWithConverters.xml (working copy)
@@ -15,7 +15,8 @@
   limitations under the License.
  -->
 <Config 
xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"; 
-xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
dataObjectModel="org.apache.tuscany.das.rdb.test.company.CompanyType">
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
+dataObjectModel="org.apache.tuscany.das.rdb.test/company.xsd">
   
   <Table tableName="COMPANY" typeName="CompanyType">
     <Column columnName="ID" primaryKey="true"/>
Index: src/test/resources/staticCustomerOrder.xml
===================================================================
--- src/test/resources/staticCustomerOrder.xml  (revision 422736)
+++ src/test/resources/staticCustomerOrder.xml  (working copy)
@@ -16,7 +16,7 @@
  -->
 <Config 
xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"; 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-dataObjectModel="org.apache.tuscany.das.rdb.test.customer.Customer">
+dataObjectModel="http:///org.apache.tuscany.das.rdb.test/customer.xsd";>
 
   <Command name="Customer and Orders" SQL="SELECT * FROM CUSTOMER LEFT JOIN 
ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?" 
kind="Select"/>
                
Index: src/test/resources/basicStaticCustomer.xml
===================================================================
--- src/test/resources/basicStaticCustomer.xml  (revision 422736)
+++ src/test/resources/basicStaticCustomer.xml  (working copy)
@@ -16,7 +16,7 @@
  -->
 <Config 
xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"; 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-dataObjectModel="org.apache.tuscany.das.rdb.test.customer.Customer">
+dataObjectModel="http:///org.apache.tuscany.das.rdb.test/customer.xsd";>
   
  <Table tableName="CUSTOMER" typeName="Customer">
    <Column columnName="ID" primaryKey="true"/>
Index: 
src/main/java/org/apache/tuscany/das/rdb/graphbuilder/schema/ESchemaMaker.java
===================================================================
--- 
src/main/java/org/apache/tuscany/das/rdb/graphbuilder/schema/ESchemaMaker.java  
    (revision 422736)
+++ 
src/main/java/org/apache/tuscany/das/rdb/graphbuilder/schema/ESchemaMaker.java  
    (working copy)
@@ -183,10 +183,12 @@
                return "http:///org.apache.tuscany.das.rdb/das";;
        }
 
-       public Type createTypes(Type aType) {
+       public Type createTypes(String uri) {
                Type rootType = SDOUtil.createType(typeHelper, getURI() + 
"/DataGraphRoot", "DataGraphRoot", false);    
                
-               EPackage pkg = 
((TypeHelperImpl)typeHelper).getExtendedMetaData().getPackage(aType.getURI());
+               EPackage pkg = 
((TypeHelperImpl)typeHelper).getExtendedMetaData().getPackage(uri);
+               if ( pkg == null ) 
+                       throw new RuntimeException("SDO Types have not been 
registered for URI " + uri);
                Iterator i = pkg.getEClassifiers().iterator();
                while ( i.hasNext() ) {
                        Type type = (Type) i.next();
Index: 
src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/GraphBuilderMetadata.java
===================================================================
--- 
src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/GraphBuilderMetadata.java
        (revision 422736)
+++ 
src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/GraphBuilderMetadata.java
        (working copy)
@@ -29,7 +29,6 @@
 import org.apache.tuscany.das.rdb.util.DebugUtil;
 
 import commonj.sdo.Type;
-import commonj.sdo.helper.TypeHelper;
 
 
 /**
@@ -39,21 +38,13 @@
        private Config mappingModel;
        private final Collection resultSets = new ArrayList();
        private boolean debug = false;
-       private Type schema;
+       private String typeURI;
 
 
        public GraphBuilderMetadata(Collection results, Config model, 
ResultSetShape shape) throws SQLException {
                this.mappingModel = model;
-               if (model != null && model.getDataObjectModel() != null) {
-
-                       Class rootClass;
-                       try {
-                               rootClass = 
Thread.currentThread().getContextClassLoader().loadClass(model.getDataObjectModel());
                               
-                               this.schema = 
TypeHelper.INSTANCE.getType(rootClass);
-                       } catch (ClassNotFoundException e) {
-                               throw new RuntimeException(e);
-                       }
-
+               if (model != null) {
+                       this.typeURI = model.getDataObjectModel();              
                }
                
                Iterator i = results.iterator();
@@ -96,10 +87,10 @@
         */
        public Type getSchema() {
                ESchemaMaker schemaMaker = new ESchemaMaker(this);
-               if ( this.schema == null ) {            
+               if ( this.typeURI == null ) {           
                        return schemaMaker.createTypes();
                } else {
-                       return schemaMaker.createTypes(this.schema);
+                       return schemaMaker.createTypes(this.typeURI);
                }
        }
 
Index: src/main/resources/DasAccountConfiguration.xml
===================================================================
--- src/main/resources/DasAccountConfiguration.xml      (revision 421922)
+++ src/main/resources/DasAccountConfiguration.xml      (working copy)
@@ -15,7 +15,7 @@
   limitations under the License.
  -->
 <Config 
xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
- dataObjectModel="com.bigbank.account.CustomerProfileData">
+ dataObjectModel="http://www.bigbank.com/account";>
   
   <Table tableName="CUSTOMERS" typeName="CustomerProfileData">
     <!-- Column name="firstName" primaryKey="true"/ -->
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to