tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdan...@apache.org
Subject svn commit: r451460 [4/6] - in /incubator/tuscany/java/das/rdb/src: main/java/org/apache/tuscany/das/rdb/ main/java/org/apache/tuscany/das/rdb/config/wrapper/ main/java/org/apache/tuscany/das/rdb/generator/impl/ main/java/org/apache/tuscany/das/rdb/gra...
Date Fri, 29 Sep 2006 21:36:41 GMT
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?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- 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 Fri Sep 29 14:36:37 2006
@@ -38,61 +38,60 @@
         super(sqlString, config, null);
         Iterator i = params.iterator();
         for (int idx = 1; i.hasNext(); idx++) {
-			Parameter p = (Parameter) i.next();
+            Parameter p = (Parameter) i.next();
 
-			int index = p.getColumnType().lastIndexOf('.');
-			String pkg = p.getColumnType().substring(0, index);
-			String typeName = p.getColumnType().substring(index + 1);
-
-			Type sdoType = TypeHelper.INSTANCE.getType(pkg, typeName);
-
-
-			int direction = ParameterImpl.IN;
-			if ("OUT".equalsIgnoreCase(p.getDirection()))
-				direction = ParameterImpl.OUT;
-			else if ("INOUT".equalsIgnoreCase(p.getDirection()))
-				direction = ParameterImpl.IN_OUT;
-			parameters.findOrCreateParameterWithIndex(idx, direction, sdoType);
-		}
+            int index = p.getColumnType().lastIndexOf('.');
+            String pkg = p.getColumnType().substring(0, index);
+            String typeName = p.getColumnType().substring(index + 1);
+
+            Type sdoType = TypeHelper.INSTANCE.getType(pkg, typeName);
+
+            int direction = ParameterImpl.IN;
+            if ("OUT".equalsIgnoreCase(p.getDirection()))
+                direction = ParameterImpl.OUT;
+            else if ("INOUT".equalsIgnoreCase(p.getDirection()))
+                direction = ParameterImpl.IN_OUT;
+            parameters.findOrCreateParameterWithIndex(idx, direction, sdoType);
+        }
 
     }
 
-	public DataObject executeQuery() {
+    public DataObject executeQuery() {
 
-		boolean success = false;
-		try {
-			List results = statement.executeCall(parameters);
-			success = true;
-
-			return buildGraph(results);
-		} catch (SQLException e) {
-            if(this.logger.isDebugEnabled())
+        boolean success = false;
+        try {
+            List results = statement.executeCall(parameters);
+            success = true;
+
+            return buildGraph(results);
+        } catch (SQLException e) {
+            if (this.logger.isDebugEnabled())
                 this.logger.debug(e);
 
-			throw new RuntimeException(e);
-		} finally {
-			if (success)
-				statement.getConnection().cleanUp();
-			else
-				statement.getConnection().errorCleanUp();
-		}
-	}
-
-	public void execute() {
-
-		boolean success = false;
-		try {
-			statement.executeUpdateCall(parameters);
-			success = true;
-		} catch (SQLException e) {
-			throw new RuntimeException(e);
-		} finally {
-			if (success)
-				statement.getConnection().cleanUp();
-			else
-				statement.getConnection().errorCleanUp();
-		}
+            throw new RuntimeException(e);
+        } finally {
+            if (success)
+                statement.getConnection().cleanUp();
+            else
+                statement.getConnection().errorCleanUp();
+        }
+    }
+
+    public void execute() {
 
-	}
+        boolean success = false;
+        try {
+            statement.executeUpdateCall(parameters);
+            success = true;
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (success)
+                statement.getConnection().cleanUp();
+            else
+                statement.getConnection().errorCleanUp();
+        }
+
+    }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Statement.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Statement.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Statement.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Statement.java Fri Sep 29 14:36:37 2006
@@ -33,18 +33,19 @@
 
 // TODO - Can use some refactoring. Much code is duplicated in "execute" methods
 public class Statement {
-    private final Logger logger = LoggerFactory.INSTANCE.getLogger(Statement.class);
 
     protected final String queryString;
 
     protected ConnectionImpl jdbcConnection;
 
+    private final Logger logger = LoggerFactory.INSTANCE.getLogger(Statement.class);
+    
     private PreparedStatement preparedStatement;
 
-    private boolean isPaging = false;
+    private boolean isPaging;
 
     public Statement(String sqlString) {
-        this.queryString = sqlString; 
+        this.queryString = sqlString;
     }
 
     public List executeQuery(Parameters parameters) throws SQLException {
@@ -58,41 +59,41 @@
 
     public List executeCall(Parameters parameters) throws SQLException {
 
-            CallableStatement cs = jdbcConnection.prepareCall(queryString);
+        CallableStatement cs = jdbcConnection.prepareCall(queryString);
 
-            Iterator inParams = parameters.inParams().iterator();
-            while (inParams.hasNext()) {
-                ParameterImpl param = (ParameterImpl) inParams.next();
-                cs.setObject(param.getIndex(), param.getValue());
-            }
+        Iterator inParams = parameters.inParams().iterator();
+        while (inParams.hasNext()) {
+            ParameterImpl param = (ParameterImpl) inParams.next();
+            cs.setObject(param.getIndex(), param.getValue());
+        }
 
-            // register out parameters
-            Iterator outParams = parameters.outParams().iterator();
-            while (outParams.hasNext()) {
-                ParameterImpl param = (ParameterImpl) outParams.next();
-                if(this.logger.isDebugEnabled())
-                    this.logger.debug("Registering parameter " + param.getName());
+        // register out parameters
+        Iterator outParams = parameters.outParams().iterator();
+        while (outParams.hasNext()) {
+            ParameterImpl param = (ParameterImpl) outParams.next();
+            if (this.logger.isDebugEnabled())
+                this.logger.debug("Registering parameter " + param.getName());
 
-                cs.registerOutParameter(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType()));
-            }
+            cs.registerOutParameter(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType()));
+        }
 
-            // Using execute because Derby does not currenlty support
-            // executeQuery
-            // for SP
-            cs.execute();
-            ArrayList results = new ArrayList();
+        // Using execute because Derby does not currenlty support
+        // executeQuery
+        // for SP
+        cs.execute();
+        List results = new ArrayList();
+        results.add(cs.getResultSet());
+        while (cs.getMoreResults(java.sql.Statement.KEEP_CURRENT_RESULT)) {
             results.add(cs.getResultSet());
-            while ( cs.getMoreResults(java.sql.Statement.KEEP_CURRENT_RESULT) ) {
-            	results.add(cs.getResultSet());
-            }
+        }
 
-            Iterator i = parameters.outParams().iterator();
-            while (i.hasNext()) {
-                ParameterImpl param = (ParameterImpl) i.next();
-                param.setValue(cs.getObject(param.getIndex()));
-            }
+        Iterator i = parameters.outParams().iterator();
+        while (i.hasNext()) {
+            ParameterImpl param = (ParameterImpl) i.next();
+            param.setValue(cs.getObject(param.getIndex()));
+        }
 
-            return results;
+        return results;
 
     }
 
@@ -110,7 +111,7 @@
         while (outParams.hasNext()) {
             ParameterImpl param = (ParameterImpl) outParams.next();
 
-            if(this.logger.isDebugEnabled())
+            if (this.logger.isDebugEnabled())
                 this.logger.debug("Registering parameter " + param.getName());
 
             cs.registerOutParameter(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType()));
@@ -127,37 +128,37 @@
     }
 
     public int executeUpdate(Parameters parameters, String[] generatedKeys) throws SQLException {
-    	return executeUpdate(getPreparedStatement(generatedKeys), parameters);
+        return executeUpdate(getPreparedStatement(generatedKeys), parameters);
     }
-    
+
     public int executeUpdate(Parameters parameters) throws SQLException {
-    	return executeUpdate(parameters, new String[0]);
+        return executeUpdate(parameters, new String[0]);
     }
