tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwilli...@apache.org
Subject svn commit: r415391 - in /incubator/tuscany/java/das/rdb/src: main/java/org/apache/tuscany/das/rdb/ main/java/org/apache/tuscany/das/rdb/impl/ test/java/org/apache/tuscany/das/rdb/test/ test/java/org/apache/tuscany/das/rdb/test/commands/ test/resources/
Date Mon, 19 Jun 2006 19:27:38 GMT
Author: kwilliams
Date: Mon Jun 19 12:27:37 2006
New Revision: 415391

URL: http://svn.apache.org/viewvc?rev=415391&view=rev
Log:
Applying Brent's patch for T-231

Modified:
    incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Command.java
    incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/ResultSetShape.java
    incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CommandImpl.java
    incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java
    incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java
    incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SPCommandImpl.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConverterTests.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/RecursiveTests.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ResultSetShapeTests.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersByLastnameCommand.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersCommand.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersWithShapeCommand.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/SimpleReadCustomersWithShapeCommand.java
    incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithConverter.xml
    incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithIDConverter.xml
    incubator/tuscany/java/das/rdb/src/test/resources/PartsConfig.xml

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Command.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Command.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Command.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Command.java Mon
Jun 19 12:27:37 2006
@@ -114,19 +114,6 @@
 	 */
 	public void setDataObjectModel(Type schema);
 
-	/**
-	 * Defines the structure of the ResultSet returned by the JDBC Driver when
-	 * this command is executed. If the shape is not specified then the shape is
-	 * taken from the ResultSetMetatadta instance provided by the JDBC Driver.
-	 * <p>
-	 * This method is prvided primarily to support platforms (such as Oracle)
-	 * that do not provide complete support for ResultSetMetadata
-	 * 
-	 * @param shape
-	 *            the specified result set shape
-	 * @see ResultSetShape
-	 */
-	public void setResultSetShape(ResultSetShape shape);
 
 	/**
 	 * Provides the java.sql.Connection to be used for this executing this

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/ResultSetShape.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/ResultSetShape.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/ResultSetShape.java
(original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/ResultSetShape.java
Mon Jun 19 12:27:37 2006
@@ -18,10 +18,13 @@
 
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
+import java.util.List;
 
+import org.apache.tuscany.das.rdb.config.ResultDescriptor;
 import org.apache.tuscany.das.rdb.graphbuilder.schema.ResultSetTypeMap;
 
 import commonj.sdo.Type;
+import commonj.sdo.helper.TypeHelper;
 
 /**
  * Describes the structure of the result set returned from execution 
@@ -38,12 +41,6 @@
 	private final String[] columns;
 	private final String[] tables;
 	private final Type[] types;	
-	
-	public ResultSetShape(String[] t, String[] c, Type[] dataTypes) {
-		this.columns = c;
-		this.tables = t;
-		this.types = dataTypes;	
-	}
 
 	public ResultSetShape(ResultSetMetaData metadata) throws SQLException {
 		columns = new String[metadata.getColumnCount()];
@@ -56,6 +53,31 @@
 			columns[i-1] = metadata.getColumnName(i);
 			types[i-1] = typeMap.getType(metadata.getColumnType(i), true);
 		}
+	}
+
+	public ResultSetShape(List resultDescriptor) {
+		TypeHelper helper = TypeHelper.INSTANCE;
+		int size = resultDescriptor.size();
+		columns = new String[size];
+		tables = new String[size];
+		types = new Type[size];	
+		
+		for (int i=0; i<size; i++) {
+			ResultDescriptor desc = (ResultDescriptor) resultDescriptor.get(i);
+			tables[i] = desc.getTableName();
+			columns[i] = desc.getColumnName();
+			
+			
+			int idx = desc.getColumnType().lastIndexOf('.');
+			String uri = desc.getColumnType().substring(0, idx);
+			String typeName = desc.getColumnType().substring(idx+1);
+			
+			types[i] = helper.getType(uri, typeName);
+			if ( types[i] == null ) 
+				throw new RuntimeException("Could not find type " + desc.getColumnType() + " for column
" + desc.getColumnName());
+		}
+		
+		
 	}
 
 	public int getColumnCount() {

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CommandImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CommandImpl.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CommandImpl.java
(original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CommandImpl.java
Mon Jun 19 12:27:37 2006
@@ -132,12 +132,6 @@
 	}
 
 
-
-	public void setResultSetShape(ResultSetShape shape) {
-		this.resultSetShape = shape;
-	}
-
-
 	public void close() {
 		statement.close();
 	}

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java
(original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java
Mon Jun 19 12:27:37 2006
@@ -62,7 +62,7 @@
                     .next();
             String kind = commandConfig.getKind();
             if (kind.equalsIgnoreCase("select"))                             
-                commands.put(commandConfig.getName(), new ReadCommandImpl(commandConfig.getSQL(),
config));
+                commands.put(commandConfig.getName(), new ReadCommandImpl(commandConfig.getSQL(),
config, commandConfig.getResultDescriptor()));
             else if (kind.equalsIgnoreCase("update"))
                 commands.put(commandConfig.getName(), new UpdateCommandImpl(commandConfig.getSQL()));
             else if (kind.equalsIgnoreCase("insert"))
@@ -192,7 +192,7 @@
         char firstChar = Character.toUpperCase(sql.charAt(0));
         switch (firstChar) {
         case 'S':
-            return new ReadCommandImpl(sql, config);
+            return new ReadCommandImpl(sql, config, null);
         case 'I':
             return new InsertCommandImpl(sql);
         case 'U':

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java
(original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java
Mon Jun 19 12:27:37 2006
@@ -16,12 +16,12 @@
  */
 package org.apache.tuscany.das.rdb.impl;
 
