You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ad...@apache.org on 2007/09/30 03:36:25 UTC

svn commit: r580668 [2/2] - in /incubator/tuscany/cpp/das: ./ VSExpress/tuscany_das/ VSExpress/tuscany_das/das_runtime/ VSExpress/tuscany_das/das_test/ antscripts/ runtime/core/include/apache/das/ runtime/core/include/apache/das/rdb/ runtime/core/src/a...

Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASDataObject.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASDataObject.cpp?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASDataObject.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASDataObject.cpp Sat Sep 29 18:36:21 2007
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+#include "apache/das/rdb/ModifiedDataObject.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+DASDataObject::DASDataObject(const Table& table, commonj::sdo::DataObjectPtr dataObject, 
+			commonj::sdo::ChangeSummaryPtr changeSummary) : PKObject(table) {
+	
+	commonj::sdo::SettingList& settingList = changeSummary->getOldValues(dataObject);
+	std::map<std::string, const commonj::sdo::Setting*> settingMap;
+	const std::map<std::string, const Column*> columns = table.getColumns();
+	std::string statement;
+	unsigned int pkColumnCount = table.getPKColumnCount();
+	unsigned int pkCount = 0;
+
+	for (int i = 0 ; i < settingList.size() ; i++) {
+		settingMap.insert(std::make_pair(settingList[i].getProperty().getName(), &settingList[i]));
+	}
+
+	for (std::map<std::string, const Column*>::const_iterator columnsIterator = columns.begin() ;
+		columnsIterator != columns.end() && pkColumnCount > pkCount ; columnsIterator++) {
+
+			const Column& column = *columnsIterator->second;
+			std::map<std::string, const commonj::sdo::Setting*>::const_iterator settingIterator = 
+				settingMap.find(column.getPropertyName());
+
+			if (settingIterator != settingMap.end()) {
+				addPrimaryKey(column.getPropertyName(), 
+					*(new ColumnData(column, *settingIterator->second)));
+
+			} else {
+				addPrimaryKey(column.getPropertyName(), 
+					*(new ColumnData(column, dataObject)));
+
+			}
+
+	}
+	
+}
+
+void DASDataObject::printStmt() {
+	std::cout << "[" << getTable().getTableName() << "]" << std::endl;
+
+	for (std::list<std::string>::iterator it = updateStatements.begin() ; it != updateStatements.end() ; it++) {
+		std::cout << *it << std::endl;
+	}
+
+	std::cout << std::endl;
+
+}
+
+const commonj::sdo::DataObjectPtr DASDataObject::getDataObject(void) const {
+	return dataObject;
+}
+
+void DASDataObject::executeStatements(StatementPtr stmt) const {
+	
+	for (std::list<std::string>::const_iterator it = updateStatements.begin() ; it != updateStatements.end() ; it++) {
+		stmt->executeQuery(*it);	
+	}
+
+}
+
+void DASDataObject::appendStatement(std::string statement) {
+	updateStatements.push_back(statement);
+}
+
+void DASDataObject::pushStatement(std::string statement) {
+	updateStatements.push_front(statement);
+}
+
+		};
+	};
+};

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASImpl.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASImpl.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASImpl.cpp Sat Sep 29 18:36:21 2007
@@ -95,7 +95,7 @@
         case 'S':
             command = new ReadCommandImpl(*this, sql);
             break;
-     
+		
     }
 
 	std::list<CommandPtr*>::iterator it;