-    
+
     /**
      * TODO - We need to look at using specific ps.setXXX methods when a type
      * has been specified and try setObject otherwise.
      */
     private int executeUpdate(PreparedStatement ps, Parameters parameters) throws SQLException {
-        if(this.logger.isDebugEnabled())
+        if (this.logger.isDebugEnabled())
             this.logger.debug("Executing statement " + queryString);
-      
+
         Iterator i = parameters.inParams().iterator();
         while (i.hasNext()) {
             ParameterImpl param = (ParameterImpl) i.next();
 
             Object value = param.getValue();
-            if(this.logger.isDebugEnabled())
+            if (this.logger.isDebugEnabled())
                 this.logger.debug("Setting parameter " + param.getIndex() + " to " + value);
 
             if (value == null) {
                 if (param.getType() == null) {
-                	try {
-                		ParameterMetaData pmd = ps.getParameterMetaData();
-                		ps.setNull(param.getIndex(), pmd.getParameterType(param.getIndex()));
-                	} catch (SQLException ex) {
-                		ps.setNull(param.getIndex(), SDODataTypeHelper.sqlTypeFor(null));
-                	}
+                    try {
+                        ParameterMetaData pmd = ps.getParameterMetaData();
+                        ps.setNull(param.getIndex(), pmd.getParameterType(param.getIndex()));
+                    } catch (SQLException ex) {
+                        ps.setNull(param.getIndex(), SDODataTypeHelper.sqlTypeFor(null));
+                    }
                 } else
                     ps.setNull(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType()));
             } else {
@@ -197,11 +198,11 @@
 
     public Integer getGeneratedKey() throws SQLException {
 
-    	if ( getConnection().useGetGeneratedKeys() ) {
-    		ResultSet rs = preparedStatement.getGeneratedKeys();
-    		if (rs.next())
-          	  return new Integer(rs.getInt(1));
-    	}
+        if (getConnection().useGetGeneratedKeys()) {
+            ResultSet rs = preparedStatement.getGeneratedKeys();
+            if (rs.next())
+                return new Integer(rs.getInt(1));
+        }
 
         return null;
     }

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateCommandImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateCommandImpl.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateCommandImpl.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateCommandImpl.java Fri Sep 29 14:36:37 2006
@@ -22,13 +22,13 @@
 
 public class UpdateCommandImpl extends WriteCommandImpl {
 
-	public UpdateCommandImpl(String sqlString) {
-		super(sqlString);
-	}
-	
-	public UpdateCommandImpl(Update update) {
-		super(update.getSql());
-		addParameters(update.getParameters());
-	}
+    public UpdateCommandImpl(String sqlString) {
+        super(sqlString);
+    }
+
+    public UpdateCommandImpl(Update update) {
+        super(update.getSql());
+        addParameters(update.getParameters());
+    }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateList.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateList.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateList.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateList.java Fri Sep 29 14:36:37 2006
@@ -20,6 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 /**
  * Updates don't have to be sorted, so this class is a simple wrapper of ArrayList. 
@@ -27,18 +28,18 @@
  */
 public class UpdateList {
 
-	private ArrayList updates = new ArrayList();
+    private List updates = new ArrayList();
 
-	public UpdateList() {
-		super();
-	}
+    public UpdateList() {
+        super();
+    }
 
-	public void add(ChangeOperation c) {
-		updates .add(c);
-	}
+    public void add(ChangeOperation c) {
+        updates.add(c);
+    }
 
-	public Collection getSortedList() {
-		return updates;
-	}
+    public Collection getSortedList() {
+        return updates;
+    }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateOperation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateOperation.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateOperation.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateOperation.java Fri Sep 29 14:36:37 2006
@@ -24,9 +24,9 @@
 
 public class UpdateOperation extends ChangeOperation {
 
-	public UpdateOperation(UpdateCommandImpl command, DataObject changedObject, String id) {
-		super(command, changedObject);
-		this.propagatedID = id;
-	}
+    public UpdateOperation(UpdateCommandImpl command, DataObject changedObject, String id) {
+        super(command, changedObject);
+        this.propagatedID = id;
+    }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/WriteCommandImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/WriteCommandImpl.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/WriteCommandImpl.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/WriteCommandImpl.java Fri Sep 29 14:36:37 2006
@@ -26,60 +26,60 @@
 import commonj.sdo.DataObject;
 
 public abstract class WriteCommandImpl extends CommandImpl {
-	
 
-	public WriteCommandImpl(String sqlString) {
-		super(sqlString);
-	}	
-
-	public void execute() {
-
-		boolean success = false;
-		try {
-			statement.executeUpdate(parameters);		
-			success = true;
-		} catch (SQLException e) {
-			throw new RuntimeException(e);
-		} finally {
-			if (success)
-				statement.getConnection().cleanUp();
-			else
-				statement.getConnection().errorCleanUp();
-		}
-
-	}
-
-	public DataObject executeQuery() {
-		throw new UnsupportedOperationException();
-	}
-
-	public Config getMappingModel() {
-		return configWrapper.getConfig();
-	}
-
-	
-	public String toString() {
-		
-		StringBuffer buffer = new StringBuffer();
-		buffer.append("\nSQL: " + statement.queryString);
-		
-		return buffer.toString();
-	}
-
-	public int getGeneratedKey() {
-			throw new RuntimeException("No generated key is available");
-	}
-
-	public void addParameters(String parameters) {
-		StringTokenizer tokenizer = new StringTokenizer(parameters);
-		for (int idx=1; tokenizer.hasMoreTokens(); idx++) {
-			ParameterImpl p = new ParameterImpl();
-			p.setName(tokenizer.nextToken());		
-			p.setIndex(idx);
-			addParameter(p);
-		}
-	}
-	
+
+    public WriteCommandImpl(String sqlString) {
+        super(sqlString);
+    }
+
+    public void execute() {
+
+        boolean success = false;
+        try {
+            statement.executeUpdate(parameters);
+            success = true;
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (success) {
+                statement.getConnection().cleanUp();
+            } else {
+                statement.getConnection().errorCleanUp();
+            }
+        }
+
+    }
+
+    public DataObject executeQuery() {
+        throw new UnsupportedOperationException();
+    }
+
+    public Config getMappingModel() {
+        return configWrapper.getConfig();
+    }
+
+    public String toString() {
+
+        StringBuffer buffer = new StringBuffer();
+        buffer.append("\nSQL: " + statement.queryString);
+
+        return buffer.toString();
+    }
+
+    public int getGeneratedKey() {
+        throw new RuntimeException("No generated key is available");
+    }
+
+    public void addParameters(String parameters) {
+        StringTokenizer tokenizer = new StringTokenizer(parameters);
+        for (int idx = 1; tokenizer.hasMoreTokens(); idx++) {
+            ParameterImpl p = new ParameterImpl();
+            p.setName(tokenizer.nextToken());
+            p.setIndex(idx);
+            addParameter(p);
+        }
+    }
+
 
 
 }

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/merge/impl/GraphMerger.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/merge/impl/GraphMerger.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/merge/impl/GraphMerger.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/merge/impl/GraphMerger.java Fri Sep 29 14:36:37 2006
@@ -22,6 +22,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.logging.Logger;
 
 import org.apache.tuscany.das.rdb.config.Config;
@@ -40,171 +41,151 @@
 
 public class GraphMerger {
 
-	private HashMap keys = new HashMap();
+    private static Logger logger = Logger.getLogger("GraphMerger");
 
-	private TableRegistry registry = new MultiTableRegistry();
+    private Map keys = new HashMap();
 
-	private static Logger logger = Logger.getLogger("GraphMerger");
+    private TableRegistry registry = new MultiTableRegistry();
 
-	//TODO lots of cleanup/design
-	public GraphMerger() {
-		// Empty Constructor
-	}
-
-		// TODO Replace EMF reference with SDOUtil function when available
-		// (Tuscany-583)
-	public DataObject emptyGraph(Config config) {
-
-		if (config.getDataObjectModel() == null)
-			throw new RuntimeException(
-					"DataObjectModel must be specified in the Config");
-
-		String uri = "http:///org.apache.tuscany.das.rdb/das";
-		TypeHelper typeHelper = SDOUtil.createTypeHelper();
-		Type rootType = SDOUtil.createType(typeHelper, uri + "/DataGraphRoot",
-				"DataGraphRoot", false);
-
-		List types = SDOUtil.getTypes(typeHelper, config.getDataObjectModel());
-		if ( types == null )
-			throw new RuntimeException("SDO Types have not been registered for URI " + config.getDataObjectModel());
-		
-		Iterator i = types.iterator();
-		while (i.hasNext()) {
-			Type type = (Type) i.next();
-			Property property = SDOUtil.createProperty(rootType,
-					type.getName(), type);
-			SDOUtil.setContainment(property, true);
-			SDOUtil.setMany(property, true);
-		}
-
-		// Create the DataGraph
-		DataGraph g = SDOUtil.createDataGraph();
-
-		// Create the root object
-		g.createRootObject(rootType);
-
-		ChangeSummary summary = g.getChangeSummary();
-		summary.beginLogging();
-
-		return g.getRootObject();
-	}
-	public DataObject merge(List graphs) {
-		DataObject primaryGraph = (DataObject) graphs.get(0);
-
-		Iterator i = graphs.iterator();
-		if (i.hasNext())
-			i.next();
-		while (i.hasNext()) {
-			primaryGraph = merge(primaryGraph, (DataObject) i.next());
-		}
-
-		return primaryGraph;
-	}
-
-	public DataObject merge(DataObject primary, DataObject secondary) {
-		addGraphToRegistry(primary);
-
-		ChangeSummary summary =  primary
-				.getDataGraph().getChangeSummary();
-		summary.endLogging();
-		Iterator i = secondary.getType().getProperties().iterator();
-
-		while (i.hasNext()) {
-			Property p = (Property) i.next();
-
-			Iterator objects = secondary.getList(p.getName()).iterator();
-			while (objects.hasNext()) {
-				DataObject object = (DataObject) objects.next();
-				createObjectWithSubtree(primary, p, object);
-			}
-		}
-		((ChangeSummaryImpl)summary).resumeLogging();
-		return primary;
-	}
-
-	private void createObjectWithSubtree(DataObject root, Property p,
-			DataObject object) {
-		Object pk = getPrimaryKey(object);
-
-		if (!registry.contains(object.getType().getName(), Collections
-				.singletonList(pk))) {
-	//		logger.info("creating " + object.getType().getName() + " with pk " + pk);
-			DataObject newObject = root.createDataObject(p.getName());
-
-			
-
-			Iterator attrs = object.getType().getProperties().iterator();
-			while (attrs.hasNext()) {
-				Property attr = (Property) attrs.next();
-				if ( attr.getType().isDataType()) {
-					newObject.set(attr.getName(), object.get(attr));
-				} 
-			}
-			registry.put(object.getType().getName(), Collections
-					.singletonList(pk), newObject);
-
-			Iterator refs = object.getType().getProperties().iterator();
-			while (refs.hasNext()) {
-				Property ref = (Property) refs.next();
-				if ( !ref.getType().isDataType()) {
-					List refObjects;
-					if (!ref.isMany()) {
-						refObjects = Collections.singletonList(object.get(ref));
-					} else {
-						refObjects = (List) object.get(ref);
-					}
-
-					Iterator iter = refObjects.iterator();
-					while (iter.hasNext()) {
-						DataObject refObject = (DataObject) iter.next();
-						createObjectWithSubtree(root, refObject
-							.getContainmentProperty(), refObject);
-					
-						refObject = registry.get(refObject.getType().getName(), Collections.singletonList(getPrimaryKey(refObject)));
-						if (ref.isMany()) {
-							newObject.getList(
-								newObject.getType().getProperty(ref.getName()))
-								.add(refObject);
-						} else
-							newObject.set(newObject.getType().getProperty(
-									ref.getName()), refObject);
-					}
-				}
-
-			}
-
-		}
-	
-	}
-
-	private void addGraphToRegistry(DataObject graph1) {
-		Iterator i = graph1.getType().getProperties().iterator();
-		while (i.hasNext()) {
-			Property p = (Property) i.next();
-			Iterator objects = graph1.getList(p).iterator();
-			while (objects.hasNext()) {
-				DataObject object = (DataObject) objects.next();
-				Object pk = object.get(getPrimaryKeyName(object));
-				logger.finest("Adding object with pk " + pk + " to registry");
-				registry.put(object.getType().getName(), Collections
-						.singletonList(pk), object);
-			}
-		}
-	}
-
-	private Object getPrimaryKey(DataObject object) {
-		String pkName = getPrimaryKeyName(object);
-		return object.get(pkName);
-	}
-
-	private String getPrimaryKeyName(DataObject object) {
-		return (String) keys.get(object.getType().getName());
-	}
-
-	public void addPrimaryKey(String key) {
-		QualifiedColumn column = new QualifiedColumn(key);
-		logger.finest("Adding " + column.getTableName() + " "
-				+ column.getColumnName() + " to keys");
-		keys.put(column.getTableName(), column.getColumnName());
-	}
+    // TODO lots of cleanup/design
+    public GraphMerger() {
+        // Empty Constructor
+    }
+
+    // TODO Replace EMF reference with SDOUtil function when available
+    // (Tuscany-583)
+    public DataObject emptyGraph(Config config) {
+
+        if (config.getDataObjectModel() == null)
+            throw new RuntimeException("DataObjectModel must be specified in the Config");
+
+        String uri = "http:///org.apache.tuscany.das.rdb/das";
+        TypeHelper typeHelper = SDOUtil.createTypeHelper();
+        Type rootType = SDOUtil.createType(typeHelper, uri + "/DataGraphRoot", "DataGraphRoot", false);
+
+        List types = SDOUtil.getTypes(typeHelper, config.getDataObjectModel());
+        if (types == null)
+            throw new RuntimeException("SDO Types have not been registered for URI " + config.getDataObjectModel());
+
+        Iterator i = types.iterator();
+        while (i.hasNext()) {
+            Type type = (Type) i.next();
+            Property property = SDOUtil.createProperty(rootType, type.getName(), type);
+            SDOUtil.setContainment(property, true);
+            SDOUtil.setMany(property, true);
+        }
+
+        // Create the DataGraph
+        DataGraph g = SDOUtil.createDataGraph();
+
+        // Create the root object
+        g.createRootObject(rootType);
+
+        ChangeSummary summary = g.getChangeSummary();
+        summary.beginLogging();
+
+        return g.getRootObject();
+    }
+
+    public DataObject merge(List graphs) {
+        DataObject primaryGraph = (DataObject) graphs.get(0);
+
+        Iterator i = graphs.iterator();
+        if (i.hasNext())
+            i.next();
+        while (i.hasNext()) {
+            primaryGraph = merge(primaryGraph, (DataObject) i.next());
+        }
+
+        return primaryGraph;
+    }
+
+    public DataObject merge(DataObject primary, DataObject secondary) {
+        addGraphToRegistry(primary);
+
+        ChangeSummary summary = primary.getDataGraph().getChangeSummary();
+        summary.endLogging();
+        Iterator i = secondary.getType().getProperties().iterator();
+
+        while (i.hasNext()) {
+            Property p = (Property) i.next();
+
+            Iterator objects = secondary.getList(p.getName()).iterator();
+            while (objects.hasNext()) {
+                DataObject object = (DataObject) objects.next();
+                createObjectWithSubtree(primary, p, object);
+            }
+        }
+        ((ChangeSummaryImpl) summary).resumeLogging();
+        return primary;
+    }
+
+    private void createObjectWithSubtree(DataObject root, Property p, DataObject object) {
+        Object pk = getPrimaryKey(object);
+
+        if (!registry.contains(object.getType().getName(), Collections.singletonList(pk))) {
+            DataObject newObject = root.createDataObject(p.getName());
+            Iterator attrs = object.getType().getProperties().iterator();
+            while (attrs.hasNext()) {
+                Property attr = (Property) attrs.next();
+                if (attr.getType().isDataType()) {
+                    newObject.set(attr.getName(), object.get(attr));
+                }
+            }
+            registry.put(object.getType().getName(), Collections.singletonList(pk), newObject);
+            Iterator refs = object.getType().getProperties().iterator();
+            while (refs.hasNext()) {
+                Property ref = (Property) refs.next();
+                if (!ref.getType().isDataType()) {
+                    List refObjects;
+                    if (!ref.isMany()) {
+                        refObjects = Collections.singletonList(object.get(ref));
+                    } else {
+                        refObjects = (List) object.get(ref);
+                    }
+                    Iterator iter = refObjects.iterator();
+                    while (iter.hasNext()) {
+                        DataObject refObject = (DataObject) iter.next();
+                        createObjectWithSubtree(root, refObject.getContainmentProperty(), refObject);
+                        refObject = registry.get(refObject.getType().getName(), Collections.singletonList(getPrimaryKey(refObject)));
+                        if (ref.isMany()) {
+                            newObject.getList(newObject.getType().getProperty(ref.getName())).add(refObject);
+                        } else {
+                            newObject.set(newObject.getType().getProperty(ref.getName()), refObject);
+                        }
+                    }
+                }
+            }
+        }
+
+    }
+
+    private void addGraphToRegistry(DataObject graph1) {
+        Iterator i = graph1.getType().getProperties().iterator();
+        while (i.hasNext()) {
+            Property p = (Property) i.next();
+            Iterator objects = graph1.getList(p).iterator();
+            while (objects.hasNext()) {
+                DataObject object = (DataObject) objects.next();
+                Object pk = object.get(getPrimaryKeyName(object));
+                logger.finest("Adding object with pk " + pk + " to registry");
+                registry.put(object.getType().getName(), Collections.singletonList(pk), object);
+            }
+        }
+    }
+
+    private Object getPrimaryKey(DataObject object) {
+        String pkName = getPrimaryKeyName(object);
+        return object.get(pkName);
+    }
+
+    private String getPrimaryKeyName(DataObject object) {
+        return (String) keys.get(object.getType().getName());
+    }
+
+    public void addPrimaryKey(String key) {
+        QualifiedColumn column = new QualifiedColumn(key);
+        logger.finest("Adding " + column.getTableName() + " " + column.getColumnName() + " to keys");
+        keys.put(column.getTableName(), column.getColumnName());
+    }
 }

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/ConfigUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/ConfigUtil.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/ConfigUtil.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/ConfigUtil.java Fri Sep 29 14:36:37 2006
@@ -32,13 +32,18 @@
  * instance from an InputStream
  * 
  */
-public class ConfigUtil {
+public final class ConfigUtil {
 
+    private ConfigUtil() {
+        
+    }
+    
     public static Config loadConfig(InputStream configStream) {
 
-        if (configStream == null)
-            throw new RuntimeException(
-                    "Cannot load configuration from a null InputStream. Possibly caused by an incorrect config xml file name");
+        if (configStream == null) {
+            throw new RuntimeException("Cannot load configuration from a null InputStream. "
+                    + "Possibly caused by an incorrect config xml file name");
+        }
 
         SDOUtil.registerStaticTypes(ConfigFactory.class);
         XMLHelper helper = XMLHelper.INSTANCE;

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/DataObjectUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/DataObjectUtil.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/DataObjectUtil.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/DataObjectUtil.java Fri Sep 29 14:36:37 2006
@@ -29,47 +29,51 @@
 
 /**
  */
-public class DataObjectUtil {
-	
-	//Utilities
-	public static DataObject getRestoredCopy(DataObject changedDO) {
-	    DataObject changedCopy = getCopy(changedDO);
-	    restoreAttributeValues(changedCopy, changedDO);
-	    return changedCopy;
-	}
-
-	public static DataObject getCopy(DataObject original) {
-		
-		DataObject copy = DataFactory.INSTANCE.create(original.getType());
-		
-		//Fill in values
-		Iterator i = original.getType().getProperties().iterator();
-		while (i.hasNext()) {
-			Property feature = (Property) i.next();
-			copy.set(feature, original.get(feature));
-		}
-		return copy;
-	}	
+public final class DataObjectUtil {
 
-	/**
+    private DataObjectUtil() {
+        
+    }
+    
+    // Utilities
+    public static DataObject getRestoredCopy(DataObject changedDO) {
+        DataObject changedCopy = getCopy(changedDO);
+        restoreAttributeValues(changedCopy, changedDO);
+        return changedCopy;
+    }
+
+    public static DataObject getCopy(DataObject original) {
+
+        DataObject copy = DataFactory.INSTANCE.create(original.getType());
+
+        // Fill in values
+        Iterator i = original.getType().getProperties().iterator();
+        while (i.hasNext()) {
+            Property feature = (Property) i.next();
+            copy.set(feature, original.get(feature));
+        }
+        return copy;
+    }
+
+    /**
      * @param changedCopy
      * @return
      */
     private static void restoreAttributeValues(DataObject changedCopy, DataObject changedDO) {
-        
-		ChangeSummary changeSummary = changedDO.getDataGraph().getChangeSummary();
-		List changes = changeSummary.getOldValues(changedDO);
-		if ( changes == null )
-			return;
-		
-		Iterator i = changes.iterator();
-		while (i.hasNext()) {
-		    Setting s = (Setting) i.next();    
-		    if ( s.getProperty().getType().isDataType() )
-		    	changedCopy.set(s.getProperty(), s.getValue());
-		}
-   }
 
-	
+        ChangeSummary changeSummary = changedDO.getDataGraph().getChangeSummary();
+        List changes = changeSummary.getOldValues(changedDO);
+        if (changes == null) {
+            return;
+        }
+
+        Iterator i = changes.iterator();
+        while (i.hasNext()) {
+            Setting s = (Setting) i.next();
+            if (s.getProperty().getType().isDataType()) {
+                changedCopy.set(s.getProperty(), s.getValue());
+            }
+        }
+    }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/LoggerFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/LoggerFactory.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/LoggerFactory.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/LoggerFactory.java Fri Sep 29 14:36:37 2006
@@ -20,7 +20,12 @@
 package org.apache.tuscany.das.rdb.util;
 
 /* Import necessary log4j API classes */
-import org.apache.log4j.*;
+import org.apache.log4j.Appender;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Layout;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
 
 /**
  * Helper class for logging using external log utility : log4j
@@ -29,13 +34,14 @@
  * @author lresende
  */
 
-public class LoggerFactory {
-    public final static LoggerFactory INSTANCE = new LoggerFactory();
-    
-    private static Layout _defaultLayout = null;
-    private static Appender _defaultAppender = null;
+public final class LoggerFactory {
+    public static final LoggerFactory INSTANCE = new LoggerFactory();
 
-    static{
+    private static Layout _defaultLayout;
+
+    private static Appender _defaultAppender;
+
+    static {
         synchronized (LoggerFactory.class) {
             _defaultLayout = new PatternLayout(LoggerLayout.Layout());
             _defaultAppender = new ConsoleAppender(_defaultLayout);
@@ -46,27 +52,26 @@
 
     }
 
-    public Logger getLogger(Class loggingClass){
-         Logger logger = Logger.getLogger(loggingClass);
-         logger.setLevel(Level.OFF);
-         logger.addAppender(_defaultAppender);
-         
-         return logger;
-     }
+    public Logger getLogger(Class loggingClass) {
+        Logger logger = Logger.getLogger(loggingClass);
+        logger.setLevel(Level.OFF);
+        logger.addAppender(_defaultAppender);
 
+        return logger;
+    }
 
-    public Logger getLogger(Class loggingClass, Level logLevel){
+    public Logger getLogger(Class loggingClass, Level logLevel) {
         Logger logger = Logger.getLogger(loggingClass);
         logger.setLevel(logLevel);
         logger.addAppender(_defaultAppender);
-        
+
         return logger;
     }
 
     public static void main(String[] args) {
-        
+
         Logger log = LoggerFactory.INSTANCE.getLogger(LoggerFactory.class);
-        if(log.isDebugEnabled()){
+        if (log.isDebugEnabled()) {
             log.debug("something");
         }
 

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/LoggerLayout.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/LoggerLayout.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/LoggerLayout.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/LoggerLayout.java Fri Sep 29 14:36:37 2006
@@ -22,10 +22,14 @@
  * Log4J layout helper for Tuscany DAS
  * @author lresende
  */
-public class LoggerLayout {
-    
-    public static String Layout(){
-        
+public final class LoggerLayout {
+
+    private LoggerLayout() {
+
+    }
+
+    public static String Layout() {
+
         /*
          *  Substitute symbols
          *  %c Logger, %c{2 } last 2 partial names
@@ -45,7 +49,7 @@
          *  Caution: %C, %F, %l, %L, %M slow down program run!
          *  Note, %n is newline
          */
-        
+
         return "[DAS RDB] - %c{1}.%M (%L) : %m %n";
     }
 

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/AliasTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/AliasTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/AliasTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/AliasTests.java Fri Sep 29 14:36:37 2006
@@ -27,140 +27,136 @@
 
 import commonj.sdo.DataObject;
 
-public class AliasTests extends DasTest{
+public class AliasTests extends DasTest {
 
     protected void setUp() throws Exception {
-    	
+    
         super.setUp();
         new BookData(getAutoConnection()).refresh();
     }
-	
+
+    /**
+     * Tests the use of column aliasing. The property name change is found in the 
+     * BooksConfig.xml file Otherwise similar to testTableAlias
+     * 
+     * @throws Exception
+     */
+    public void testColumnAlias() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConfig("BooksConfigWithAlias.xml"), getConnection());
+
+        Command select = das.getCommand("get all books");
+        // select.setConnection( getConnection() );
+
+        DataObject root = select.executeQuery();
+
+        DataObject book = root.getDataObject("Book[2]");
+        book.set("Writer", "Dr. Seuss");
+
+        das.applyChanges(root);
+
+        select = das.getCommand("get Cat in the Hat");
+
+        root = select.executeQuery();
+        // Ensure the change actually updated
+        assertEquals("Dr. Seuss", root.getString("Book[1]/Writer"));
+    }
+
+    /**
+     * Tests to ensure that columns are being properly read when using an Alias, 
+     * just a bunch of simple creating, renaming, and deleting of entries
+     * while using an alias.
+     */
+    public void testColumnData() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConfig("BooksConfigWithAlias.xml"), getConnection());
+
+        Command select = das.getCommand("get book by ID");
+        select.setParameter(1, new Integer(1));
+
+        // *******Verifys a column entry is readable
+        DataObject root = select.executeQuery();
+        assertEquals("Fyodor Dostoevsky", root.getString("Book[1]/Writer"));
+
+        DataObject bookToChange = root.getDataObject("Book[1]");
+        bookToChange.set("Writer", "Fyodor Dostoevskii"); // His last name COULD be spelt like that too!
+
+        das.applyChanges(root);
+
+        // *******Verifys correct information in entry after a column data is changed
+        select = das.getCommand("get all books");
+        // select.setConnection(getConnection());
+
+        root = select.executeQuery();
+        bookToChange = null;
+        Iterator i = root.getList("Book").iterator();
+        while (i.hasNext()) {
+            DataObject d = (DataObject) i.next();
+            if ("Fyodor Dostoevskii".equals(d.getString("Writer"))) {
+                bookToChange = d;
+            }
+        }
+        assertFalse(bookToChange == null);
+
+        bookToChange.delete();
+
+        das.applyChanges(root);
+
+        // *******Verifys correct in table, after entry is deleted
+        select = das.getCommand("get all books");
+        // select.setConnection(getConnection());
+
+        root = select.executeQuery();
+        assertEquals(1, root.getList("Book").size());
+        assertEquals("Doctor Seuss", root.getString("Book[1]/Writer"));
+    }
+
+    /**
+     * Test to check if updating a table works when using Aliasing Previously this was test_4 in ExceptionTests.
+     */
+    public void testTableAlias() throws Exception {
+
+        // Create Table config programmatically
+        // ConfigHelper helper = new ConfigHelper();
+        // helper.addTable("BOOK", "Book");
+        // helper.addPrimaryKey("BOOK.BOOK_ID");
+
+        DAS das = DAS.FACTORY.createDAS(getConfig("BooksConfigWithAlias.xml"), getConnection());
+        Command select = das.getCommand("get book by ID");
+        select.setParameter(1, new Integer(1));
+
+        DataObject root = select.executeQuery();
+
+        DataObject newBook = root.createDataObject("Book");
+        newBook.setString("NAME", "Ant Colonies of the Old World");
+        newBook.setInt("BOOK_ID", 1001);
+        root.getList("Book").add(newBook);
+
+        das.applyChanges(root);
+
+        root = select.executeQuery();
+
+        // Verify
+        select.setParameter(1, new Integer(1001));
+        root = select.executeQuery();
+
+        assertEquals("Ant Colonies of the Old World", root.getString("Book[1]/NAME"));
+    }
+
     /**
-	 * Tests the use of column aliasing. The property name change is found in the BooksConfig.xml file
-	 * Otherwise similar to testTableAlias
-	 * 
-	 * @throws Exception
-	 */
-	public void testColumnAlias() throws Exception{
-		
-		DAS das = DAS.FACTORY.createDAS( getConfig("BooksConfigWithAlias.xml") , getConnection());	   
-	    
-	    Command select = das.getCommand( "get all books" );
-	    //select.setConnection( getConnection() );
-	    
-	    DataObject root = select.executeQuery();
-	    
-	    DataObject book = root.getDataObject("Book[2]");
-	    book.set( "Writer", "Dr. Seuss");
-	    
-	    das.applyChanges( root );
-	  
-	    select = das.getCommand( "get Cat in the Hat" );
-	  
-	    
-	    root = select.executeQuery();
-	    // Ensure the change actually updated
-	    assertEquals( "Dr. Seuss", root.getString( "Book[1]/Writer" ) );
-	}
-
-	/**
-	 * Tests to ensure that columns are being properly read when using an Alias, just a bunch of simple
-	 * creating, renaming, and deleting of entries while using an alias.
-	 */
-	public void testColumnData() throws Exception {
-		
-	    DAS das = DAS.FACTORY.createDAS( getConfig("BooksConfigWithAlias.xml") , getConnection());	 
-	    
-	    Command select = das.getCommand( "get book by ID" );
-	    select.setParameter(1, new Integer(1));	
-	    
-	    //*******Verifys a column entry is readable
-	    DataObject root = select.executeQuery();
-	    assertEquals("Fyodor Dostoevsky", root.getString( "Book[1]/Writer" ) );
-	    
-	    DataObject bookToChange = root.getDataObject("Book[1]");
-	    bookToChange.set("Writer", "Fyodor Dostoevskii"); // His last name COULD be spelt like that too!
-	    
-	    das.applyChanges( root );
-	    
-	    //*******Verifys correct information in entry after a column data is changed
-	    select = das.getCommand( "get all books" );
-	    //select.setConnection(getConnection());
-	    
-	    root = select.executeQuery();
-	    bookToChange = null;
-	    Iterator i = root.getList("Book").iterator();
-	    while (i.hasNext()) {
-	    	DataObject d = (DataObject)i.next();
-	    	if ( "Fyodor Dostoevskii".equals(d.getString("Writer")) )
-	    		bookToChange = d;
-	    }
-	    assertFalse(bookToChange == null);	   
-	    	  
-	    bookToChange.delete();
-	    
-	    das.applyChanges( root );
-	    
-	    //*******Verifys correct in table, after entry is deleted
-	    select = das.getCommand( "get all books" );
-	    //select.setConnection(getConnection());
-	    
-	    root = select.executeQuery();
-	    assertEquals( 1, root.getList("Book").size() );
-	    assertEquals( "Doctor Seuss", root.getString( "Book[1]/Writer") );
-	}
-
-	/**
-	 * Test to check if updating a table works when using Aliasing
-	 * Previously this was test_4 in ExceptionTests.
-	 */
-	public void testTableAlias() throws Exception  {
-		
-	    // Create Table config programmatically
-	    //ConfigHelper helper = new ConfigHelper();
-	    //helper.addTable("BOOK", "Book");
-	    //helper.addPrimaryKey("BOOK.BOOK_ID");
-	    
-	    DAS das = DAS.FACTORY.createDAS( getConfig("BooksConfigWithAlias.xml"), getConnection() );	
-	    Command select = das.getCommand( "get book by ID" );
-	    select.setParameter(1, new Integer(1));
-	    
-	    DataObject root = select.executeQuery(); 
-	    
-	    
-	    DataObject newBook = root.createDataObject("Book");
-	    newBook.setString("NAME", "Ant Colonies of the Old World");
-	    newBook.setInt("BOOK_ID", 1001);
-	    root.getList("Book").add(newBook);
-	    
-	    
-	    das.applyChanges( root );
-	    
-	    
-	    root = select.executeQuery();
-	    
-	    //Verify
-	    select.setParameter(1, new Integer(1001));
-	    root = select.executeQuery();
-	
-	    assertEquals("Ant Colonies of the Old World", root.getString("Book[1]/NAME"));
-	 }
-	
-	/**
-	 * Test ability to assign DataObject type and propertyaliases with xml file
-	 */
-	public void testRead() throws Exception {
-
-		DAS das = DAS.FACTORY.createDAS(getConfig("customerMapping.xml"), getConnection());
-		// Read a customer
-		Command select = das.createCommand(
-				"SELECT * FROM CUSTOMER WHERE CUSTOMER.ID = 1");	
-
-		DataObject root = select.executeQuery();
-		DataObject customer = root.getDataObject("Customer[1]");
-		assertEquals(1, customer.getInt("id"));
-		assertEquals("1212 foobar lane", customer.getString("address"));
-		assertEquals("Williams", customer.getString("lastname"));
-		
-	}
+     * Test ability to assign DataObject type and propertyaliases with xml file
+     */
+    public void testRead() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConfig("customerMapping.xml"), getConnection());
+        // Read a customer
+        Command select = das.createCommand("SELECT * FROM CUSTOMER WHERE CUSTOMER.ID = 1");
+
+        DataObject root = select.executeQuery();
+        DataObject customer = root.getDataObject("Customer[1]");
+        assertEquals(1, customer.getInt("id"));
+        assertEquals("1212 foobar lane", customer.getString("address"));
+        assertEquals("Williams", customer.getString("lastname"));
+
+    }
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java Fri Sep 29 14:36:37 2006
@@ -36,72 +36,72 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        
+
         new CompanyData(getAutoConnection()).refresh();
         new DepartmentData(getAutoConnection()).refresh();
         new EmployeeData(getAutoConnection()).refresh();
         new CompanyDeptData(getAutoConnection()).refresh();
         new DepEmpData(getAutoConnection()).refresh();
-        
+
     }
 
     //Read list of companies
     public void testReadCompanies() throws Exception {
 
-        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());       
+        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());
         Command read = das.getCommand("all companies");
-        DataObject root = read.executeQuery(); 
+        DataObject root = read.executeQuery();
         assertEquals(3, root.getList("COMPANY").size());
 
     }
-    
+
     //Read list of companies
     public void testReadCompaniesWithDepartments() throws Exception {
 
-        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());       
+        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());
         Command read = das.getCommand("all companies and departments");
-        DataObject root = read.executeQuery(); 
-        
+        DataObject root = read.executeQuery();
+
         Iterator i = root.getList("COMPANY").iterator();
-        while ( i.hasNext()) {
-        	DataObject d = (DataObject) i.next();
-        	List departments = d.getList("departments");
-        	if (d.getString("NAME").equals("Do-rite plumbing") || d.getString("NAME").equals("ACME Publishing")) {        		
-            	assertEquals(0, departments.size());
-        	} else {
-        		assertEquals(1, departments.size());
-        	}
-        }            
+        while (i.hasNext()) {
+            DataObject d = (DataObject) i.next();
+            List departments = d.getList("departments");
+            if (d.getString("NAME").equals("Do-rite plumbing") || d.getString("NAME").equals("ACME Publishing")) {
+                assertEquals(0, departments.size());
+            } else {
+                assertEquals(1, departments.size());
+            }
+        }
+
+    }
 
-    }  
-    
     public void testddDepartmentToFirstCompany() throws Exception {
-        
-        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());      
+
+        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());
         Command read = das.getCommand("all companies and departments");
         DataObject root = read.executeQuery();
         DataObject firstCustomer = root.getDataObject("COMPANY[1]");
         int deptCount = firstCustomer.getList("departments").size();
-        
+
         DataObject newDepartment = root.createDataObject("DEPARTMENT");
-        firstCustomer.getList("departments").add(newDepartment); 
-        
-        das.applyChanges(root);        
-        
+        firstCustomer.getList("departments").add(newDepartment);
+
+        das.applyChanges(root);
+
         //verify
         root = read.executeQuery();
         firstCustomer = root.getDataObject("COMPANY[1]");
-        assertEquals (deptCount + 1, firstCustomer.getList("departments").size());
-    }  
-    
+        assertEquals(deptCount + 1, firstCustomer.getList("departments").size());
+    }
+
     /**
      * Test ability to correctly flush heirarchy of objects that have generated
      * keys
      */
     public void testFlushCreateHeirarchy() throws Exception {
 
-        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());       
-        Command select = das.getCommand("all companies and departments");        
+        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());
+        Command select = das.getCommand("all companies and departments");
         DataObject root = select.executeQuery();
 
         // Create a new Company
@@ -114,12 +114,12 @@
         department.setString("NAME", "Do-rite Pest Control");
         department.setString("LOCATION", "The boonies");
         department.setString("DEPNUMBER", "101");
-   
+
         // Associate the new department with the new company
         company.getList("departments").add(department);
 
         // Get apply command
-        das.applyChanges(root);      
+        das.applyChanges(root);
 
         // Save the id
         Integer id = (Integer) company.get("ID");
@@ -129,25 +129,24 @@
         select = das.getCommand("company by id with departments");
         select.setParameter(1, id);
         root = select.executeQuery();
-        assertEquals("Do-rite Pest Control", root.getDataObject("COMPANY[1]")
-                .getString("NAME"));
+        assertEquals("Do-rite Pest Control", root.getDataObject("COMPANY[1]").getString("NAME"));
 
     }
-    
+
     /**
      * Test ability to get an empty graph with the Types/Properties intact
      */
     public void testGetEmptyGraph() throws Exception {
 
-        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());      
+        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());
 
         Command select = das.getCommand("company by id with departments");
         Integer idOfNoExistingCompany = new Integer(-1);
         select.setParameter(1, idOfNoExistingCompany);
         DataObject root = select.executeQuery();
-        
+
         //Will fail if there is no property named "COMPANY"
-        assertEquals(0, root.getList("COMPANY").size()); 
+        assertEquals(0, root.getList("COMPANY").size());
 
     }
 

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CUDGeneration.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CUDGeneration.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CUDGeneration.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CUDGeneration.java Fri Sep 29 14:36:37 2006
@@ -28,86 +28,84 @@
 
 public class CUDGeneration extends DasTest {
 
-	protected void setUp() throws Exception {
-		super.setUp();
-		
-		new CustomerData(getAutoConnection()).refresh();
-		new OrderData(getAutoConnection()).refresh();
-	}
-
-	/**
-	 * This tests provides invalid SQL and should fail on Apply.execute. If not
-	 * then the engine is generating CUD and overlooking the provided
-	 * statements.
-	 */
-	public void testCUDGeneration1() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMappingWithInvalidCUD.xml"), getConnection());
-		
-		// Read customer with particular ID
-		Command select = das.createCommand("Select * from CUSTOMER where ID = 1");	
-		DataObject root = select.executeQuery();
-
-		DataObject customer = (DataObject) root.get("CUSTOMER[1]");
-
-		// Modify customer
-		customer.set("LASTNAME", "Pavick");
-
-
-		// Flush changes
-		try {
-			das.applyChanges(root);
-			fail("Should fail with invalid SQL.  Provided CUD not used!!");
-		} catch (RuntimeException e) {
-			// Everything OK
-		}
-
-	}
-
-	public void testInsertCUDGeneration() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		
-		Command select = das.createCommand("Select * from CUSTOMER where ID = 1");	
-		DataObject root = select.executeQuery();
-
-		DataObject customer = root.createDataObject("CUSTOMER");
-		customer.setInt("ID", 720);
-		customer.set("LASTNAME", "foobar");
-		customer.set("ADDRESS", "asdfasdf");
-	
-		das.applyChanges(root);
-
-		select = das.createCommand("select * from CUSTOMER where ID = 720");
-		root = select.executeQuery();
-
-		assertEquals(1, root.getList("CUSTOMER").size());
-	}
-
-	public void testReadModifyApply() throws Exception {
-
-		DAS das = DAS.FACTORY.createDAS(getConfig("1xM_mapping_no_cud.xml"), getConnection());
-		
-		// Build the select command to read a specific customer and related
-		// orders
-		Command select = das
-				.createCommand(
-						"SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
-
-		// Parameterize the command	
-		select.setParameter(1, new Integer(1));
-
-		// Get the graph
-		DataObject root = select.executeQuery();
-
-		// Modify a customer
-		DataObject customer = (DataObject) root.get("Customer[1]");
-		customer.set("LASTNAME", "Pavick");
-
-		// Modify an order
-		DataObject order = (DataObject) customer.get("orders[1]");
-		order.setString("PRODUCT", "Kitchen Sink 001");
-	
-		das.applyChanges(root);
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        new CustomerData(getAutoConnection()).refresh();
+        new OrderData(getAutoConnection()).refresh();
+    }
+
+    /**
+     * This tests provides invalid SQL and should fail on Apply.execute. If not 
+     * then the engine is generating CUD and overlooking the provided
+     * statements.
+     */
+    public void testCUDGeneration1() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMappingWithInvalidCUD.xml"), getConnection());
+
+        // Read customer with particular ID
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
+        DataObject root = select.executeQuery();
+
+        DataObject customer = (DataObject) root.get("CUSTOMER[1]");
+
+        // Modify customer
+        customer.set("LASTNAME", "Pavick");
+
+        // Flush changes
+        try {
+            das.applyChanges(root);
+            fail("Should fail with invalid SQL.  Provided CUD not used!!");
+        } catch (RuntimeException e) {
+            // Everything OK
+        }
+
+    }
+
+    public void testInsertCUDGeneration() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
+        DataObject root = select.executeQuery();
+
+        DataObject customer = root.createDataObject("CUSTOMER");
+        customer.setInt("ID", 720);
+        customer.set("LASTNAME", "foobar");
+        customer.set("ADDRESS", "asdfasdf");
+
+        das.applyChanges(root);
+
+        select = das.createCommand("select * from CUSTOMER where ID = 720");
+        root = select.executeQuery();
+
+        assertEquals(1, root.getList("CUSTOMER").size());
+    }
+
+    public void testReadModifyApply() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConfig("1xM_mapping_no_cud.xml"), getConnection());
+
+        // Build the select command to read a specific customer and related
+        // orders
+        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON " 
+                + "CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
+
+        // Parameterize the command
+        select.setParameter(1, new Integer(1));
+
+        // Get the graph
+        DataObject root = select.executeQuery();
+
+        // Modify a customer
+        DataObject customer = (DataObject) root.get("Customer[1]");
+        customer.set("LASTNAME", "Pavick");
+
+        // Modify an order
+        DataObject order = (DataObject) customer.get("orders[1]");
+        order.setString("PRODUCT", "Kitchen Sink 001");
+
+        das.applyChanges(root);
+
+    }
 