-import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.tuscany.das.rdb.ResultSetShape;
 import org.apache.tuscany.das.rdb.config.Config;
 import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper;
 import org.apache.tuscany.das.rdb.graphbuilder.impl.GraphBuilderMetadata;
@@ -39,26 +39,18 @@
 
     private int startRow = 1;
 
-    private int endRow = Integer.MAX_VALUE;
+    private int endRow = Integer.MAX_VALUE;   
 
-    public ReadCommandImpl(String sqlString) {
+    public ReadCommandImpl(String sqlString, Config mapping, List resultDescriptor) {
         super(sqlString);
-    }
-
-    public ReadCommandImpl(String sqlString, Config mapping) {
-        this(sqlString);
-        if (mapping != null)
-            setMappingModel(mapping);
-    }
-
-    //TODO - Need to refactor based on use of DataSource and CommandGroup
-    public ReadCommandImpl(String sqlString, Config mapping, Connection connection) {
-        this(sqlString);
-        setConnection(connection);
         if (mapping != null)
             setMappingModel(mapping);
+        
+        if ( resultDescriptor != null && !resultDescriptor.isEmpty()) 
+        	this.resultSetShape = new ResultSetShape(resultDescriptor);
     }
 
+   
     public void execute() {
         throw new UnsupportedOperationException();
     }

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SPCommandImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SPCommandImpl.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SPCommandImpl.java
(original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SPCommandImpl.java
Mon Jun 19 12:27:37 2006
@@ -25,13 +25,9 @@
 import commonj.sdo.DataObject;
 
 public class SPCommandImpl extends ReadCommandImpl {
-
-	public SPCommandImpl(String sqlString) {
-		super(sqlString);
-	}
     
     public SPCommandImpl(String sqlString, Config config) {
-        super(sqlString, config);
+        super(sqlString, config, null);
     }
 
 	public DataObject executeQuery() {

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConverterTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConverterTests.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConverterTests.java
(original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConverterTests.java
Mon Jun 19 12:27:37 2006
@@ -23,13 +23,10 @@
 
 import org.apache.tuscany.das.rdb.Command;
 import org.apache.tuscany.das.rdb.DAS;
-import org.apache.tuscany.das.rdb.ResultSetShape;
-import org.apache.tuscany.das.rdb.SDODataTypes;
 import org.apache.tuscany.das.rdb.test.data.CustomerData;
 import org.apache.tuscany.das.rdb.test.framework.DasTest;
 
 import commonj.sdo.DataObject;
-import commonj.sdo.Type;
 
 /**
  * Tests the Converter framwork
@@ -79,16 +76,10 @@
 	 */
 	public void testArbitraryConverter() throws Exception {
 		DAS das = DAS.FACTORY.createDAS(getConfig("CustomerConfigWithConverter.xml"));
+		das.setConnection(getConnection());
 		//Create and initialize command to read customers
-		Command read = das.createCommand("select * from CUSTOMER where ID = 1", getConfig("CustomerConfigWithConverter.xml"));

-		read.setConnection(getConnection());
+		Command read = das.getCommand("testArbitraryConverter");			
 
-		String[] columns = { "ID", "LASTNAME", "ADDRESS" };
-		String[] tables = { "CUSTOMER", "CUSTOMER", "CUSTOMER" };
-		Type[] types = { SDODataTypes.INTEGEROBJECT, SDODataTypes.DATE, SDODataTypes.STRING };
-		ResultSetShape shape = new ResultSetShape(tables, columns, types);
-		read.setResultSetShape(shape);							
-		
 		//Read
 		DataObject root = read.executeQuery();
 		

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/RecursiveTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/RecursiveTests.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/RecursiveTests.java
(original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/RecursiveTests.java
Mon Jun 19 12:27:37 2006
@@ -20,14 +20,10 @@
 
 import org.apache.tuscany.das.rdb.Command;
 import org.apache.tuscany.das.rdb.DAS;
-import org.apache.tuscany.das.rdb.ResultSetShape;
-import org.apache.tuscany.das.rdb.SDODataTypes;
-import org.apache.tuscany.das.rdb.impl.ReadCommandImpl;
 import org.apache.tuscany.das.rdb.test.data.PartData;
 import org.apache.tuscany.das.rdb.test.framework.DasTest;
 
 import commonj.sdo.DataObject;
-import commonj.sdo.Type;
 
 public class RecursiveTests extends DasTest {
 
@@ -39,21 +35,12 @@
 	public void testReadEngineParts() throws Exception {
 		
 		DAS das = DAS.FACTORY.createDAS(getConfig("PartsConfig.xml"));
+		das.setConnection(getConnection());
 		//Table definition
 		//CREATE TABLE PART (ID INT PRIMARY KEY NOT NULL, NAME VARCHAR(50), QUANTITY INT, PARENT_ID
INT );
 
-		String threeLevelPartsSQL = "SELECT P1.*, P2.*, P3.* FROM PART AS P1 LEFT JOIN PART AS
P2 ON P1.ID = P2.PARENT_ID "
-				+ "LEFT JOIN PART AS P3 on P2.ID = P3.PARENT_ID WHERE P1.ID = 1";
-		Command select = das.createCommand(threeLevelPartsSQL, getConfig("PartsConfig.xml"));
-		select.setConnection(getConnection());
-
-		String[] columns = {"ID", "NAME", "QUANTITY", "PARENT_ID", "ID", "NAME", "QUANTITY", "PARENT_ID",
"ID", "NAME", "QUANTITY", "PARENT_ID"};
-		String[] tables = {"PART", "PART", "PART", "PART", "PART", "PART", "PART", "PART", "PART",
"PART", "PART", "PART"};
-		Type[] types = {SDODataTypes.INTEGEROBJECT, SDODataTypes.STRING, SDODataTypes.INTEGEROBJECT,
SDODataTypes.INTEGEROBJECT, SDODataTypes.INTEGEROBJECT, SDODataTypes.STRING, SDODataTypes.INTEGEROBJECT,
SDODataTypes.INTEGEROBJECT, SDODataTypes.INTEGEROBJECT, SDODataTypes.STRING, SDODataTypes.INTEGEROBJECT,
SDODataTypes.INTEGEROBJECT};
-		ResultSetShape shape = new ResultSetShape(tables, columns, types);
-
-		//Hack until we provide a nicer API
-		((ReadCommandImpl)select).setResultSetShape(shape);	
+	
+		Command select = das.getCommand("readEngineParts");				
 		
 		// Need to set the key explicitly. The aggregate of columns not working
 		// because of null values

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ResultSetShapeTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ResultSetShapeTests.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ResultSetShapeTests.java
(original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ResultSetShapeTests.java
Mon Jun 19 12:27:37 2006
@@ -18,13 +18,10 @@
 
 import org.apache.tuscany.das.rdb.Command;
 import org.apache.tuscany.das.rdb.DAS;
-import org.apache.tuscany.das.rdb.ResultSetShape;
-import org.apache.tuscany.das.rdb.SDODataTypes;
 import org.apache.tuscany.das.rdb.test.data.CustomerData;
 import org.apache.tuscany.das.rdb.test.framework.DasTest;
 
 import commonj.sdo.DataObject;
-import commonj.sdo.Type;
 
 /**
  * Test ability to specify format(shape) of the ResultSet. This is necessary
@@ -49,20 +46,10 @@
      */
     public void testReadSingle() throws Exception {
 
-        // Using literals in the select forces invalid resultset metadata
-        String sqlString = "Select 99, 'Roosevelt', '1600 Pennsylvania Avenue' from customer";
-        String[] columns = { "ID", "LASTNAME", "ADDRESS" };
-        String[] tables = { "CUSTOMER", "CUSTOMER", "CUSTOMER" };
-        Type[] types = { SDODataTypes.LONG, SDODataTypes.STRING, SDODataTypes.STRING };
-
-        ResultSetShape shape = new ResultSetShape(tables, columns, types);
-
         DAS das = DAS.FACTORY.createDAS(getConfig("CustomerConfigWithIDConverter.xml"));
+        das.setConnection(getConnection());
         // Create and initialize command to read customers
-        Command readCustomers = das.createCommand(sqlString,
-                getConfig("CustomerConfigWithIDConverter.xml"));
-        // Specify result shape
-        readCustomers.setResultSetShape(shape);
+        Command readCustomers = das.getCommand("literal");     
 
         readCustomers.setConnection(getConnection());
 

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersByLastnameCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersByLastnameCommand.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersByLastnameCommand.java
(original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersByLastnameCommand.java
Mon Jun 19 12:27:37 2006
@@ -49,6 +49,6 @@
 	}
 	
 	public ReadCustomersByLastnameCommand() {
-		super(sqlString, mapping);
+		super(sqlString, mapping, null);
 	}
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersCommand.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersCommand.java
(original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersCommand.java
Mon Jun 19 12:27:37 2006
@@ -49,7 +49,7 @@
 	}
 	
 	public ReadCustomersCommand() {
-		super(sqlString, mapping);
+		super(sqlString, mapping, null);
 	}
 
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java
(original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java
Mon Jun 19 12:27:37 2006
@@ -53,7 +53,7 @@
 	}
 	
 	public ReadCustomersStaticTypesCommand() {
-		super(sqlString, mapping);
+		super(sqlString, mapping, null);
 		setDataObjectModel(TypeHelper.INSTANCE.getType(DataGraphRoot.class));
 	}
 

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersWithShapeCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersWithShapeCommand.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersWithShapeCommand.java
(original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersWithShapeCommand.java
Mon Jun 19 12:27:37 2006
@@ -16,25 +16,43 @@
  */
 package org.apache.tuscany.das.rdb.test.commands;
 
-import org.apache.tuscany.das.rdb.ResultSetShape;
-import org.apache.tuscany.das.rdb.SDODataTypes;
-import org.apache.tuscany.das.rdb.impl.ReadCommandImpl;
+import java.util.ArrayList;
 
-import commonj.sdo.Type;
+import org.apache.tuscany.das.rdb.config.ConfigFactory;
+import org.apache.tuscany.das.rdb.config.ResultDescriptor;
+import org.apache.tuscany.das.rdb.config.impl.ConfigFactoryImpl;
+import org.apache.tuscany.das.rdb.impl.ReadCommandImpl;
 
 public class ReadCustomersWithShapeCommand extends ReadCommandImpl {
-
-	// This sql string ensures that we won't have resultset metadata
-	private static final String sqlString = "Select * from customer union select * from customer";
-
-	private static final String[] columns = {"ID", "LASTNAME", "ADDRESS"};
-	private static final String[] tables = {"CUSTOMER", "CUSTOMER", "CUSTOMER"};
-	private static final Type[] types = {SDODataTypes.INT, SDODataTypes.STRING, SDODataTypes.STRING};
-
+//	 This sql string ensures that we won't have resultset metadata
+	static String sqlString = "select * from customer union select * from customer";	
+	static ArrayList descriptor = new ArrayList();
+	
+	static {
+		ConfigFactory factory = ConfigFactoryImpl.eINSTANCE;
+		
+		ResultDescriptor desc1 = factory.createResultDescriptor();
+		desc1.setColumnName("ID");
+		desc1.setColumnType("commonj.sdo.Int");
+		desc1.setTableName("CUSTOMER");
+		
+		ResultDescriptor desc2 = factory.createResultDescriptor();
+		desc2.setColumnName("LASTNAME");
+		desc2.setColumnType("commonj.sdo.String");
+		desc2.setTableName("CUSTOMER");
+		
+		ResultDescriptor desc3 = factory.createResultDescriptor();
+		desc3.setColumnName("ADDRESS");
+		desc3.setColumnType("commonj.sdo.String");
+		desc3.setTableName("CUSTOMER");
+		
+		descriptor.add(desc1);
+		descriptor.add(desc2);
+		descriptor.add(desc3);
+		
+	}
 	public ReadCustomersWithShapeCommand() {
-		super(sqlString);
-		ResultSetShape shape = new ResultSetShape(tables, columns, types);
-		setResultSetShape(shape);
+		super(sqlString, null, descriptor);		
 	}
 
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/SimpleReadCustomersWithShapeCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/SimpleReadCustomersWithShapeCommand.java?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/SimpleReadCustomersWithShapeCommand.java
(original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/SimpleReadCustomersWithShapeCommand.java
Mon Jun 19 12:27:37 2006
@@ -16,31 +16,27 @@
 */
 package org.apache.tuscany.das.rdb.test.commands;
 
-import org.apache.tuscany.das.rdb.ResultSetShape;
-import org.apache.tuscany.das.rdb.SDODataTypes;
+import java.util.ArrayList;
+
 import org.apache.tuscany.das.rdb.config.Column;
 import org.apache.tuscany.das.rdb.config.Config;
 import org.apache.tuscany.das.rdb.config.ConfigFactory;
+import org.apache.tuscany.das.rdb.config.ResultDescriptor;
 import org.apache.tuscany.das.rdb.config.Table;
 import org.apache.tuscany.das.rdb.config.impl.ConfigFactoryImpl;
 import org.apache.tuscany.das.rdb.impl.ReadCommandImpl;
 
-import commonj.sdo.Type;
-
 public class SimpleReadCustomersWithShapeCommand extends ReadCommandImpl {
 
 	// This sql string ensures that we won't have resultset metadata
 	private static final String sqlString = "Select * from customer union select * from customer";
-
-	private static final String[] columns = {"ID", "LASTNAME", "ADDRESS"};
-	private static final String[] tables = {"CUSTOMER", "CUSTOMER", "CUSTOMER"};
-	private static final Type[] types = {SDODataTypes.INT, SDODataTypes.STRING, SDODataTypes.STRING};
+	private static final ArrayList descriptor = new ArrayList();
 	
-	private static final Config mapping;
+	private static final Config config;
 
 	static {
 		ConfigFactory factory = ConfigFactoryImpl.eINSTANCE;
-		mapping = factory.createConfig();
+		config = factory.createConfig();
 		Table t = factory.createTable();
 		Column id = factory.createColumn();
 		id.setColumnName("ID");
@@ -54,13 +50,30 @@
 		t.getColumn().add(lastname);
 		t.getColumn().add(address);
 		t.setTableName("CUSTOMER");
-		mapping.getTable().add(t);
+		config.getTable().add(t);
+		
+		ResultDescriptor desc1 = factory.createResultDescriptor();
+		desc1.setColumnName("ID");
+		desc1.setColumnType("commonj.sdo.Int");
+		desc1.setTableName("CUSTOMER");
+		
+		ResultDescriptor desc2 = factory.createResultDescriptor();
+		desc2.setColumnName("LASTNAME");
+		desc2.setColumnType("commonj.sdo.String");
+		desc2.setTableName("CUSTOMER");
+		
+		ResultDescriptor desc3 = factory.createResultDescriptor();
+		desc3.setColumnName("ADDRESS");
+		desc3.setColumnType("commonj.sdo.String");
+		desc3.setTableName("CUSTOMER");
+		
+		descriptor.add(desc1);
+		descriptor.add(desc2);
+		descriptor.add(desc3);
 	}
 
 	public SimpleReadCustomersWithShapeCommand() {
-		super(sqlString, mapping);
-		ResultSetShape shape = new ResultSetShape(tables, columns, types);
-		setResultSetShape(shape);
+		super(sqlString, config, descriptor);		
 	}
 
 }

Modified: incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithConverter.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithConverter.xml?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithConverter.xml (original)
+++ incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithConverter.xml Mon
Jun 19 12:27:37 2006
@@ -16,6 +16,13 @@
  -->
 <Config xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
+	
+	<Command name="testArbitraryConverter" SQL="Select * from CUSTOMER where ID = 1" kind="Select">
+ 		<ResultDescriptor columnName="ID" tableName="CUSTOMER" columnType="commonj.sdo.IntObject"/>
+ 		<ResultDescriptor columnName="LASTNAME" tableName="CUSTOMER" columnType="commonj.sdo.Date"/>
+ 		<ResultDescriptor columnName="ADDRESS" tableName="CUSTOMER" columnType="commonj.sdo.String"/>
+ 	</Command>
+ 	
   <Table tableName="CUSTOMER">
 	<Column columnName="ID" primaryKey="true"/>
     <Column columnName="LASTNAME" converterClassName="org.apache.tuscany.das.rdb.test.mappings.SillyDateStringConverter"/>

Modified: incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithIDConverter.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithIDConverter.xml?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithIDConverter.xml (original)
+++ incubator/tuscany/java/das/rdb/src/test/resources/CustomerConfigWithIDConverter.xml Mon
Jun 19 12:27:37 2006
@@ -16,6 +16,12 @@
  -->
 <Config xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
+ 	<Command name="literal" SQL="Select 99, 'Roosevelt', '1600 Pennsylvania Avenue' from
customer" kind="Select">
+ 		<ResultDescriptor columnName="ID" tableName="CUSTOMER" columnType="commonj.sdo.Long"/>
+ 		<ResultDescriptor columnName="LASTNAME" tableName="CUSTOMER" columnType="commonj.sdo.String"/>
+ 		<ResultDescriptor columnName="ADDRESS" tableName="CUSTOMER" columnType="commonj.sdo.String"/>
+ 	</Command>
+ 	
   <Table tableName="CUSTOMER">
     <Column columnName="ID" converterClassName="org.apache.tuscany.das.rdb.test.mappings.StringToLongConverter"/>
   </Table>

Modified: incubator/tuscany/java/das/rdb/src/test/resources/PartsConfig.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/resources/PartsConfig.xml?rev=415391&r1=415390&r2=415391&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/resources/PartsConfig.xml (original)
+++ incubator/tuscany/java/das/rdb/src/test/resources/PartsConfig.xml Mon Jun 19 12:27:37
2006
@@ -15,6 +15,26 @@
   limitations under the License.
  -->
 <Config xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  	
+  <Command name="readEngineParts" kind="Select" SQL="SELECT P1.*, P2.*, P3.* FROM PART
AS P1 
+  				LEFT JOIN PART AS P2 ON P1.ID = P2.PARENT_ID 
+  					LEFT JOIN PART AS P3 on P2.ID = P3.PARENT_ID WHERE P1.ID = 1">
+  					<ResultDescriptor columnName="ID" columnType="commonj.sdo.IntObject" tableName="PART"/>
+  					<ResultDescriptor columnName="NAME" columnType="commonj.sdo.String" tableName="PART"/>
+  					<ResultDescriptor columnName="QUANTITY" columnType="commonj.sdo.IntObject" tableName="PART"/>
+  					<ResultDescriptor columnName="PARENT_ID" columnType="commonj.sdo.IntObject" tableName="PART"/>
+  					
+  					<ResultDescriptor columnName="ID" columnType="commonj.sdo.IntObject" tableName="PART"/>
+  					<ResultDescriptor columnName="NAME" columnType="commonj.sdo.String" tableName="PART"/>
+  					<ResultDescriptor columnName="QUANTITY" columnType="commonj.sdo.IntObject" tableName="PART"/>
+  					<ResultDescriptor columnName="PARENT_ID" columnType="commonj.sdo.IntObject" tableName="PART"/>
+  					
+  					<ResultDescriptor columnName="ID" columnType="commonj.sdo.IntObject" tableName="PART"/>
+  					<ResultDescriptor columnName="NAME" columnType="commonj.sdo.String" tableName="PART"/>
+  					<ResultDescriptor columnName="QUANTITY" columnType="commonj.sdo.IntObject" tableName="PART"/>
+  					<ResultDescriptor columnName="PARENT_ID" columnType="commonj.sdo.IntObject" tableName="PART"/>
+  					
+  </Command>
   
   <Table tableName="PART">
   	<Column columnName="ID" primaryKey="true"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message