@@ -136,6 +136,10 @@
 
 const ::apache::das::Config& DASImpl::getConfig(void) const {
 	return *((Config*) config);
+}
+
+void DASImpl::applyChanges(commonj::sdo::DataObjectPtr root) {
+	ApplyChanges(*config, root);
 }
 
 		};

Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASInvalidSDOTypeException.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASInvalidSDOTypeException.cpp?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASInvalidSDOTypeException.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASInvalidSDOTypeException.cpp Sat Sep 29 18:36:21 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *   
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "apache/das/rdb/DASInvalidSDOTypeException.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+DASInvalidSDOTypeException::DASInvalidSDOTypeException(std::string message) : std::exception(message.c_str()) {}
+
+DASInvalidSDOTypeException::~DASInvalidSDOTypeException(void) {}
+
+		};
+	};
+};

Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASPrimaryKeyNotFoundException.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASPrimaryKeyNotFoundException.cpp?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASPrimaryKeyNotFoundException.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DASPrimaryKeyNotFoundException.cpp Sat Sep 29 18:36:21 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *   
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "apache/das/rdb/DASPrimaryKeyNotFoundException.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+DASPrimaryKeyNotFoundException::DASPrimaryKeyNotFoundException(std::string message) : std::exception(message.c_str()) {}
+
+DASPrimaryKeyNotFoundException::~DASPrimaryKeyNotFoundException(void) {}
+
+		};
+	};
+};

Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DeteledDataObject.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DeteledDataObject.cpp?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DeteledDataObject.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/DeteledDataObject.cpp Sat Sep 29 18:36:21 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+#include "apache/das/rdb/DeletedDataObject.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+DeletedDataObject::DeletedDataObject(const Table& table, commonj::sdo::DataObjectPtr dataObject, 
+										commonj::sdo::ChangeSummaryPtr changeSummary)
+									: DASDataObject(table, dataObject, changeSummary) {
+	
+	std::string statement;
+	statement.append("delete from ").append(table.getTableName()).append(" where ");
+	const KeyDataList& columnDataList = getPrimaryKeys();
+	unsigned int pkCount = 0;
+	unsigned int pkColumnCount = columnDataList.size();
+	
+	for (KeyDataList::const_iterator columnDataListIterator = columnDataList.begin() ;
+		columnDataListIterator != columnDataList.end() ; columnDataListIterator++) {
+
+			ColumnData& columnData = *columnDataListIterator->second;
+			statement.append(columnData.getColumn().getName()).append("=").append(columnData.toSQL());
+			pkCount++;
+
+			if (pkCount != pkColumnCount) {
+				statement.append(" and ");
+			}
+
+	}
+
+	
+	appendStatement(statement.append(";"));
+	
+}
+
+		};
+	};
+};

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/GraphBuilder.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/GraphBuilder.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/GraphBuilder.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/GraphBuilder.cpp Sat Sep 29 18:36:21 2007
@@ -25,7 +25,7 @@
 GraphBuilder::GraphBuilder(const ConfigImpl& config, ResultSetPtr resultSet) {
 	graphBuilderMetaData = new GraphBuilderMetaData(config, resultSet->getResultSetMetaData()) ;
 	commonj::sdo::DataFactoryPtr dataFactory = graphBuilderMetaData->createGraph();
-
+	
 	this->resultSet = resultSet;
 	const std::map<std::string, Table*>& tables = graphBuilderMetaData->getTables();
 	

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/GraphBuilderMetaData.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/GraphBuilderMetaData.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/GraphBuilderMetaData.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/GraphBuilderMetaData.cpp Sat Sep 29 18:36:21 2007
@@ -238,6 +238,7 @@
 commonj::sdo::DataFactoryPtr GraphBuilderMetaData::createGraph(void) const {
 	commonj::sdo::DataFactoryPtr dataFactory = commonj::sdo::DataFactory::getDataFactory();
 	dataFactory->addType(DAS_NAMESPACE, DAS_ROOT_NAME);
+	dataFactory->addPropertyToType(DAS_NAMESPACE, DAS_ROOT_NAME, "ChangeSummary", SDO_NAMESPACE, "ChangeSummary", false, false, true);
 	
 	std::map<std::string, Table*>::const_iterator it;
 	std::map<std::string, Relationship*>::const_iterator it2;

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/KeyPair.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/KeyPair.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/KeyPair.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/KeyPair.cpp Sat Sep 29 18:36:21 2007
@@ -30,14 +30,16 @@
 }
 
 KeyPair::KeyPair(std::string pkColumnName, std::string fkColumnName) {
-	pkColumnName = StringWrapper::toLower(pkColumnName);
-	fkColumnName = StringWrapper::toLower(fkColumnName);
-
-	if (!StringWrapper::isValidRDBName(pkColumnName)) {
+	StringWrapper pkColumnNameWrapper(pkColumnName);
+	pkColumnName = pkColumnNameWrapper.toLower();
+	StringWrapper fkColumnNameWrapper(fkColumnName);
+	fkColumnName = fkColumnNameWrapper.toLower();
+	
+	if (!pkColumnNameWrapper.isValidRDBName()) {
 		throw DASInvalidColumnNameException("PK column name must not contain whitespace characters!");
 	}
 
-	if (!StringWrapper::isValidRDBName(fkColumnName)) {
+	if (!fkColumnNameWrapper.isValidRDBName()) {
 		throw DASInvalidColumnNameException("FK column name must not contain whitespace characters!");
 	}
 

Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ModifiedDataObject.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ModifiedDataObject.cpp?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ModifiedDataObject.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ModifiedDataObject.cpp Sat Sep 29 18:36:21 2007
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+#include "apache/das/rdb/ModifiedDataObject.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+ModifiedDataObject::ModifiedDataObject(const Table& table, commonj::sdo::DataObjectPtr dataObject, 
+			commonj::sdo::ChangeSummaryPtr changeSummary) : DASDataObject(table, dataObject, changeSummary) {
+	
+	std::string statement;
+	statement.append("update ").append(table.getTableName()).append(" set");
+	const KeyDataList& columnDataList = getPrimaryKeys();
+	unsigned int pkCount = 0;
+	unsigned int pkColumnCount = columnDataList.size();
+
+	commonj::sdo::SettingList& settings = changeSummary->getOldValues(dataObject);
+
+	for (int i = 0 ; i < settings.size() ; i++) {
+		std::string propName = settings[i].getProperty().getName();
+		const Column* column = table.getColumnByProperty(propName);
+		
+		KeyDataList::const_iterator it = columnDataList.find(column->getName());
+
+		if (it == columnDataList.end()) {
+			sets.append(" ").append(column->getName()).append("=").append(ColumnData(*column, dataObject).toSQL()).append(",");
+		}
+
+	}
+	
+	pkWhere = " where ";
+
+	for (KeyDataList::const_iterator columnDataListIterator = columnDataList.begin() ;
+		columnDataListIterator != columnDataList.end() ; columnDataListIterator++) {
+
+			ColumnData& columnData = *columnDataListIterator->second;
+			pkWhere.append(columnData.getColumn().getName()).append("=").append(columnData.toSQL());
+			pkCount++;
+
+			if (pkCount != pkColumnCount) {
+				pkWhere.append(" and ");
+			}
+
+	}
+
+	pkWhere.append(";");
+	
+}
+
+void ModifiedDataObject::setFK(std::string relationshipName, const KeyDataList* keyDataList) {
+
+	if (keyDataList == 0) {
+		std::map<std::string, const KeyDataList*>::const_iterator it = fks.find(relationshipName);
+
+		if (it != fks.end() && it->second != 0) {
+			return;
+		}
+
+	}
+
+	fks.insert(std::make_pair(relationshipName, keyDataList));
+
+}
+
+		};
+	};
+};

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ODBCTypeHelper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ODBCTypeHelper.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ODBCTypeHelper.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ODBCTypeHelper.cpp Sat Sep 29 18:36:21 2007
@@ -27,7 +27,7 @@
 	switch (sqlType) {
 	
 		case SQL_INTEGER :
-			return "Integer";
+			return "Int";
 
 		case SQL_REAL :
 			return "Float";
@@ -37,6 +37,7 @@
 			return "Double";
 
 		case SQL_VARCHAR :
+		case SQL_WVARCHAR :
 			return "String";
 
 		default :
@@ -46,8 +47,29 @@
 
 }
 