-	}
-	
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CommandGroupTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CommandGroupTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CommandGroupTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CommandGroupTests.java Fri Sep 29 14:36:37 2006
@@ -35,21 +35,16 @@
 
 /**
  * 
- * This tests use of the XML Config file. Tests will utilize the
- * customer-orders-orderdetails tables. The plan is for the config file to have
- * a section that applies to all commands and another that applies to specific
- * commands.
+ * This tests use of the XML Config file. Tests will utilize the customer-orders-orderdetails tables. The plan is for the config file to have a
+ * section that applies to all commands and another that applies to specific commands.
  * 
- * The config file will be used to initialize a command factory that will then
- * return named commands.
+ * The config file will be used to initialize a command factory that will then return named commands.
  * 
  * There will be two read commands:
  * 
- * 1) Return all customers 2) Return a specific customer (by ID) and related
- * orders and order details
+ * 1) Return all customers 2) Return a specific customer (by ID) and related orders and order details
  * 
- * A test will demonstrate the creation of the factory and then reuse of
- * commands created from the same config data file
+ * A test will demonstrate the creation of the factory and then reuse of commands created from the same config data file
  * 
  */
 public class CommandGroupTests extends DasTest {
@@ -66,11 +61,11 @@
     }
 
     /**
-     * Read 
+     * Read
      */
     public void testRead() throws Exception {
 
-        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());       
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
 
         Command read = das.getCommand("all customers");
         DataObject root = read.executeQuery();
