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/11/12 23:03:24 UTC

svn commit: r594314 [8/9] - in /incubator/tuscany/sandbox/crestani/das_distribution_example: ./ bin/ bin/antscripts/ bin/bin/ bin/include/ bin/include/apache/ bin/include/apache/das/ bin/include/apache/das/rdb/ bin/lib/ bin/samples/ bin/samples/Company...

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/ResultSet.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/ResultSet.cpp?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/ResultSet.cpp (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/ResultSet.cpp Mon Nov 12 14:02:46 2007
@@ -0,0 +1,356 @@
+/*
+ * 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/ResultSet.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+ResultSet::ResultSet(StatementPtr aStmt) {
+	stmt = aStmt;
+	metaData = new ResultSetMetaData(*this);
+
+}
+
+ResultSet::~ResultSet(void) {
+	ResultSetObject::free();
+	delete metaData;
+
+}
+
+const ResultSetMetaData& ResultSet::getResultSetMetaData(void) const {
+	return *metaData;
+}
+
+StatementPtr ResultSet::getStatement(void) const {
+	return stmt;
+}
+
+SQLINTEGER ResultSet::getSQLInteger(unsigned int columnIndex) const {
+	SQLINTEGER sqlPtr = 0;
+	SQLSMALLINT length = 0;
+	SQLINTEGER aux = 0;
+
+	if (metaData->getSQLType(columnIndex) == SQL_INTEGER) {
+		SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_LONG, &sqlPtr, 0, &aux);
+SQLINTEGER error;
+		if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)){
+SQLCHAR sqlStat;
+
+SQLCHAR * message = new SQLCHAR[100];
+	SQLSMALLINT messageLength;
+			SQLGetDiagRec(SQL_HANDLE_DBC, stmt->getConnection().getODBCConnection(),1, 
+		              &sqlStat, &error,message,100,&messageLength);
+
+		
+
+		string error("Error to establish the connection.\nSQLSTATE: ");
+		error += reinterpret_cast<char*>(&sqlStat);
+		throw SQLException(result, error);
+	}
+
+		if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+			throw SQLException(result, "Error on getting database data!");
+
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not integer!");
+	}
+		
+	return sqlPtr;
+
+}
+
+SQLINTEGER ResultSet::getSQLInteger(std::string tableName, std::string columnName) const {
+	return getSQLInteger(metaData->getColumnIndex(tableName, columnName));
+}
+
+SQLSMALLINT ResultSet::getSQLSmallInt(unsigned int columnIndex) const {
+	SQLSMALLINT sqlPtr = 0;
+	SQLSMALLINT length = 0;
+	SQLINTEGER aux = 0;
+
+	if (metaData->getSQLType(columnIndex) == SQL_SMALLINT) {
+		SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_SHORT, &sqlPtr, 0, &aux);
+
+		if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+			throw SQLException(result, "Error on getting database data!");
+
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not integer!");
+	}
+		
+	return sqlPtr;
+
+}
+
+SQLSMALLINT ResultSet::getSQLSmallInt(std::string tableName, std::string columnName) const {
+	return getSQLSmallInt(metaData->getColumnIndex(tableName, columnName));
+}
+
+
+SQLWCHAR ResultSet::getSQLWChar(unsigned int columnIndex) const {
+	SQLWCHAR strAux = 0;
+	
+	if (metaData->getSQLType(columnIndex) == SQL_WCHAR) {
+		SQLINTEGER length = 0;
+		SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_WCHAR, &strAux, 2, &length);
+		
+		if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+			throw SQLException(result, "Error on getting database data!");
+		
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not char!");
+	}
+
+	return strAux;
+
+}
+
+SQLWCHAR ResultSet::getSQLWChar(std::string tableName, std::string columnName) const {
+	return getSQLWChar(metaData->getColumnIndex(tableName, columnName));
+}
+
+SQLCHAR ResultSet::getSQLChar(unsigned int columnIndex) const {
+	SQLCHAR strAux = 0;
+		
+	if (metaData->getSQLType(columnIndex) == SQL_CHAR) {
+		SQLINTEGER length = 0;
+		SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_CHAR, &strAux, 2, &length);
+		
+		if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+			throw SQLException(result, "Error on getting database data!");
+
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not char!");
+	}
+
+	return strAux;
+
+}
+
+SQLCHAR ResultSet::getSQLChar(std::string tableName, std::string columnName) const {
+	return getSQLChar(metaData->getColumnIndex(tableName, columnName));
+}
+
+SQLREAL ResultSet::getSQLReal(unsigned int columnIndex) const {
+	SQLREAL ret = 0;
+
+	if (metaData->getSQLType(columnIndex) == SQL_REAL) {
+		SQLREAL real = 0;
+		SQLINTEGER length = 0;
+		SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_FLOAT, &real, 1, &length);
+		
+		if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+			throw SQLException(result, "Error on getting database data!");
+
+		ret = (SQLREAL) real;
+		
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not real!");
+	}
+
+	return ret;
+
+}
+
+SQLREAL ResultSet::getSQLReal(std::string tableName, std::string columnName) const {
+	return getSQLReal(metaData->getColumnIndex(tableName, columnName));
+}
+
+SQLFLOAT ResultSet::getSQLFloat(unsigned int columnIndex) const {
+	SQLFLOAT ret = 0;
+
+	if (metaData->getSQLType(columnIndex) == SQL_FLOAT) {
+		SQLDOUBLE data = 0;
+		SQLINTEGER length = 0;
+		SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_DOUBLE, &data, 1, &length);
+		
+		if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+			throw SQLException(result, "error on getting database data!");
+
+		ret = (SQLFLOAT) data;
+		
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not float!");
+	}
+
+	return ret;
+
+}
+
+SQLFLOAT ResultSet::getSQLFloat(std::string tableName, std::string columnName) const {
+	return getSQLFloat(metaData->getColumnIndex(tableName, columnName));
+}
+
+SQLDOUBLE ResultSet::getSQLDouble(unsigned int columnIndex) const {
+	double ret = 0;
+
+	if (metaData->getSQLType(columnIndex) == SQL_DOUBLE) {
+		SQLDOUBLE data = 0;
+		SQLINTEGER length = 0;
+		SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_DOUBLE, &data, 1, &length);
+		
+		if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+			throw SQLException(result, "error on getting database data!");
+
+		ret = (SQLDOUBLE) data;
+		
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not double!");
+	}
+
+	return ret;
+
+}
+
+SQLDOUBLE ResultSet::getSQLDouble(std::string tableName, std::string columnName) const {
+	return getSQLDouble(metaData->getColumnIndex(tableName, columnName));
+}
+
+std::string ResultSet::getSQLDecimal(unsigned int columnIndex) const {
+
+	if (metaData->getSQLType(columnIndex) == SQL_DECIMAL) {
+		return getSQLString(columnIndex);
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not decimal!");
+	}
+
+}
+
+std::string ResultSet::getSQLDecimal(std::string tableName, std::string columnName) const {
+	return getSQLDecimal(metaData->getColumnIndex(tableName, columnName));
+}
+
+bool ResultSet::isNull(unsigned int columnIndex) const { 
+	SQLINTEGER sqlPtr = 0;
+	SQLSMALLINT length = 0;
+	SQLINTEGER aux = 0;
+
+	if (metaData->getSQLType(columnIndex) == SQL_INTEGER) {
+		SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_DEFAULT, &sqlPtr, 0, &aux);
+
+		if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+			throw SQLException(result, "Error on getting database data!");
+
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not integer!");
+	}
+
+	return aux == SQL_NULL_DATA;
+		
+}
+
+bool ResultSet::isNull(std::string tableName, std::string columnName) const {
+	return isNull(metaData->getColumnIndex(tableName, columnName));
+}
+
+bool ResultSet::next(void) {
+	return (SQL_SUCCESS == SQLFetch(stmt->getODBCStatement()));
+}
+
+unsigned int ResultSet::getRowCount(void) const {
+	SQLINTEGER rowCount = 0;
+	SQLRETURN result = SQLRowCount(stmt->getODBCStatement(), &rowCount);
+		
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+			throw SQLException(result, "error on getting row count!");
+
+	return (unsigned int) rowCount;
+
+}
+
+std::string ResultSet::getSQLString(unsigned int columnIndex) const {
+	SQLPOINTER sqlPtr = 0;
+	SQLCHAR strAux[1];
+	SQLINTEGER length = 0;
+	SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_CHAR, &strAux, 1, &length);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+		throw SQLException(result, "error on getting database data!");
+
+	length++;
+	sqlPtr = new SQLCHAR[length];
+	SQLINTEGER aux = 0;
+	result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_CHAR, sqlPtr, length, &aux);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+		throw SQLException(result, "error on getting database data!");
+		
+	std::string ret = (char*) sqlPtr;
+	delete [] ((SQLCHAR*) sqlPtr);
+
+	return ret;
+
+}
+
+std::wstring ResultSet::getSQLWString(unsigned int columnIndex) const {
+	SQLPOINTER sqlPtr = 0;
+	SQLWCHAR strAux[1];
+	SQLINTEGER length = 0;
+	SQLRETURN result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_WCHAR, &strAux, 1, &length);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+		throw SQLException(result, "error on getting database data!");
+
+	length++;
+	sqlPtr = new SQLWCHAR[length];
+	SQLINTEGER aux = 0;
+	result = SQLGetData(stmt->getODBCStatement(), columnIndex + 1, SQL_C_WCHAR, sqlPtr, length, &aux);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+		throw SQLException(result, "error on getting database data!");
+		
+	std::wstring ret = (wchar_t*) sqlPtr;
+	delete [] ((SQLWCHAR*) sqlPtr);
+
+	return ret;
+
+}
+
+std::string ResultSet::getSQLVarchar(unsigned int columnIndex) const {
+
+	if (metaData->getSQLType(columnIndex) == SQL_VARCHAR) {
+		return getSQLString(columnIndex);
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not varchar!");
+	}
+
+}
+
+std::string ResultSet::getSQLVarchar(std::string tableName, std::string columnName) const {
+	return getSQLVarchar(metaData->getColumnIndex(tableName, columnName));
+}
+
+std::wstring ResultSet::getSQLWVarchar(unsigned int columnIndex) const {
+
+	if (metaData->getSQLType(columnIndex) == SQL_WVARCHAR) {
+		return getSQLWString(columnIndex);
+	} else {
+		throw DASInvalidSQLTypeException("Column sql type on index " + columnIndex + (std::string) " is not varchar!");
+	}
+
+}
+
+std::wstring ResultSet::getSQLWVarchar(std::string tableName, std::string columnName) const {
+	return getSQLWVarchar(metaData->getColumnIndex(tableName, columnName));
+}
+
+		};
+	};
+};

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/ResultSetMetaData.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/ResultSetMetaData.cpp?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/ResultSetMetaData.cpp (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/ResultSetMetaData.cpp Mon Nov 12 14:02:46 2007
@@ -0,0 +1,216 @@
+/*
+ * 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/ResultSetMetaData.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+ResultSetMetaData::ResultSetMetaData(const ResultSet& aResultSet) {
+	resultSet = &aResultSet;
+	unsigned int columnCount = getColumnCount();
+	
+	for (unsigned int i = 0 ; i < columnCount ; i++) {
+		std::string columnName = StringWrapper(getColumnName(i)).toUpper();
+		std::string tableName = StringWrapper(getTableName(i)).toUpper();
+		columnsIndexes.insert(std::make_pair(tableName + "." + columnName, i));
+
+	}
+
+}
+
+ResultSetMetaData::~ResultSetMetaData(void) {}
+
+SQLSMALLINT ResultSetMetaData::getSQLCType(SQLSMALLINT sqlType) {
+
+	switch (sqlType) {
+
+		case SQL_CHAR :
+			return SQL_C_CHAR;
+
+		case SQL_BINARY :
+			return SQL_C_BINARY;
+
+		case SQL_TYPE_DATE :
+			return SQL_C_TYPE_DATE;
+
+		case SQL_DECIMAL :
+			return SQL_C_CHAR;
+
+		case SQL_DOUBLE :
+			return SQL_C_DOUBLE;
+
+		case SQL_FLOAT :
+			return SQL_C_DOUBLE;
+
+		case SQL_INTEGER :
+			return SQL_C_LONG;
+
+		case SQL_LONGVARCHAR :
+			return SQL_C_CHAR;
+
+		case SQL_LONGVARBINARY :
+			return SQL_C_BINARY;
+
+		case SQL_NUMERIC :
+			return SQL_C_CHAR;
+
+		case SQL_REAL :
+			return SQL_C_FLOAT;
+
+		case SQL_SMALLINT :
+			return SQL_C_SHORT;
+
+		case SQL_TYPE_TIME :
+			return SQL_C_TYPE_TIME;
+
+		case SQL_TYPE_TIMESTAMP :
+			return SQL_C_TYPE_TIMESTAMP;
+
+		case SQL_VARCHAR :
+			return SQL_C_CHAR;
+
+		case SQL_VARBINARY :
+			return SQL_C_BINARY;
+
+		default :
+			throw DASInvalidSQLTypeException();
+		
+	}
+
+}
+
+SQLSMALLINT ResultSetMetaData::getSQLType(unsigned int columnIndex) const {
+	SQLSMALLINT sqlType = 0;
+	SQLColAttribute(resultSet->getStatement()->getODBCStatement(), columnIndex + 1, SQL_DESC_TYPE, NULL, NULL, NULL, &sqlType);
+		
+	return sqlType;
+
+}
+
+SQLSMALLINT ResultSetMetaData::getSQLType(std::string tableName, std::string columnName) const {
+	return getSQLType(getColumnIndex(tableName, columnName));
+}
+
+std::string ResultSetMetaData::getSQLTypeName(unsigned int columnIndex) const {
+	SQLCHAR* sqlPtr = 0;
+	char strAux[1];
+	SQLSMALLINT length = 0;
+	SQLColAttribute(resultSet->getStatement()->getODBCStatement(), columnIndex + 1, SQL_DESC_TYPE_NAME, &strAux, 1, (SQLSMALLINT*) &length, NULL);
+	length++;
+	sqlPtr = (SQLCHAR*) new SQLCHAR[length];
+	SQLColAttributeA(resultSet->getStatement()->getODBCStatement(), columnIndex + 1, SQL_DESC_TYPE_NAME, sqlPtr, length, (SQLSMALLINT*) &length, NULL);
+
+	std::string ret((char*) sqlPtr);
+	delete [] sqlPtr;
+
+	return StringWrapper(ret).toUpper();
+
+}
+
+std::string ResultSetMetaData::getSQLTypeName(std::string tableName, std::string columnName) const {
+	return getSQLTypeName(getColumnIndex(tableName, columnName));
+}
+
+
+std::string ResultSetMetaData::getColumnName(unsigned int columnIndex) const {
+	SQLCHAR* sqlPtr = 0;
+	char strAux[1];
+	SQLSMALLINT length = 0;
+	SQLColAttribute(resultSet->getStatement()->getODBCStatement(), columnIndex + 1, SQL_DESC_BASE_COLUMN_NAME, &strAux, 1, (SQLSMALLINT*) &length, NULL);
+	length++;
+	sqlPtr = (SQLCHAR*) new SQLCHAR[length];
+	SQLColAttributeA(resultSet->getStatement()->getODBCStatement(), columnIndex + 1, SQL_DESC_BASE_COLUMN_NAME, sqlPtr, length, (SQLSMALLINT*) &length, NULL);
+
+	std::string ret((char*) sqlPtr);
+	delete [] sqlPtr;
+
+	return StringWrapper(ret).toUpper();
+
+}
+
+unsigned int ResultSetMetaData::getColumnIndex(std::string tableName, std::string columnName) const {
+	tableName = StringWrapper(tableName).toUpper();
+	columnName = StringWrapper(columnName).toUpper();
+	std::map<std::string, unsigned int>::const_iterator it = columnsIndexes.find(tableName + "." + columnName);
+
+	if (it == columnsIndexes.end()) {
+		throw DASColumnNotFoundException("No such column on table " + tableName + ": " + columnName);
+	}
+
+	return it->second;
+
+}
+
+
+std::string ResultSetMetaData::getTableName(unsigned int columnIndex) const {
+	SQLCHAR* sqlPtr = 0;
+	char strAux[1];
+	SQLSMALLINT length = 0;
+	SQLColAttribute(resultSet->getStatement()->getODBCStatement(), columnIndex + 1, SQL_DESC_TABLE_NAME, &strAux, 1, (SQLSMALLINT*) &length, NULL);
+	length++;
+	sqlPtr = (SQLCHAR*) new SQLCHAR[length];
+	SQLColAttributeA(resultSet->getStatement()->getODBCStatement(), columnIndex + 1, SQL_DESC_TABLE_NAME, sqlPtr, length, (SQLSMALLINT*) &length, NULL);
+
+	std::string ret((char*) sqlPtr);
+	delete [] sqlPtr;
+
+	return StringWrapper(ret).toUpper();
+
+}
+
+std::string ResultSetMetaData::getTableName(std::string tableName, std::string columnName) const {
+	return getTableName(getColumnIndex(tableName, columnName));
+}
+
+
+SQLSMALLINT ResultSetMetaData::getSQLCType(unsigned int columnIndex) const {
+	return getSQLCType(getSQLType(columnIndex));
+}
+
+SQLSMALLINT ResultSetMetaData::getSQLCType(std::string tableName, std::string columnName) const {
+	return getSQLCType(getSQLType(getColumnIndex(tableName, columnName)));
+}
+
+unsigned int ResultSetMetaData::getColumnCount(void) const {
+	SQLUINTEGER columnCount = 0;
+	SQLRETURN ret = SQLColAttribute(resultSet->getStatement()->getODBCStatement(), NULL, SQL_DESC_COUNT, NULL, NULL, NULL, &columnCount);
+	
+	return (unsigned int) columnCount;
+
+}
+
+bool ResultSetMetaData::containsColumn(std::string tableName, std::string columnName) const {
+	std::map<std::string, unsigned int>::const_iterator it = columnsIndexes.find(tableName + "." + columnName);
+	
+	if (it == columnsIndexes.end()) {
+		return false;
+	}
+
+	return true;
+
+}
+
+const ResultSet& ResultSetMetaData::getResultSet(void) const {
+	return *resultSet;
+}
+
+		};
+	};
+};

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/SQLException.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/SQLException.cpp?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/SQLException.cpp (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/SQLException.cpp Mon Nov 12 14:02:46 2007
@@ -0,0 +1,40 @@
+/*
+ * 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/SQLException.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+SQLException::SQLException(SQLRETURN returnCode, string errorText)
+	:exception(errorText.c_str()) {
+		this->returnCode = returnCode;
+
+}
+
+SQLException::~SQLException(){}
+
+SQLRETURN SQLException::getODBCReturnCode(void) const {
+	return returnCode;
+}
+
+		};
+	};
+};

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/Statement.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/Statement.cpp?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/Statement.cpp (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/Statement.cpp Mon Nov 12 14:02:46 2007
@@ -0,0 +1,107 @@
+/*
+ * 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/Statement.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+Statement::Statement(Connection& connection, SQLHSTMT statementHandle) : resultSet(0, false) {
+	this->statementHandle = statementHandle;
+	this->connection = &connection;
+
+}
+
+Statement::~Statement(void) {
+	if (!resultSet) {
+		delete resultSet;
+	}
+
+	SQLFreeHandle(SQL_HANDLE_STMT, statementHandle);
+	StatementObject::free();
+
+}
+
+std::string Statement::getError(void) const {
+	SQLCHAR state[5];
+	SQLCHAR message[1000];
+	SQLINTEGER nativeError = 0;
+	SQLSMALLINT messageLength = 0;
+
+	SQLRETURN result = SQLGetDiagRec(SQL_HANDLE_STMT, statementHandle, 1, 
+		              state, &nativeError, message, 1000, &messageLength);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
+		return "";
+	}
+
+	if (messageLength < 1000) {
+		message[messageLength + 1] = 0;
+	}
+
+	std::string ret = (std::string) (char*) state;
+	ret += ": ";
+	ret += StringWrapper::toString((long) nativeError);
+	ret += " - ";
+	ret += (char*) message;
+
+	return ret;
+
+}
+
+Connection& Statement::getConnection(void) const {
+	return *connection;
+}
+
+ResultSetPtr Statement::executeQuery(std::string sql) {
+	queryString = sql;
+	SQLCloseCursor(statementHandle);
+	SQLRETURN result = SQLExecDirect(statementHandle, (SQLCHAR*) (char*) sql.c_str(), SQL_NTS);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
+		throw SQLException(result, getError());
+	}
+	
+	return createResultSet();
+
+}
+
+ResultSetPtr Statement::createResultSet(void) {
+	if (resultSet) {
+		delete resultSet;
+	}
+
+	ResultSetPtr ret = new ResultSet((StatementPtr) *this);
+	resultSet = ret;
+
+	return ret;
+
+}
+
+void Statement::close(void) {
+	delete this;
+}
+
+HSTMT Statement::getODBCStatement(void) const {
+	return statementHandle;
+}
+
+		};
+	};
+};

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/Table.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/Table.cpp?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/Table.cpp (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/Table.cpp Mon Nov 12 14:02:46 2007
@@ -0,0 +1,236 @@
+/*
+ * 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/Table.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+Table::Table(std::string tableName) {
+	tableName = StringWrapper(tableName).toUpper();
+
+	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 = tableName;
+	this->columns = new std::map<std::string, const Column*>();
+
+}
+
+Table::Table(std::string tableName, std::string typeName) {
+	tableName = StringWrapper(tableName).toUpper();
+
+	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;
+	typeName = table.typeName;
+	this->columns = new std::map<std::string, const Column*>();
+
+	std::map<std::string, const Column*>::iterator it;
+	for (it = table.columns->begin() ; it != table.columns->end() ; it++) {
+		Column* newColumn = new Column(*it->second);
+		newColumn->setContainerTable(this);
+		columns->insert(std::make_pair(it->first, newColumn));
+		
+	}
+
+}
+
+Table::~Table(void) {
+	std::map<std::string, const Column*>::iterator it;
+
+	for (it = columns->begin() ; it != columns->end() ; it++) {
+		delete it->second;
+	}
+
+	delete columns;
+
+}
+
+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;
+}
+
+Column& Table::addColumn(std::string columnName, SQLSMALLINT sqlType) {
+	Column* column = new Column(columnName, sqlType);
+	return newColumn(*column);
+}
+
+Column& Table::addColumn(const Column& column) {
+	return newColumn(*(new Column(column)));
+}
+
+Column& Table::newColumn(Column& column) {
+	std::string columnName = column.getName();
+	Column* tableColumn = getColumn(columnName);
+
+	if (tableColumn == 0) {
+		columns->insert(std::make_pair(columnName, &column));
+		column.setContainerTable(this);
+
+		return column;
+
+	}
+
+	return *tableColumn;
+
+}
+
+void Table::createGraph(const GraphBuilderMetaData& graphBuilderMetaData, commonj::sdo::DataFactoryPtr dataFactory) const {
+	std::map<std::string, const Column*>::const_iterator it;
+	std::map<std::string, Relationship*>& relationships = graphBuilderMetaData.getRelationships();
+	std::map<std::string, Relationship*>::const_iterator relationshipIterator;
+	std::list<Relationship*> tablePKRelationships;
+	std::list<Relationship*> tableFKRelationships;
+	std::list<std::string> relationshipColumns;
+	
+	for (relationshipIterator = relationships.begin() ; relationshipIterator != 
+		relationships.end() ; relationshipIterator++) {
+
+			if (relationshipIterator->second->getFKTableName() == tableName) {
+				const std::map<std::string, const KeyPair*>& keyPairs = relationshipIterator->second->getKeyPairs();
+				std::map<std::string, const KeyPair*>::const_iterator keyPairIterator;
+
+				for (keyPairIterator = keyPairs.begin() ; keyPairIterator != 
+					keyPairs.end() ; keyPairIterator++) {
+
+						relationshipColumns.push_back(keyPairIterator->second->
+							getFKColumnName());
+
+				}
+
+			}
+
+	}
+	
+	for (it = columns->begin() ; it != columns->end() ; it++) {
+		const Column& column = *(it->second);
+
+		if (graphBuilderMetaData.getResultSetMetaData().containsColumn(tableName, column.getName())) {
+
+			std::list<std::string>::const_iterator it2 = std::find(relationshipColumns.begin(),
+				relationshipColumns.end(), column.getName());
+		
+			if (it2 == relationshipColumns.end()) {
+				dataFactory->addPropertyToType(graphBuilderMetaData.getConfig().getURI(), typeName.c_str(),
+					column.getPropertyName().c_str(), SDO_NAMESPACE, 
+					ODBCTypeHelper::getSDOType(column.getSQLType()).c_str() , false, 
+					false, true);
+			
+			}
+
+		}
+	
+	}
+
+}
+
+const Column* Table::getOCCColumn(void) const {
+
+	for (std::map<std::string, const Column*>::const_iterator it = columns->begin() ; it != columns->end() ; it++) {
+
+		if (it->second->isCollision()) {
+			return it->second;
+		}
+
+	}
+
+	return 0;
+
+}
+
+void Table::setTypeName(std::string typeName) {
+	typeName = StringWrapper(typeName).toUpper();
+
+	if (typeName.find(' ') != -1 || typeName.find('\t') != -1 || typeName.find('\n') != -1 || typeName.find('\r') != -1) {
+		throw DASInvalidTypeNameException("Type must not contain whitespace characters!");
+	}
+
+	this->typeName = typeName;
+
+}
+
+Column* Table::getColumn(std::string columnName) {
+	std::map<std::string, const Column*>::const_iterator it = columns->find(columnName);
+
+	if (it == columns->end()) {
+		return 0;
+	}
+
+	return (Column*) it->second;
+
+}
+
+const Column* Table::getColumn(std::string columnName) const {
+	return ((Table*) this)->getColumn(columnName);
+}
+
+std::string Table::getTypeName(void) const {
+	return typeName;
+}
+
+const std::map<std::string, const Column*>& Table::getColumns(void) const {
+	return *columns;
+}
+
+unsigned int Table::getPKColumnCount(void) const {
+	unsigned int count = 0;
+	std::map<std::string, const Column*>::const_iterator it;
+
+	for (it = columns->begin() ; it != columns->end() ; it++) {
+
+		if (it->second->isPK()) {
+			count++;
+		}
+
+	}
+
+	return count;
+
+}
+
+		};
+	};
+};

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/TableData.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/TableData.cpp?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/TableData.cpp (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/core/src/apache/das/rdb/TableData.cpp Mon Nov 12 14:02:46 2007
@@ -0,0 +1,98 @@
+/*
+ * 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/TableData.h"
+
+namespace apache {
+	namespace das {
+		namespace rdb {
+
+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++) {
+
+			const Column& column = *columnIterator->second;
+			std::string columnName = column.getName();
+
+			if (metaData.containsColumn(table.getTableName(), columnName)) {
+				ColumnData* columnData = new ColumnData(column, resultSet);
+
+				columnsData.insert(std::make_pair(columnName, columnData));
+
+				if (column.isPK()) {
+					addPrimaryKey(columnName, *columnData);
+				}
+
+			}
+
+	}
+
+}
+
+TableData::~TableData(void) {
+	std::map<std::string, ColumnData*>::iterator it;
+
+	for (it = columnsData.begin() ; it != columnsData.end() ; it++) {
+
+		if (!(it->second->getColumn().isPK())) {
+			delete it->second;
+		}
+
+	}
+	
+}
+
+bool TableData::hasPK(void) const {
+	const KeyDataList& primaryKeys = getPrimaryKeys();
+	return (primaryKeys.size() == getTable().getPKColumnCount() && primaryKeys.size() > 0);
+}
+
+commonj::sdo::DataObjectPtr TableData::getGraphObject(void) const {
+	return dataObject;
+}
+
+void TableData::populateDataGraph(GraphBuilder& graphBuilder) {
+	dataObject = graphBuilder.getRoot()->createDataObject(getTable().getTableName().c_str());
+	std::map<std::string, ColumnData*>::iterator it;
+
+	for (it = columnsData.begin() ; it != columnsData.end() ; it++) {
+		it->second->populateDataGraph(*this);
+	}
+
+}
+
+ColumnData* TableData::getColumnData(std::string columnName) const {
+	std::map<std::string, ColumnData*>::const_iterator it = columnsData.find(columnName);
+
+	if (it == columnsData.end()) {
+		return 0;
+	}
+
+	return it->second;
+
+}
+
+		};
+	};
+};

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/build.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/build.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/build.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/build.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,73 @@
+<?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="TuscanyDASNative_test" default="all" basedir="../..">
+
+  <import file="${basedir}/antscripts/system.xml"/>
+  <import file="${basedir}/antscripts/compile-targets.xml"/>
+
+  <!--
+    Notice that the basedir for this project is set to the TuscanyDAS 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}/runtime/test"/>
+  <property name="das.test.src.dir"    location="${this.dir}/src"/>
+  <property name="das.test.build.dir"  location="${this.dir}/build"/>
+  <property name="das.test.app"        value="das_test"/>
+
+  <!--
+    Public targets
+  -->
+  <target name="all" description="compile, link, and run TuscanyDASNative test suite">
+    <antcall target="build"/>
+    <antcall target="run"/>
+  </target>
+
+  <target name="build" description="compile and link TuscanyDASNative test suite" depends="check.sdo">
+    <cpp-build
+        srcdir="${das.test.src.dir}"
+        infiles="*.cpp"
+        outdir="${das.test.build.dir}"
+        outfile="${das.test.app}"
+        outtype="executable">
+      <custom-build-elements>
+
+	<includepath path="${tuscanyDAS.install.dir}/include"/>
+	<includepath path="${tuscany.sdo.home.dir}/include"/>
+
+        <libset dir="${tuscanyDAS.install.dir}/lib" libs="tuscany_das"/>
+	<libset dir="${tuscany.sdo.home.dir}/lib" libs="tuscany_sdo"/>
+	<libset libs="odbc32"/>
+
+      </custom-build-elements>
+    </cpp-build>
+
+  </target>
+
+  <target name="run" depends="build" description="Run TuscanyDASNative test suite">
+    <exec executable="${das.test.build.dir}/${das.test.app}${exe.ext}" dir="${das.test.build.dir}"/>
+  </target>
+
+  <target name="clean" description="Clean TuscanyDASNative test suite">
+    <delete dir="${das.test.build.dir}" quiet="@{quiet}"/>
+
+  </target>
+
+</project>

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testCompositeRelationship.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testCompositeRelationship.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testCompositeRelationship.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testCompositeRelationship.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,35 @@
+<?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" uri="test.composite.relationship"> 
+
+	<Command name="get composite relationship" SQL="SELECT DEPARTMENT.ID, DEPARTMENT.NAME, EMPLOYEE.ID, EMPLOYEE.DEPARTMENT_ID, EMPLOYEE.DEPARTMENT_NAME FROM DEPARTMENT, EMPLOYEE;"/>
+
+	<Table tableName="department">
+      	<Column sqlType="integer" columnName="id" primaryKey="true"/>
+		<Column sqlType="varchar" columnName="name" primaryKey="true"/>
+	</Table>
+
+	<Relationship primaryKeyTable="department" foreignKeyTable="employee" many="true">
+      	<KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+		<KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+	</Relationship>
+
+</Config>
\ No newline at end of file

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testCreateOperation.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testCreateOperation.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testCreateOperation.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testCreateOperation.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,41 @@
+<?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" uri="test.create.operation"> > 
+
+	<Command name="get all tables" SQL="SELECT * FROM company, department, employee;"/>
+
+	<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

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testDeleteOperation.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testDeleteOperation.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testDeleteOperation.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testDeleteOperation.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,41 @@
+<?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" uri="test.delete.operation"> 
+
+	<Command name="get all tables" SQL="SELECT * FROM company, department, employee;"/>
+
+	<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

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testIncompleteCompositeRelationship1.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testIncompleteCompositeRelationship1.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testIncompleteCompositeRelationship1.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testIncompleteCompositeRelationship1.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,35 @@
+<?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" uri="test.incomplete.composite.relationship.one"> 
+
+	<Command name="get incomplete relationship" SQL="SELECT department.id, department.name, employee.id, employee.department_id FROM department, employee;"/>
+
+	<Table tableName="department">
+      	<Column sqlType="integer" columnName="id" primaryKey="true"/>
+		<Column sqlType="varchar" columnName="name" primaryKey="true"/>
+	</Table>
+
+	<Relationship primaryKeyTable="department" foreignKeyTable="employee" many="true">
+      	<KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+		<KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+	</Relationship>
+
+</Config>
\ No newline at end of file

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testIncompleteCompositeRelationship2.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testIncompleteCompositeRelationship2.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testIncompleteCompositeRelationship2.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testIncompleteCompositeRelationship2.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,34 @@
+<?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" uri="test.incomplete.composite.relationship.two"> 
+
+	<Command name="get incomplete relationship" SQL="SELECT department.id, department.name, employee.id, employee.department_id, employee.department_name FROM department, employee;"/>
+
+	<Table tableName="department">
+      	<Column sqlType="varchar" columnName="name" primaryKey="true"/>
+	</Table>
+
+	<Relationship primaryKeyTable="department" foreignKeyTable="employee" many="true">
+      	<KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+		<KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+	</Relationship>
+
+</Config>
\ No newline at end of file

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testKeyPairColumnTypeNotEqual.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testKeyPairColumnTypeNotEqual.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testKeyPairColumnTypeNotEqual.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testKeyPairColumnTypeNotEqual.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,37 @@
+<?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" uri="test.key.pair.column.type.not.equal"> 
+
+	<Command name="get all employees and departments" SQL="SELECT * FROM department, employee;"/>
+
+	<Table tableName="department">
+      	<Column sqlType="integer" columnName="id" primaryKey="true"/>
+	</Table>
+
+	<Table tableName="employee">
+      	<Column sqlType="float" columnName="department_id" primaryKey="true"/>
+	</Table>
+
+	<Relationship primaryKeyTable="department" foreignKeyTable="employee" many="true">
+      	<KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+	</Relationship>
+
+</Config>
\ No newline at end of file

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testManyRelationship1.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testManyRelationship1.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testManyRelationship1.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testManyRelationship1.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,29 @@
+<?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" uri="test.many.relationship.one"> 
+
+	<Command name="get company 1 and its departments" SQL="SELECT * FROM company, department where company.id = 1;"/>
+
+	<Relationship primaryKeyTable="company" foreignKeyTable="department" many="true">
+      	<KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+	</Relationship>
+
+</Config>
\ No newline at end of file

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testManyRelationship2.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testManyRelationship2.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testManyRelationship2.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testManyRelationship2.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,29 @@
+<?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" uri="test.many.relationship.two"> 
+
+	<Command name="get company 1 and its departments" SQL="SELECT * FROM company, department where company.id = 1;"/>
+
+	<Relationship primaryKeyTable="company" foreignKeyTable="department" many="false">
+      	<KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+	</Relationship>
+
+</Config>
\ No newline at end of file

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testModifyOperation.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testModifyOperation.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testModifyOperation.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testModifyOperation.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,41 @@
+<?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" uri="test.modify.operation"> 
+
+	<Command name="get all tables" SQL="SELECT * FROM company, department, employee;"/>
+
+	<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

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testOCC1.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testOCC1.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testOCC1.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testOCC1.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,43 @@
+<?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" uri="test.occ"> 
+
+	<Command name="get all companies" SQL="SELECT * FROM company;"/>
+
+	<Table tableName="Department">
+		<Column columnName="id" sqlType="integer" primaryKey="true"/>
+		<Column columnName="name" sqlType="varchar" primaryKey="true"/>
+	</Table>
+
+	<Table tableName="company">
+		<Column columnName="occ" sqlType="integer" collision="true" managed="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

Added: incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testOCC2.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testOCC2.xml?rev=594314&view=auto
==============================================================================
--- incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testOCC2.xml (added)
+++ incubator/tuscany/sandbox/crestani/das_distribution_example/src/runtime/test/rsc/testOCC2.xml Mon Nov 12 14:02:46 2007
@@ -0,0 +1,43 @@
+<?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" uri="test.occ"> 
+
+	<Command name="get all companies" SQL="SELECT * FROM company;"/>
+
+	<Table tableName="Department">
+		<Column columnName="id" sqlType="integer" primaryKey="true"/>
+		<Column columnName="name" sqlType="varchar" primaryKey="true"/>
+	</Table>
+
+	<Table tableName="company">
+		<Column columnName="occ" sqlType="integer" collision="true" managed="false"/>
+	</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



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