+const SQLSMALLINT ODBCTypeHelper::getSQLType(const commonj::sdo::Type& type) {
+	std::string typeName = type.getName();
+
+	if ("String" == typeName) {
+		return SQL_VARCHAR;
+
+	} else if ("Double" == typeName) {
+		return SQL_DOUBLE;
+
+	} else if ("Float" == typeName) {
+		return SQL_REAL;
+
+	} else if ("Int" == typeName) {
+		return SQL_INTEGER;
+
+	} else {
+		throw DASInvalidSDOTypeException((std::string) "Invalid sdo data type: " + type.getURI() + "." + type.getName() + "");
+	}
+
+}
+
 const SQLSMALLINT ODBCTypeHelper::getSQLType(std::string sqlTypeName) {
-	sqlTypeName = StringWrapper::toLower(sqlTypeName); 
+	sqlTypeName = StringWrapper(sqlTypeName).toLower(); 
 	
 	if ("varchar" == sqlTypeName) {
 		return SQL_VARCHAR;

Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/PKObject.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/PKObject.cpp?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/PKObject.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/PKObject.cpp Sat Sep 29 18:36:21 2007
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+#include "apache/das/rdb/PKObject.h"
+#include "apache/das/rdb/ColumnData.h"
+
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+PKObject::PKObject(const Table& table) {
+	this->table = &table;
+	primaryKeys = new KeyDataList();
+	
+}
+
+PKObject::~PKObject(void) {
+	KeyDataList::const_iterator it;
+	
+	for (it = primaryKeys->begin() ; it != primaryKeys->end() ; it++) {
+		delete it->second;
+	}
+
+	delete primaryKeys;
+
+}
+
+void PKObject::addPrimaryKey(std::string columnName, ColumnData& columnData) {
+	primaryKeys->insert(std::make_pair(columnName, &columnData));
+}
+
+const Table& PKObject::getTable(void) const {
+	return *table;
+}
+
+bool PKObject::isPK(std::string columnName) const {
+	KeyDataList::const_iterator it = primaryKeys->find(columnName);
+
+	return it != primaryKeys->end();
+	
+}
+
+bool PKObject::operator==(const KeyDataList* primaryKeyList) const {
+	
+	if (primaryKeys->size() != primaryKeyList->size()) {
+		return false;
+	}
+
+	KeyDataList::const_iterator it, primaryKeyIterator;
+	
+	for (it = primaryKeyList->begin() ; it != primaryKeyList->end() ; it++) {
+		primaryKeyIterator = primaryKeys->find(it->first);
+
+		if (primaryKeyIterator == primaryKeys->end())  {
+			return false;
+
+		} else if (*it->second != *primaryKeyIterator->second) {
+			return false;
+
+		}
+
+	}
+
+	return true;
+	
+}
+
+bool PKObject::operator==(const PKObject& pkObject) const {
+	return (*this == pkObject.primaryKeys);
+}
+
+bool PKObject::operator!=(const PKObject& pkObject) const {
+	return !(*this == pkObject);
+}
+
+bool PKObject::operator!=(const KeyDataList* primaryKeyList) const {
+	return !(*this == primaryKeyList);
+}
+
+const KeyDataList& PKObject::getPrimaryKeys(void) const {
+	return *primaryKeys;
+}
+
+bool PKObject::operator<(const PKObject& pkObject) const {
+	return (*this < pkObject.primaryKeys);
+}
+
+bool PKObject::operator<(const KeyDataList* primaryKeyList) const {
+	
+	if (primaryKeys->size() < primaryKeyList->size()) {
+		return true;
+	} else if (primaryKeys->size() > primaryKeyList->size()) {
+		return false;
+	}
+
+	KeyDataList::const_iterator it;
+	
+	for (it = primaryKeyList->begin() ; it != primaryKeyList->end() ; it++) {
+		KeyDataList::const_iterator primaryKeyIterator = 
+			primaryKeys->find(it->first);
+
+		if (primaryKeyIterator != primaryKeys->end()) {
+
+			if (*it->second < *primaryKeyIterator->second) {
+				return true;
+			} else if (*it->second > *primaryKeyIterator->second) {
+				return false;
+			}
+
+		}
+
+	}
+
+	return false;
+
+}
+
+bool KeyDataCmp::operator() ( const KeyDataList* keyDataList1, const KeyDataList* keyDataList2 ) const {
+	if (keyDataList1->size() < keyDataList2->size()) {
+		return true;
+	} else if (keyDataList1->size() > keyDataList2->size()) {
+		return false;
+	}
+
+	KeyDataList::const_iterator it;
+	
+	for (it = keyDataList2->begin() ; it != keyDataList2->end() ; it++) {
+		KeyDataList::const_iterator primaryKeyIterator = 
+			keyDataList1->find(it->first);
+
+		if (primaryKeyIterator != keyDataList1->end()) {
+
+			if (it->second->getColumn().getSQLType() != primaryKeyIterator->second->getColumn().getSQLType()) {
+				return false;
+			}
+
+			if (*it->second < *primaryKeyIterator->second) {
+				return true;
+			} else if (*it->second > *primaryKeyIterator->second) {
+				return false;
+			}
+
+		}
+
+	}
+
+	return false;
+
+}
+
+		};
+	};
+};

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ReadCommandImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ReadCommandImpl.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ReadCommandImpl.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ReadCommandImpl.cpp Sat Sep 29 18:36:21 2007
@@ -29,6 +29,7 @@
 commonj::sdo::DataObjectPtr ReadCommandImpl::executeQuery(void) {
 	ResultSetPtr results = statement->executeQuery(sql);
 	commonj::sdo::DataObjectPtr root = buildGraph(results);
+	root->getChangeSummary()->beginLogging();
 
 	return root;
     
@@ -36,7 +37,7 @@
 
 commonj::sdo::DataObjectPtr ReadCommandImpl::buildGraph(ResultSetPtr resultSet) {
 	GraphBuilder graphBuilder((ConfigImpl&) ((DASImpl*) das)->getConfig(), resultSet); 
-		
+
 	return graphBuilder.getRoot();
 
 }

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Relationship.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Relationship.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Relationship.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Relationship.cpp Sat Sep 29 18:36:21 2007
@@ -42,26 +42,29 @@
 Relationship::Relationship(std::string pkTableName, std::string fkTableName, 
 						   std::string relationshipName) {
 
-    pkTableName = StringWrapper::toLower(pkTableName);
-	fkTableName = StringWrapper::toLower(fkTableName);
+    StringWrapper pkTableNameWrapper(pkTableName);
+	StringWrapper fkTableNameWrapper(fkTableName);
+	StringWrapper relationshipNameWrapper(relationshipName);
+    pkTableName = pkTableNameWrapper.toLower();
+	fkTableName = fkTableNameWrapper.toLower();
 
     if (relationshipName == "") {
 		this->relationshipName = fkTableName;
     } else {
 
-		if (!StringWrapper::isValidRDBName(relationshipName)) {
+		if (!relationshipNameWrapper.isValidRDBName()) {
 			throw DASInvalidRelationshipNameException("Relationship name must not contain whitespace characters!");
 		}
 
-		this->relationshipName = StringWrapper::toLower(relationshipName);
+		this->relationshipName = relationshipNameWrapper.toLower();
 
     }
 
-	if (!StringWrapper::isValidRDBName(pkTableName)) {
+	if (!pkTableNameWrapper.isValidRDBName()) {
 		throw DASInvalidTableNameException("PK Table name must not contain whitespace characters!");
 	}
 
-	if (!StringWrapper::isValidRDBName(fkTableName)) {
+	if (!fkTableNameWrapper.isValidRDBName()) {
 		throw DASInvalidTableNameException("FK Table name must not contain whitespace characters!");
 	}
 

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ResultSetMetaData.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ResultSetMetaData.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ResultSetMetaData.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ResultSetMetaData.cpp Sat Sep 29 18:36:21 2007
@@ -27,8 +27,8 @@
 	unsigned int columnCount = getColumnCount();
 	
 	for (unsigned int i = 0 ; i < columnCount ; i++) {
-		std::string columnName = StringWrapper::toLower(getColumnName(i));
-		std::string tableName = StringWrapper::toLower(getTableName(i));
+		std::string columnName = StringWrapper(getColumnName(i)).toLower();
+		std::string tableName = StringWrapper(getTableName(i)).toLower();
 		columnsIndexes.insert(std::make_pair(tableName + "." + columnName, i));
 
 	}
@@ -120,7 +120,7 @@
 	std::string ret((char*) sqlPtr);
 	delete [] sqlPtr;
 
-	return StringWrapper::toLower(ret);
+	return StringWrapper(ret).toLower();
 
 }
 
@@ -141,13 +141,13 @@
 	std::string ret((char*) sqlPtr);
 	delete [] sqlPtr;
 
-	return StringWrapper::toLower(ret);
+	return StringWrapper(ret).toLower();
 
 }
 
 unsigned int ResultSetMetaData::getColumnIndex(std::string tableName, std::string columnName) const {
-	tableName = StringWrapper::toLower(tableName);
-	columnName = StringWrapper::toLower(columnName);
+	tableName = StringWrapper(tableName).toLower();
+	columnName = StringWrapper(columnName).toLower();
 	std::map<std::string, unsigned int>::const_iterator it = columnsIndexes.find(tableName + "." + columnName);
 
 	if (it == columnsIndexes.end()) {
@@ -171,7 +171,7 @@
 	std::string ret((char*) sqlPtr);
 	delete [] sqlPtr;
 
-	return StringWrapper::toLower(ret);
+	return StringWrapper(ret).toLower();
 
 }
 

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Statement.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Statement.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Statement.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Statement.cpp Sat Sep 29 18:36:21 2007
@@ -57,7 +57,7 @@
 
 	std::string ret = (std::string) (char*) state;
 	ret += ": ";
-	ret += StringWrapper::to_string((long) nativeError);
+	ret += StringWrapper::toString((long) nativeError);
 	ret += " - ";
 	ret += (char*) message;
 

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Table.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Table.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Table.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Table.cpp Sat Sep 29 18:36:21 2007
@@ -23,7 +23,7 @@
 		namespace rdb {
 
 Table::Table(std::string tableName) {
-	tableName = StringWrapper::toLower(tableName);
+	tableName = StringWrapper(tableName).toLower();
 
 	if (tableName.find(' ') != -1 || tableName.find('\t') != -1 || tableName.find('\n') != -1 || tableName.find('\r') != -1) {
 		throw DASInvalidTableNameException("Table name must not contain whitespace characters!");
@@ -35,6 +35,18 @@
 
 }
 
+Table::Table(std::string tableName, std::string typeName) {
+	tableName = StringWrapper(tableName).toLower();
+
+	if (tableName.find(' ') != -1 || tableName.find('\t') != -1 || tableName.find('\n') != -1 || tableName.find('\r') != -1) {
+		throw DASInvalidTableNameException("Table name must not contain whitespace characters!");
+	}
+
+	this->tableName = tableName;
+	this->typeName = typeName;
+	this->columns = new std::map<std::string, const Column*>();
+
+}
 
 Table::Table(const Table& table) {
 	tableName = table.tableName;
@@ -62,6 +74,21 @@
 
 }
 
+const Column* Table::getColumnByProperty(std::string propertyName) const {
+	
+	for (std::map<std::string, const Column*>::const_iterator it = columns->begin() ;
+		it != columns->end() ; it++) {
+	
+			if (it->second->getPropertyName() == propertyName) {
+				return it->second;
+			}
+
+	}
+
+	return 0;
+
+}
+
 std::string Table::getTableName(void) const {
 	return tableName;
 }
@@ -141,7 +168,7 @@
 }
 
 void Table::setTypeName(std::string typeName) {
-	typeName = StringWrapper::toLower(typeName);
+	typeName = StringWrapper(typeName).toLower();
 
 	if (typeName.find(' ') != -1 || typeName.find('\t') != -1 || typeName.find('\n') != -1 || typeName.find('\r') != -1) {
 		throw DASInvalidTypeNameException("Type must not contain whitespace characters!");

Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/TableData.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/TableData.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/TableData.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/TableData.cpp Sat Sep 29 18:36:21 2007
@@ -22,13 +22,12 @@
 	namespace das {
 		namespace rdb {
 
-TableData::TableData(const Table& table, ResultSetPtr resultSet) {
-	this->table = &table;
-	primaryKeys = new KeyDataList();
+TableData::TableData(const Table& table, ResultSetPtr resultSet) : PKObject(table) {
 	dataObject = 0;
 	const std::map<std::string, const Column*>& columns = table.getColumns();
 	std::map<std::string, const Column*>::const_iterator columnIterator;
 	const ResultSetMetaData& metaData = resultSet->getResultSetMetaData();
+	const KeyDataList& primaryKeys = getPrimaryKeys();
 	
 	for (columnIterator = columns.begin() ; columnIterator != columns.end() ; 
 		columnIterator++) {
@@ -42,7 +41,7 @@
 				columnsData.insert(std::make_pair(columnName, columnData));
 
 				if (column.isPK()) {
-					primaryKeys->insert(std::make_pair(columnName, columnData));
+					addPrimaryKey(columnName, *columnData);
 				}
 
 			}
@@ -55,56 +54,18 @@
 	std::map<std::string, ColumnData*>::iterator it;
 
 	for (it = columnsData.begin() ; it != columnsData.end() ; it++) {
-		delete it->second;
-	}
-
-	delete primaryKeys;
-	
-}
-
-const Table& TableData::getTable(void) const {
-	return *table;
-}
-
-bool TableData::operator==(const KeyDataList* primaryKeyList) const {
-	
-	if (primaryKeys->size() != primaryKeyList->size()) {
-		return false;
-	}
-
-	KeyDataList::const_iterator it, primaryKeyIterator;
-	
-	for (it = primaryKeyList->begin() ; it != primaryKeyList->end() ; it++) {
-		primaryKeyIterator = primaryKeys->find(it->first);
-
-		if (primaryKeyIterator == primaryKeys->end())  {
-			return false;
-
-		} else if (*it->second != *primaryKeyIterator->second) {
-			return false;
 
+		if (!(it->second->getColumn().isPK())) {
+			delete it->second;
 		}
 
 	}
-
-	return true;
 	
 }
 
-bool TableData::operator==(const TableData& tableData) const {
-	return (*this == tableData.primaryKeys);
-}
-
-bool TableData::operator!=(const TableData& tableData) const {
-	return !(*this == tableData);
-}
-
-bool TableData::operator!=(const KeyDataList* primaryKeyList) const {
-	return !(*this == primaryKeyList);
-}
-
 bool TableData::hasPK(void) const {
-	return (primaryKeys->size() == table->getPKColumnCount() && primaryKeys->size() > 0);
+	const KeyDataList& primaryKeys = getPrimaryKeys();
+	return (primaryKeys.size() == getTable().getPKColumnCount() && primaryKeys.size() > 0);
 }
 
 commonj::sdo::DataObjectPtr TableData::getGraphObject(void) const {
@@ -112,7 +73,7 @@
 }
 
 void TableData::populateDataGraph(GraphBuilder& graphBuilder) {
-	dataObject = graphBuilder.getRoot()->createDataObject(table->getTableName().c_str());
+	dataObject = graphBuilder.getRoot()->createDataObject(getTable().getTableName().c_str());
 	std::map<std::string, ColumnData*>::iterator it;
 
 	for (it = columnsData.begin() ; it != columnsData.end() ; it++) {
@@ -121,21 +82,6 @@
 
 }
 
-const KeyDataList& TableData::getPrimaryKeys(void) const {
-	return *primaryKeys;
-}
-
-void TableData::addFK(std::string columnName) {
-	std::map<std::string, ColumnData*>::iterator it = columnsData.find(columnName);
-
-	if (it == columnsData.end()) {
-		throw DASInvalidColumnNameException("Column " + columnName + " does not exist!");
-	}
-	
-	foreignKeys.insert(std::make_pair(columnName, it->second));
-
-}
-
 ColumnData* TableData::getColumnData(std::string columnName) const {
 	std::map<std::string, ColumnData*>::const_iterator it = columnsData.find(columnName);
 
@@ -144,73 +90,6 @@
 	}
 
 	return it->second;
-
-}
-
-bool TableData::operator<(const TableData& tableData) const {
-	return (*this < tableData.primaryKeys);
-}
-
-bool TableData::operator<(const KeyDataList* primaryKeyList) const {
-	
-	if (primaryKeys->size() < primaryKeyList->size()) {
-		return true;
-	} else if (primaryKeys->size() > primaryKeyList->size()) {
-		return false;
-	}
-
-	KeyDataList::const_iterator it;
-	
-	for (it = primaryKeyList->begin() ; it != primaryKeyList->end() ; it++) {
-		KeyDataList::const_iterator primaryKeyIterator = 
-			primaryKeys->find(it->first);
-
-		if (primaryKeyIterator != primaryKeys->end()) {
-
-			if (*it->second < *primaryKeyIterator->second) {
-				return true;
-			} else if (*it->second > *primaryKeyIterator->second) {
-				return false;
-			}
-
-		}
-
-	}
-
-	return false;
-
-}
-
-bool KeyDataCmp::operator() ( const KeyDataList* keyDataList1, const KeyDataList* keyDataList2 ) const {
-	if (keyDataList1->size() < keyDataList2->size()) {
-		return true;
-	} else if (keyDataList1->size() > keyDataList2->size()) {
-		return false;
-	}
-
-	KeyDataList::const_iterator it;
-	
-	for (it = keyDataList2->begin() ; it != keyDataList2->end() ; it++) {
-		KeyDataList::const_iterator primaryKeyIterator = 
-			keyDataList1->find(it->first);
-
-		if (primaryKeyIterator != keyDataList1->end()) {
-
-			if (it->second->getColumn().getSQLType() != primaryKeyIterator->second->getColumn().getSQLType()) {
-				return false;
-			}
-
-			if (*it->second < *primaryKeyIterator->second) {
-				return true;
-			} else if (*it->second > *primaryKeyIterator->second) {
-				return false;
-			}
-
-		}
-
-	}
-
-	return false;
 
 }
 

Modified: incubator/tuscany/cpp/das/runtime/test/rsc/TestCases.fdb
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/test/rsc/TestCases.fdb?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
Binary files - no diff available.

Added: incubator/tuscany/cpp/das/runtime/test/rsc/testDeleteOperation.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/test/rsc/testDeleteOperation.xml?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/runtime/test/rsc/testDeleteOperation.xml (added)
+++ incubator/tuscany/cpp/das/runtime/test/rsc/testDeleteOperation.xml Sat Sep 29 18:36:21 2007
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+
+<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd"> 
+
+
+	<Table tableName="Department">
+		<Column columnName="id" sqlType="integer" primaryKey="true"/>
+		<Column columnName="name" sqlType="varchar" primaryKey="true"/>
+	</Table>
+
+	<Relationship primaryKeyTable="company" foreignKeyTable="department">
+      		<KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+	</Relationship>
+
+	<Relationship primaryKeyTable="department" foreignKeyTable="employee">
+      		<KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+      		<KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+	</Relationship>
+
+	
+
+</Config>
\ No newline at end of file

Modified: incubator/tuscany/cpp/das/runtime/test/src/main.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/test/src/main.cpp?rev=580668&r1=580667&r2=580668&view=diff
==============================================================================
--- incubator/tuscany/cpp/das/runtime/test/src/main.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/test/src/main.cpp Sat Sep 29 18:36:21 2007
@@ -39,6 +39,67 @@
 using namespace apache::das;
 using namespace apache::das::rdb;
 
+std::string clearDBStatements[] = {	"delete from employee",
+									"delete from department",
+									"delete from company",
+									"drop table employee",
+									"drop table department",
+									"drop table company"
+								  };
+
+std::string resetDBStatements[] = {	"create table company ( id int not null, name varchar(20), primary key(id) )",
+									"create table department ( id int not null, name varchar(20) not null, company_id int, foreign key (company_id) references company (id), primary key(id, name) )",
+									"create table employee ( id int not null, name varchar(20), department_id int, department_name varchar(20), primary key(id) )",
+									"insert into company values (1, 'apache')",
+									"insert into company values (2, 'acme')",
+									"insert into company values (3, 'google')",
+									"insert into company values (4, 'ibm')",
+									"insert into company values (5, 'yahoo')",
+									"insert into department values (1, 'department1', 1)",
+									"insert into department values (2, 'department1', 1)",
+									"insert into department values (3, 'department2', 2)",
+									"insert into department values (5, 'department3', 3)",
+									"insert into department values (4, 'department5', 2)",
+									"insert into department values (6, 'department6', 3)",
+									"insert into employee values (1, 'adriano', 1, 'department1')",
+									"insert into employee values (2, 'paul', 1, 'department1')",
+									"insert into employee values (3, 'richard', 1, 'department1')",
+									"insert into employee values (4, 'ema', 2, 'department2')",
+									"insert into employee values (5, 'james', 2, 'department2')"
+								};
+//delete from employee;
+//delete from department;
+//delete from company;
+//
+//drop table employee;
+//drop table department;
+//drop table company;
+//
+//create table company ( id int not null, name varchar(20), primary key(id) );
+//
+//create table department ( id int not null, name varchar(20) not null, company_id int, foreign key (company_id) references company (id), primary key(id, name) );
+//
+//create table employee ( id int not null, name varchar(20), department_id int, department_name varchar(20), primary key(id) );
+//
+//insert into company values (1, 'apache');
+//insert into company values (2, 'acme');
+//insert into company values (3, 'google');
+//insert into company values (4, 'ibm');
+//insert into company values (5, 'yahoo');
+//
+//insert into department values (1, 'department1', 1);
+//insert into department values (2, 'department1', 1);
+//insert into department values (3, 'department2', 2);
+//insert into department values (4, 'department5', 2);
+//insert into department values (5, 'department3', 3);
+//insert into department values (6, 'department6', 3);
+//
+//insert into employee values (1, 'adriano', 1, 'department1');
+//insert into employee values (2, 'paul', 1, 'department1');
+//insert into employee values (3, 'richard', 1, 'department1');
+//insert into employee values (4, 'ema', 2, 'department2');
+//insert into employee values (5, 'james', 2, 'department2');
+
 Connection* getConnection() {
 	char* tuscanyDASCPPPath = getenv("TUSCANY_DASCPP");
 	
@@ -49,28 +110,56 @@
 
 	}
 
+	Connection* conn;
+
 	try {
 		// Connect to a database using a connect string
-		string user = "SYSDBA";
+		/*string user = "SYSDBA";
 		string password = "masterkey";
+		string driver = "Firebird/InterBase(r) driver";
 		string dataSourcePath = (string) tuscanyDASCPPPath + "/../runtime/test/rsc/TestCases.fdb";
 
-		return new Connection((string)
-				"DRIVER=Firebird/InterBase(r) driver; " +
-				"UID=" + user + 
+		conn = new Connection((string)
+				"DRIVER=" + driver +
+				"; UID=" + user + 
 				"; PWD=" + password + 
 				";DBNAME=localhost:" + dataSourcePath + ";"
-			);
+		);*/
 
+		conn = new Connection("driver={MySQL ODBC 3.51 Driver};server=localhost;database=testcases;user=root;PWD=masterkey");
+
+		
 	} catch (SQLException& ex) {
-		cout << "couldn't connect to the data source!" << endl;
+		cout << "couldn't connect to the data source: " << ex.what() << endl;
 		system("PAUSE");
 		exit(1);
 
 	}
 
-	return 0;
+	StatementPtr stmt = conn->createStatement();
+
+	for (unsigned int i = 0 ; i < 6 ; i++) {
+
+		try {
+			stmt->executeQuery(clearDBStatements[i]);
+		} catch (SQLException& ex) {/*cout << ex.what() << endl;*/}
+
+	}
+
+	//stmt->executeQuery("commit");
+	//stmt = conn->createStatement();
+
+	for (unsigned int i = 0 ; i < 19 ; i++) {
+		stmt->executeQuery(resetDBStatements[i]);
+
+		//if (i == 2) stmt->executeQuery("commit");
+
+	}
+
+	stmt->executeQuery("commit");
 
+	return conn;
+	
 }
 
 
@@ -260,8 +349,8 @@
 
 }
 
-void testeCOCRelationship() {
-	cout << "-------------testeCOCRelationship--------------" << endl;
+void testCOCRelationship() {
+	cout << "-------------testCOCRelationship--------------" << endl;
 
 	Connection* conn = getConnection();
 	DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(*conn);
@@ -332,6 +421,32 @@
 
 }
 
+void testDeleteOperation() {
+	cout << "-------------testDeleteOperation--------------" << endl;
+
+	Connection* conn = getConnection();
+	ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testDeleteOperation.xml");
+	DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+	CommandPtr command = das->createCommand("SELECT * FROM company, department, employee;");
+	commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+	DataGraphPrinter(root).printMetaData(cout);
+	DataGraphPrinter(root).print(cout);
+
+
+	//root->getDataObject("company[1]")->getDataObject("department[1]")->detach();
+	root->getDataObject("company[1]")->detach();
+
+	commonj::sdo::ChangeSummaryPtr summary = root->getChangeSummary();
+
+	das->applyChanges(root);
+
+	delete conn;
+	
+	cout << "---------------------------------" << endl << endl;
+
+}
+
 void testManyRelationship() {
 	cout << "-------------testManyRelationship--------------" << endl;
 
@@ -388,14 +503,49 @@
 }
 
 int main() {
-	testPointers();
-	testUniqueObjectByID();
-	testIncompleteCompositeRelationship();
-	testCompositeRelationship();
-	testeCOCRelationship();
-	//testKeyPairColumnTypeNotEqual();
-	testManyRelationship();
+	
+	/*try {
+		testDeleteOperation();
+	} catch (std::exception& exp) {
+		cout << "Exception occurred: " << exp.what() << endl;
+	}*/
+	
+	try {
+		testPointers();
+	} catch (std::exception& exp) {
+		cout << "Exception occurred: " << exp.what() << endl;
+	}
+
+	try {
+		testUniqueObjectByID();
+	} catch (std::exception& exp) {
+		cout << "Exception occurred: " << exp.what() << endl;
+	}
 
+	try {
+		testIncompleteCompositeRelationship();
+	} catch (std::exception& exp) {
+		cout << "Exception occurred: " << exp.what() << endl;
+	}
+
+	try {
+		testCompositeRelationship();
+	} catch (std::exception& exp) {
+		cout << "Exception occurred: " << exp.what() << endl;
+	}
+
+	try {
+		testCOCRelationship();
+	} catch (std::exception& exp) {
+		cout << "Exception occurred: " << exp.what() << endl;
+	}
+
+	try {
+		testManyRelationship();
+	} catch (std::exception& exp) {
+		cout << "Exception occurred: " << exp.what() << endl;
+	}
+	
 	system("PAUSE");
 
 }

Added: incubator/tuscany/cpp/das/tools/ant_cpptasks/build.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/tools/ant_cpptasks/build.xml?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/tools/ant_cpptasks/build.xml (added)
+++ incubator/tuscany/cpp/das/tools/ant_cpptasks/build.xml Sat Sep 29 18:36:21 2007
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+     
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+
+
+<project name="org.apache.tuscany.sca.cpp.antCompilers" default="all" basedir="../..">
+
+	<import file="${basedir}/antscripts/system.xml"/>
+	<import file="${basedir}/antscripts/compile-targets.xml"/>
+	
+	<target name="init">
+		<tstamp/>
+		<property name="this.dir"        location="${basedir}/tools/ant_cpptasks"/>
+		<property name="build.dir"       location="${this.dir}/build" />
+	  <property name="java.src.dir"    location="${this.dir}/tuscanyAntCompilers" />
+	  <property name="install.dir"     location="${basedir}/antscripts" />
+		<property name="class.name"       value="TuscanyMSVC8DevStudioCCompiler" />
+	</target>
+
+	<target name="all" depends="init,build,install"/>
+
+	<target name="build" depends="init" description="Build tuscany ant msvc 8.0 compiler task">
+		<mkdir dir="${build.dir}" />
+
+		<!-- compile the source code -->
+		<javac srcdir="${java.src.dir}"
+			     destdir="${build.dir}"
+		       failonerror="true"
+           includeAntRuntime="no">
+		  <classpath>
+		    <pathelement path="${env.ANT_HOME}/lib/cpptasks.jar"/>
+		    <pathelement path="${env.ANT_HOME}/lib/ant.jar"/>
+		  </classpath>
+		</javac>
+	</target>
+
+  <target name="make.jar" depends="init,build">
+    <jar jarfile="${build.dir}/${class.name}.jar"
+         basedir="${build.dir}"
+         includes="tuscany/antCompilers/${class.name}.class">
+      <manifest>
+        <attribute name="Main-Class" value="tuscany.antCompilers.${class.name}" />
+      </manifest>
+    </jar>
+  </target>
+
+	<target name="install" depends="init,make.jar">
+    <mkdir dir="${install.dir}"/>
+    <copy todir="${install.dir}" overwrite='true'>
+      <fileset dir="${build.dir}" includes="${class.name}.jar"/>
+    </copy>
+  </target>
+	
+	<target name="clean" depends="init" description="Clean of all the files created.">
+		<delete dir="${build.dir}" quiet="true"/>
+    <delete file="${install.dir}/${class.name}.jar" quiet="true"/>
+	</target>
+
+</project>

Added: incubator/tuscany/cpp/das/tools/ant_cpptasks/tuscanyAntCompilers/TuscanyMSVC8DevStudioCCompiler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/tools/ant_cpptasks/tuscanyAntCompilers/TuscanyMSVC8DevStudioCCompiler.java?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/tools/ant_cpptasks/tuscanyAntCompilers/TuscanyMSVC8DevStudioCCompiler.java (added)
+++ incubator/tuscany/cpp/das/tools/ant_cpptasks/tuscanyAntCompilers/TuscanyMSVC8DevStudioCCompiler.java Sat Sep 29 18:36:21 2007
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *   
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package tuscany.antCompilers;
+
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.PrecompilingCommandLineCCompiler;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioProcessor;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+
+
+/**
+ * An abstract base class for compilers that are basically command line
+ * compatible with Microsoft(r) C/C++ Optimizing Compiler
+ * 
+ * This class was taken from cpptasks. Its a combination of the following 2 classes:
+ *     net.sf.antcontrib.cpptasks.devstudio.DevStudioCompatibleCCompiler
+ *     net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler
+ *
+ * To compile MSVC8.0 in debug mode, the cpptasks msvc compiler doesnt distinguish
+ * between msvc 7.1 and 8.0 and seems to actually be 7.1 centric. This implementation
+ * For the Apache Tuscany project tries to address those issues. 
+ */
+
+public final class TuscanyMSVC8DevStudioCCompiler
+        extends PrecompilingCommandLineCCompiler
+{
+    private static String[] mflags_ = 
+    	new String[] {"/ML", "/MLd", null, null, "/MT", "/MTd", "/MD", "/MDd"};
+    //   first four are single-threaded
+    //      (runtime=static,debug=false), (..,debug=true),
+    //      (runtime=dynamic,debug=true), (..,debug=false), (not supported)
+    //    next four are multi-threaded, same sequence
+
+	  // Indeces into the mflags_ array 
+	private static int MINDEX_DEBUG           =  1;
+	private static int MINDEX_STATIC_RUNTIME  =  2;
+	private static int MINDEX_MULTI_THREADED  =  4;
+
+	private static final TuscanyMSVC8DevStudioCCompiler instance_ = 
+		new TuscanyMSVC8DevStudioCCompiler( "cl", false, null);
+
+    public static TuscanyMSVC8DevStudioCCompiler getInstance()
+    {
+        return instance_;
+    }
+
+    private TuscanyMSVC8DevStudioCCompiler(
+    		String command,
+    		boolean newEnvironment,
+            Environment env)
+    {
+        super(command, 
+              "/bogus",
+              new String[]{".c", ".cc", ".cpp", ".cxx", ".c++"},
+              new String[]{".h", ".hpp", ".inl"},
+              ".obj",
+              false,
+              null,
+              newEnvironment,
+              env);
+    }
+
+    public Processor changeEnvironment(boolean newEnvironment, Environment env)
+    {
+        if (newEnvironment || env != null) {
+            return new TuscanyMSVC8DevStudioCCompiler(getCommand(), newEnvironment, env);
+        }
+        return this;
+    }
+
+    public Linker getLinker(LinkType type)
+    {
+        return DevStudioLinker.getInstance().getLinker(type);
+    }
+
+    public int getMaximumCommandLength()
+    {
+        return 32767;
+    }
+
+    protected void addImpliedArgs(
+    		final Vector args,
+            final boolean debug,
+            final boolean multithreaded,
+            final boolean exceptions,
+            final LinkType linkType,
+            final Boolean rtti,
+            final OptimizationEnum optimization)
+    {
+        args.addElement("/c");
+        args.addElement("/nologo");
+        if (exceptions) {
+            //   changed to eliminate warning on VC 2005, should support VC 6 and later
+            //   use /GX to support VC5 - 2005 (with warning)
+            args.addElement("/EHsc");
+        }
+        int mindex = 0;
+        if (multithreaded) {
+            mindex += MINDEX_MULTI_THREADED;
+        }
+        boolean staticRuntime = linkType.isStaticRuntime();
+        if (!staticRuntime) {
+            mindex += MINDEX_STATIC_RUNTIME;
+        }
+
+        if (debug) {
+            mindex += MINDEX_DEBUG;
+            args.addElement("/Zi");        // Generates complete debugging information
+            args.addElement("/Od");        // Disables optimization
+            
+		// Native DAS gets corrupted stack memory when /RTC1 argument is added
+		//args.addElement("/RTC1");      // Enables run-time error checking as opposed to depracated /GZ
+
+            args.addElement("/Gd");        // Uses the __cdecl calling convention (x86 only)
+            args.addElement("/D_DEBUG");   // Debug mode
+        } else {
+            args.addElement("/DNDEBUG");
+            if (optimization != null) {
+                if (optimization.isSize()) {
+                    args.addElement("/O1");
+                }
+
+                if (optimization.isSpeed()) {
+                    args.addElement("/O2");
+                }
+            }
+        }
+
+        String mflag = mflags_[mindex];
+        if (mflag == null) {
+            throw new BuildException(
+                    "multithread='false' and runtime='dynamic' not supported");
+        }
+        args.addElement(mflag);
+        if (rtti != null && rtti.booleanValue()) {
+                args.addElement("/GR");
+        }
+    }
+
+    protected void addWarningSwitch(Vector args, int level)
+    {
+        DevStudioProcessor.addWarningSwitch(args, level);
+    }
+
+    protected CompilerConfiguration createPrecompileGeneratingConfig(
+            CommandLineCompilerConfiguration baseConfig,
+            File prototype,
+            String lastInclude)
+    {
+        String[] additionalArgs = new String[]{
+                "/Fp" + CUtil.getBasename(prototype) + ".pch", "/Yc"};
+        return new
+            CommandLineCompilerConfiguration(
+        		baseConfig,
+        		additionalArgs,
+                null,
+                true);
+    }    
+
+    protected CompilerConfiguration createPrecompileUsingConfig(
+            CommandLineCompilerConfiguration baseConfig,
+            File prototype,
+            String lastInclude,
+            String[] exceptFiles)
+    {
+        String[] additionalArgs = new String[]{
+                "/Fp" + CUtil.getBasename(prototype) + ".pch",
+                "/Yu" + lastInclude};
+        return new
+            CommandLineCompilerConfiguration(
+        		baseConfig,
+        		additionalArgs,
+                exceptFiles,
+                false);
+    }
+
+    protected void getDefineSwitch(StringBuffer buffer, String define, String value)
+    {
+        DevStudioProcessor.getDefineSwitch(buffer, define, value);
+    }
+
+    protected File[] getEnvironmentIncludePath()
+    {
+        return CUtil.getPathFromEnvironment("INCLUDE", ";");
+    }
+
+    protected String getIncludeDirSwitch(String includeDir)
+    {
+        return DevStudioProcessor.getIncludeDirSwitch(includeDir);
+    }
+
+    protected void getUndefineSwitch(StringBuffer buffer, String define)
+    {
+        DevStudioProcessor.getUndefineSwitch(buffer, define);
+    }
+}

Added: incubator/tuscany/cpp/das/tools/build.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/tools/build.xml?rev=580668&view=auto
==============================================================================
--- incubator/tuscany/cpp/das/tools/build.xml (added)
+++ incubator/tuscany/cpp/das/tools/build.xml Sat Sep 29 18:36:21 2007
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+     
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+
+<project name="TuscanyScaNative_tools" default="all" basedir="..">
+
+  <!--
+    This is the root level ant build.xml file for TuscanySCA Native tools
+    Nothing is actually performed here, it just delegates to subdirectory
+    build.xml files.
+  --> 
+    
+  <import file="${basedir}/antscripts/system.xml"/>
+  <import file="${basedir}/antscripts/compile-targets.xml"/>
+
+  <!--
+    Notice that the basedir for this project is set to the TuscanySCA root dir
+    This makes path setting in system.xml much simpler, but we'll just have to
+    set a property here to this directory.
+  -->
+
+  <property name="this.dir"           location="${basedir}/tools"/>
+  <property name="TuscanyDriver.dir"  location="${this.dir}/TuscanyDriver"/>
+  <property name="ant_cpptasks.dir"   location="${this.dir}/ant_cpptasks"/>
+
+  <!--
+    Public targets
+  -->
+
+  <target name="all" description="Build and install all TuscanyScaNative tools">
+    <antcall target="build"/>
+    <antcall target="install"/>
+  </target>
+
+     <!--
+       Notice the ant_cpptasks tool is not included in the "all" target.
+       This is because its not something that should be built that often.
+       The resulting jar is included in TUSCANY_SCA_SRC_ROOT/antscripts svn
+     -->
+
+  <target name="build" description="Build all TuscanyScaNative tools">
+    <antcall target="build.TuscanyDriver"/>
+  </target>
+
+  <target name="install" description="Install TuscanyScaNative tools">
+    <antcall target="install.TuscanyDriver"/>
+  </target>
+
+  <target name="clean" description="Clean all TuscanyScaNative tools">
+    <antcall target="clean.TuscanyDriver"/>
+  </target>
+
+  <!--
+    Internal targets
+    They can still be called, they're just not described, so wont show up in "ant -p"
+    Using antfile and inheritAll="false" to maintain the subdir build.xml basedir settings
+  -->
+
+    <!-- build -->
+
+  <target name="build.ant_cpptasks">
+    <ant target="build" antfile="${ant_cpptasks.dir}/build.xml" inheritAll="false"/>
+  </target>
+
+  <target name="build.TuscanyDriver">
+    <ant target="build" antfile="${TuscanyDriver.dir}/build.xml" inheritAll="false"/>
+  </target>
+
+    <!-- install -->
+
+  <target name="install.ant_cpptasks">
+    <ant target="install" antfile="${ant_cpptasks.dir}/build.xml" inheritAll="false"/>
+  </target>
+
+  <target name="install.TuscanyDriver">
+    <ant target="install" antfile="${TuscanyDriver.dir}/build.xml" inheritAll="false"/>
+  </target>
+
+    <!-- clean -->
+
+  <target name="clean.ant_cpptasks">
+    <ant target="clean" antfile="${ant_cpptasks.dir}/build.xml" inheritAll="false"/>
+  </target>
+
+  <target name="clean.TuscanyDriver">
+    <ant target="clean" antfile="${TuscanyDriver.dir}/build.xml" inheritAll="false"/>
+  </target>
+
+</project>



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