@@ -80,11 +75,11 @@
     }
 
     /**
-     * Read 
+     * Read
      */
     public void testReadUsingConfigInput() throws Exception {
-    	Config config = ConfigUtil.loadConfig(getConfig("CustomersOrdersConfig.xml"));
-        DAS das = DAS.FACTORY.createDAS(config, getConnection());       
+        Config config = ConfigUtil.loadConfig(getConfig("CustomersOrdersConfig.xml"));
+        DAS das = DAS.FACTORY.createDAS(config, getConnection());
 
         Command read = das.getCommand("all customers");
         DataObject root = read.executeQuery();
@@ -92,29 +87,29 @@
         assertEquals(5, root.getList("CUSTOMER").size());
 
     }
+
     /**
      * Read an order using parm marker
      */
     public void testReadWithParmmarker() throws Exception {
 
-        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());     
-        
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
+
         Command read = das.getCommand("order by id");
         read.setParameter(1, new Integer(1));
         DataObject root = read.executeQuery();
 
         assertEquals("recombobulator", root.getString("ANORDER[1]/PRODUCT"));
 
-    }   
-    
+    }
 
     /**
      * Specify connection properties in config. Add explicit update command
      */
     public void testUpdate() throws Exception {
 
-        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());       
-        
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
+
         Command read = das.getCommand("all customers");
         DataObject root = read.executeQuery();
         // Verify precondition
@@ -132,13 +127,12 @@
     }
 
     /**
-     * Read all customers, select a specific customer. Then read that customer
-     * and related orders. Modify an order and flush changes back
+     * Read all customers, select a specific customer. Then read that customer and related orders. Modify an order and flush changes back
      */
     public void testRead2() throws Exception {
 
         // Create the group and set common connection
-        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());       
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
 
         // Read all customers and remember the first one
         Command read = das.getCommand("all customers");

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CompanyTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CompanyTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CompanyTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CompanyTests.java Fri Sep 29 14:36:37 2006
@@ -49,13 +49,13 @@
 
     public void testSimple() throws Exception {
 
-    	DAS das = DAS.FACTORY.createDAS(getConfig("companyMapping.xml"), getConnection());
-    	
+        DAS das = DAS.FACTORY.createDAS(getConfig("companyMapping.xml"), getConnection());
+
         // Build the select command
-        Command selectCommand = das.createCommand("select COMPANY.NAME, "
+        Command selectCommand = das.createCommand("select COMPANY.NAME, " 
                 + "EMPLOYEE.NAME, EMPLOYEE.SN, EMPLOYEE.MANAGER, "
                 + "DEPARTMENT.NAME, DEPARTMENT.LOCATION, DEPARTMENT.DEPNUMBER from COMPANY, DEPARTMENT, EMPLOYEE "
-                + "where COMPANY.ID=DEPARTMENT.COMPANYID and DEPARTMENT.ID=EMPLOYEE.DEPARTMENTID");     
+                + "where COMPANY.ID=DEPARTMENT.COMPANYID and DEPARTMENT.ID=EMPLOYEE.DEPARTMENTID");
 
         // Get the graph
         DataObject root = selectCommand.executeQuery();
@@ -74,19 +74,17 @@
 
     public void testSimpleStatic() throws Exception {
 
-    	DAS das = DAS.FACTORY.createDAS(getConfig("companyMappingWithConverters.xml"), getConnection());
-    	SDOUtil.registerStaticTypes(CompanyFactory.class);
+        DAS das = DAS.FACTORY.createDAS(getConfig("companyMappingWithConverters.xml"), getConnection());
+        SDOUtil.registerStaticTypes(CompanyFactory.class);
         // Build the select command
-        Command selectCommand = das.createCommand("select COMPANY.NAME, "
+        Command selectCommand = das.createCommand("select COMPANY.NAME, " 
                 + "EMPLOYEE.NAME, EMPLOYEE.SN, EMPLOYEE.MANAGER, "
                 + "DEPARTMENT.NAME, DEPARTMENT.LOCATION, DEPARTMENT.DEPNUMBER from COMPANY, DEPARTMENT, EMPLOYEE "
                 + "where COMPANY.ID=DEPARTMENT.COMPANYID and DEPARTMENT.ID=EMPLOYEE.DEPARTMENTID");
-        
 
         // Get the graph
         DataObject root = selectCommand.executeQuery();
-        
-        
+
         CompanyType company = (CompanyType) root.getList("CompanyType").get(0);
 
         assertEquals("MegaCorp", company.getName());

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CompoundKeyTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CompoundKeyTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CompoundKeyTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CompoundKeyTests.java Fri Sep 29 14:36:37 2006
@@ -43,10 +43,8 @@
     }
 
     public void testRead() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConnection());
-        Command getOrderDetails = das
-                .createCommand("Select * from ORDERDETAILS where ORDERID = ? AND PRODUCTID = ?");
-       
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command getOrderDetails = das.createCommand("Select * from ORDERDETAILS where ORDERID = ? AND PRODUCTID = ?");
 
         getOrderDetails.setParameter(1, new Integer(1));
         getOrderDetails.setParameter(2, new Integer(1));
@@ -59,10 +57,9 @@
     }
 
     public void testReadModifyWrite2() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConfig("OrdersOrderDetailsConfig.xml"), getConnection());
-        Command getOrderDetails = das
-                .createCommand("Select * from ORDERDETAILS where ORDERID = 1 AND PRODUCTID = 1");
-     
+        DAS das = DAS.FACTORY.createDAS(getConfig("OrdersOrderDetailsConfig.xml"), getConnection());
+        Command getOrderDetails = das.createCommand("Select * from ORDERDETAILS where ORDERID = 1 AND PRODUCTID = 1");
+
         DataObject root = getOrderDetails.executeQuery();
 
         DataObject orderDetails = (DataObject) root.get("ORDERDETAILS[1]");
@@ -72,8 +69,8 @@
         orderDetails.setFloat("PRICE", 0f);
 
         // Build apply changes command
-       
-        das.applyChanges(root);        
+
+        das.applyChanges(root);
 
         // Verify
         root = getOrderDetails.executeQuery();
@@ -81,11 +78,10 @@
         assertEquals(0f, orderDetails.getFloat("PRICE"), 0.01);
 
     }
-    
+
     public void testReadOrdersAndDetails2() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConfig("OrdersOrderDetailsConfig.xml"), getConnection());
-        Command read = das
-                .createCommand("SELECT * FROM ANORDER LEFT JOIN ORDERDETAILS ON ANORDER.ID = ORDERDETAILS.ORDERID ORDER BY ANORDER.ID");      
+        DAS das = DAS.FACTORY.createDAS(getConfig("OrdersOrderDetailsConfig.xml"), getConnection());
+        Command read = das.createCommand("SELECT * FROM ANORDER LEFT JOIN ORDERDETAILS ON ANORDER.ID = ORDERDETAILS.ORDERID ORDER BY ANORDER.ID");
 
         DataObject root = read.executeQuery();
 
@@ -94,12 +90,10 @@
         assertEquals(2, firstOrder.getList("ORDERDETAILS").size());
 
     }
-    
+
     public void testReadAndDelete() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConfig("OrdersOrderDetailsConfig.xml"), getConnection());
-        Command getOrderDetails = das
-                .createCommand("Select * from ORDERDETAILS where ORDERID = ? AND PRODUCTID = ?");
-       
+        DAS das = DAS.FACTORY.createDAS(getConfig("OrdersOrderDetailsConfig.xml"), getConnection());
+        Command getOrderDetails = das.createCommand("Select * from ORDERDETAILS where ORDERID = ? AND PRODUCTID = ?");
 
         getOrderDetails.setParameter(1, new Integer(1));
         getOrderDetails.setParameter(2, new Integer(1));
@@ -108,7 +102,7 @@
 
         DataObject orderDetail = (DataObject) root.get("ORDERDETAILS[1]");
         orderDetail.delete();
-        das.applyChanges(root);      
+        das.applyChanges(root);
 
     }
 }

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?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- 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 Fri Sep 29 14:36:37 2006
@@ -38,125 +38,114 @@
  */
 public class ConverterTests extends DasTest {
 
-	
-	protected void setUp() throws Exception {
-		super.setUp();
-		new CustomerData(getAutoConnection()).refresh();
-	}
-
-
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-	
-	private static DateFormat myformat = new SimpleDateFormat("yyyy.MM.dd"); 
-
-	private static Date kbday;
-	private static Date tbday;
-	
-	static {
-		try {
-			kbday = myformat.parse("1957.09.27");
-			tbday = myformat.parse("1966.12.20");
-		} catch (ParseException e) {
-			throw new RuntimeException(e);
-		}
-	}
-	
-	
-
-	/**
-	 * This tests the use of an arbitrary converter.  The column converted is a VARCAHAR.
-	 * ResultSetShape is used to specify that the property will be a SDODataTypes.DATE.
-	 * 
-	 * So this example uses a converter that transforms a string column into a date property
-	 * and conversely, a date property back to a string for the underlying column.
-	 * 
-	 * The converter returns 1957.09.27 if the column value is "Williams" and 1966.12.20
-	 * if the value is "Pavick"
-	 * 
-	 * On write, the converter returns "Pavick" if the property value is 1966.12.20
-	 * and "Williams" if the property value is 1957.09.27
-	 * 
-	 */
-	public void testArbitraryConverter() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConfig("CustomerConfigWithConverter.xml"), getConnection());
-		
-		//Create and initialize command to read customers
-		Command read = das.getCommand("testArbitraryConverter");			
-
-		//Read
-		DataObject root = read.executeQuery();
-		
-		//Verify 
-		assertEquals(kbday, root.getDate("CUSTOMER[1]/LASTNAME"));
-		
-		//Modify
-		root.setDate("CUSTOMER[1]/LASTNAME", tbday);	
-		
-		das.applyChanges(root);		
-		
-		//Read
-		root = read.executeQuery();
-
-		//Verify 
-		assertEquals(tbday, root.getDate("CUSTOMER[1]/LASTNAME"));
-		
-	}
-	
-	public void testInvalidConverter1() throws Exception {
-
-		DAS das = DAS.FACTORY.createDAS(getConfig("InvalidConverter.xml"), getConnection());
-		
-		// Build the select command to read a specific customer and related
-		// orders
-		Command select = das
-				.createCommand(
-						"SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
-
-		// Parameterize the command	
-		select.setParameter(1, new Integer(1));
-
-		// Get the graph
-		try {
-			select.executeQuery();
-		} catch (Exception ex) {
-			assertEquals("java.lang.ClassNotFoundException: not.a.valid.class", ex.getMessage());
-		}
-
-	
-	}
-	
-	public void testInvalidConverter2() throws Exception {
-
-		SDOUtil.registerStaticTypes(CustomerFactory.class);
-		DAS das = DAS.FACTORY.createDAS(getConfig("InvalidConverter.xml"), getConnection());
-		
-		// Build the select command to read a specific customer and related
-		// orders
-		Command select = das
-				.createCommand(
-						"SELECT * FROM ANORDER");	
-
-		// Get the graph
-		
-		DataObject root = select.executeQuery();
-		DataObject order = root.getDataObject("AnOrder[1]");
-		
-		Customer customer = (Customer) root.createDataObject("Customer");
-		customer.setID(700);
-		customer.setLastName("Daniel");
-		customer.setAddress("an address");		
-		
-		customer.getOrders().add(order);	
-		
-		try {
-			das.applyChanges(root);
-		} catch (Exception ex) {
-			assertEquals("java.lang.ClassNotFoundException: not.a.valid.class", ex.getMessage());
-		}
-
-	
-	}
-	
+    private static DateFormat myformat = new SimpleDateFormat("yyyy.MM.dd");
+
+    private static Date kbday;
+
+    private static Date tbday;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        new CustomerData(getAutoConnection()).refresh();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    static {
+        try {
+            kbday = myformat.parse("1957.09.27");
+            tbday = myformat.parse("1966.12.20");
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * This tests the use of an arbitrary converter. The column converted is a VARCAHAR. ResultSetShape is used to specify that the property will be a
+     * SDODataTypes.DATE.
+     * 
+     * So this example uses a converter that transforms a string column into a date property and conversely, a date property back to a string for the
+     * underlying column.
+     * 
+     * The converter returns 1957.09.27 if the column value is "Williams" and 1966.12.20 if the value is "Pavick"
+     * 
+     * On write, the converter returns "Pavick" if the property value is 1966.12.20 and "Williams" if the property value is 1957.09.27
+     * 
+     */
+    public void testArbitraryConverter() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomerConfigWithConverter.xml"), getConnection());
+
+        // Create and initialize command to read customers
+        Command read = das.getCommand("testArbitraryConverter");
+
+        // Read
+        DataObject root = read.executeQuery();
+
+        // Verify
+        assertEquals(kbday, root.getDate("CUSTOMER[1]/LASTNAME"));
+
+        // Modify
+        root.setDate("CUSTOMER[1]/LASTNAME", tbday);
+
+        das.applyChanges(root);
+
+        // Read
+        root = read.executeQuery();
+
+        // Verify
+        assertEquals(tbday, root.getDate("CUSTOMER[1]/LASTNAME"));
+
+    }
+
+    public void testInvalidConverter1() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConfig("InvalidConverter.xml"), getConnection());
+
+        // Build the select command to read a specific customer and related
+        // orders
+        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
+
+        // Parameterize the command
+        select.setParameter(1, new Integer(1));
+
+        // Get the graph
+        try {
+            select.executeQuery();
+        } catch (Exception ex) {
+            assertEquals("java.lang.ClassNotFoundException: not.a.valid.class", ex.getMessage());
+        }
+
+    }
+
+    public void testInvalidConverter2() throws Exception {
+
+        SDOUtil.registerStaticTypes(CustomerFactory.class);
+        DAS das = DAS.FACTORY.createDAS(getConfig("InvalidConverter.xml"), getConnection());
+
+        // Build the select command to read a specific customer and related
+        // orders
+        Command select = das.createCommand("SELECT * FROM ANORDER");
+
+        // Get the graph
+
+        DataObject root = select.executeQuery();
+        DataObject order = root.getDataObject("AnOrder[1]");
+
+        Customer customer = (Customer) root.createDataObject("Customer");
+        customer.setID(700);
+        customer.setLastName("Daniel");
+        customer.setAddress("an address");
+
+        customer.getOrders().add(order);
+
+        try {
+            das.applyChanges(root);
+        } catch (Exception ex) {
+            assertEquals("java.lang.ClassNotFoundException: not.a.valid.class", ex.getMessage());
+        }
+
+    }
+
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CorrectedDefectTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CorrectedDefectTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CorrectedDefectTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CorrectedDefectTests.java Fri Sep 29 14:36:37 2006
@@ -61,10 +61,9 @@
      * Dilton's bug for adding new child data object
      */
     public void testAddNewOrder() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
         // Read some customers and related orders
-        Command select = das.createCommand(
-                "SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID");       
+        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID");
 
         DataObject root = select.executeQuery();
 
@@ -83,14 +82,13 @@
         cust.getList("orders").add(order);
 
         assertEquals(custOrderCount + 1, cust.getList("orders").size());
-        
+
         // Build apply changes command      
-        das.applyChanges(root);       
+        das.applyChanges(root);
 
         // verify cust1 relationship updates
-        select = das
-                .createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
-      
+        select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
+
         select.setParameter(1, new Integer(custID));
         root = select.executeQuery();
 
@@ -110,11 +108,11 @@
         DAS das = DAS.FACTORY.createDAS(getConnection());
         Command insert = das.createCommand(sql);
         insert.setParameter(1, new Integer(316405209));
-        insert.setParameter(2, "2005-11-23 19:29:52.636");   
+        insert.setParameter(2, "2005-11-23 19:29:52.636");
         insert.execute();
 
         // Verify
-        Command select = das.createCommand("Select * from conmgt.SERVERSTATUS");      
+        Command select = das.createCommand("Select * from conmgt.SERVERSTATUS");
         DataObject root = select.executeQuery();
         assertEquals(1, root.getList("SERVERSTATUS").size());
 
@@ -123,8 +121,7 @@
     public void testWASDefect330118() throws Exception {
 
         // Create the group and set common connection
-        DAS das = DAS.FACTORY
-                .createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());       
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
 
         // Read all customers and add one
         Command read = das.getCommand("all customers");
@@ -139,7 +136,7 @@
         // Now delete this new customer
         newCust.delete();
 
-        das.applyChanges(root);     
+        das.applyChanges(root);
 
         // Verify
         root = read.executeQuery();
@@ -152,15 +149,15 @@
      * that the parameter type is set.
      */
     public void testDiltonsNullParameterBug1() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConnection());
-        Command insert = das.createCommand("insert into CUSTOMER values (?, ?, ?)");      
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command insert = das.createCommand("insert into CUSTOMER values (?, ?, ?)");
         insert.setParameter(1, new Integer(10));
         insert.setParameter(2, null);
         insert.setParameter(3, "5528 Wells Fargo Dr");
         insert.execute();
-        
+
         // Verify
-        Command select = das.createCommand("Select * from CUSTOMER where ID = 10");     
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 10");
         DataObject root = select.executeQuery();
         assertEquals(1, root.getList("CUSTOMER").size());
         assertEquals("5528 Wells Fargo Dr", root.get("CUSTOMER[1]/ADDRESS"));
@@ -171,8 +168,8 @@
      * Error by not setting a parameter
      */
     public void testDiltonsNullParameterBug2() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConnection());
-        Command insert = das.createCommand("insert into CUSTOMER values (?, ?, ?)");       
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command insert = das.createCommand("insert into CUSTOMER values (?, ?, ?)");
         insert.setParameter(1, new Integer(10));
         // insert.setParameterValue("LASTNAME", null);
         insert.setParameter(3, "5528 Wells Fargo Dr");
@@ -189,15 +186,15 @@
      * Set parameter to empty string
      */
     public void testDiltonsNullParameterBug3() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConnection());
-        Command insert = das.createCommand("insert into CUSTOMER values (?, ?, ?)");    
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command insert = das.createCommand("insert into CUSTOMER values (?, ?, ?)");
         insert.setParameter(1, new Integer(10));
         insert.setParameter(2, "");
         insert.setParameter(3, "5528 Wells Fargo Dr");
         insert.execute();
 
         // Verify
-        Command select = das.createCommand("Select * from CUSTOMER where ID = 10");     
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 10");
         DataObject root = select.executeQuery();
         assertEquals(1, root.getList("CUSTOMER").size());
         assertEquals("5528 Wells Fargo Dr", root.get("CUSTOMER[1]/ADDRESS"));
@@ -206,8 +203,8 @@
 
     public void testUpdateChildThatHasGeneratedKey() throws Exception {
 
-        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());    
-        
+        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());
+
         // Read a specific company based on the known ID
         Command readCust = das.getCommand("all companies and departments");
         DataObject root = readCust.executeQuery();
@@ -224,7 +221,7 @@
             random = random + 1;
         }
 
-        das.applyChanges(root);        
+        das.applyChanges(root);
     }
 
     /**
@@ -238,15 +235,14 @@
      */
     public void testYingChen12162005() throws Exception {
         DAS das = DAS.FACTORY.createDAS(getConnection());
-        Command insert = das
-                .createCommand("insert into CUSTOMER values (?, ?, ?)");       
+        Command insert = das.createCommand("insert into CUSTOMER values (?, ?, ?)");
         insert.setParameter(1, new Integer(10));
         insert.setParameter(2, "Williams");
         insert.setParameter(3, null);
         insert.execute();
 
         // Verify
-        Command select = das.createCommand("Select * from CUSTOMER where ID = 10");      
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 10");
         DataObject root = select.executeQuery();
         assertEquals(1, root.getList("CUSTOMER").size());
         assertNull(root.get("CUSTOMER[1]/ADDRESS"));
@@ -257,55 +253,50 @@
      * Formely tests concerning Tuscany-433. The error causing these tests was cleared up when
      * the method for handling parameters was changed.
      */
-    public void testReadModifyApply()
-        throws Exception
-    {
-
+    public void testReadModifyApply() throws Exception {
 
         // Provide updatecommand programmatically via config
         ConfigHelper helper = new ConfigHelper();
         Table customerTable = helper.addTable("CUSTOMER", "CUSTOMER");
-        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ? where ID = ?", "LASTNAME ID");         
-        
-    	DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
-    	
+        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ? where ID = ?", "LASTNAME ID");
+
+        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
+
         //Read customer 1
-        Command select = das.createCommand( "Select * from CUSTOMER where ID = 1" );        
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
         DataObject root = select.executeQuery();
 
-        DataObject customer = (DataObject) root.get( "CUSTOMER[1]" );
+        DataObject customer = (DataObject) root.get("CUSTOMER[1]");
 
         //Modify customer
-        customer.set( "LASTNAME", "Pavick" );
+        customer.set("LASTNAME", "Pavick");
 
-        das.applyChanges( root );
+        das.applyChanges(root);
 
         //Verify changes
         root = select.executeQuery();
-        assertEquals( "Pavick", root.getString( "CUSTOMER[1]/LASTNAME" ) );
+        assertEquals("Pavick", root.getString("CUSTOMER[1]/LASTNAME"));
 
     }
 
-    public void testReadModifyApply1()
-        throws Exception
-    {
-    	DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMappingWithCUD2.xml"), getConnection());
+    public void testReadModifyApply1() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMappingWithCUD2.xml"), getConnection());
         //Read customer 1
-        Command select = das.createCommand( "Select * from CUSTOMER where ID = 1" );       
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
         DataObject root = select.executeQuery();
 
-        DataObject customer = (DataObject) root.get( "CUSTOMER[1]" );
+        DataObject customer = (DataObject) root.get("CUSTOMER[1]");
 
         //Modify customer
-        customer.set( "LASTNAME", "Pavick" );
+        customer.set("LASTNAME", "Pavick");
 
         //Build apply changes command
-        das.applyChanges( root );
+        das.applyChanges(root);
 
         //Verify changes
         root = select.executeQuery();
-        assertEquals( "Pavick", root.getString( "CUSTOMER[1]/LASTNAME" ) );
+        assertEquals("Pavick", root.getString("CUSTOMER[1]/LASTNAME"));
 
-    }    
+    }
 
 }



---------------------------------------------------------------------
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