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/04/21 09:04:13 UTC

svn commit: r530989 - in /incubator/tuscany/cpp/das: VSExpress/tuscany_das/das_lite/ VSExpress/tuscany_das/das_runtime/ runtime/das_lite/src/

Author: adrianocrestani
Date: Sat Apr 21 00:04:12 2007
New Revision: 530989

URL: http://svn.apache.org/viewvc?view=rev&rev=530989
Log:
- Applied JIRA TUSCANY-1219
- Fixed some bugs when building the sdo graph

Added:
    incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.h
Modified:
    incubator/tuscany/cpp/das/VSExpress/tuscany_das/das_lite/das_lite.vcproj
    incubator/tuscany/cpp/das/VSExpress/tuscany_das/das_runtime/das_runtime.suo
    incubator/tuscany/cpp/das/runtime/das_lite/src/Command.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilder.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilderMetaData.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/Table.cpp

Modified: incubator/tuscany/cpp/das/VSExpress/tuscany_das/das_lite/das_lite.vcproj
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/VSExpress/tuscany_das/das_lite/das_lite.vcproj?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/VSExpress/tuscany_das/das_lite/das_lite.vcproj (original)
+++ incubator/tuscany/cpp/das/VSExpress/tuscany_das/das_lite/das_lite.vcproj Sat Apr 21 00:04:12 2007
@@ -18,7 +18,7 @@
 			Name="Debug|Win32"
 			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="2"
+			ConfigurationType="4"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
@@ -55,17 +55,12 @@
 				Name="VCPreLinkEventTool"
 			/>
 			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="odbc32.lib tuscany_sdo.lib"
-				AdditionalLibraryDirectories="&quot;$(TUSCANY_SDOCPP)\lib&quot;;&quot;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib&quot;"
+				Name="VCLibrarianTool"
 			/>
 			<Tool
 				Name="VCALinkTool"
 			/>
 			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
 				Name="VCXDCMakeTool"
 			/>
 			<Tool
@@ -75,12 +70,6 @@
 				Name="VCFxCopTool"
 			/>
 			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
@@ -210,6 +199,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\runtime\das_lite\src\PreparedStatement.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\runtime\das_lite\src\ReadCommandImpl.cpp"
 				>
 			</File>
@@ -226,6 +219,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\runtime\das_lite\src\SqlException.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\runtime\das_lite\src\Statement.cpp"
 				>
 			</File>
@@ -310,6 +307,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\runtime\das_lite\src\PreparedStatement.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\runtime\das_lite\src\ReadCommandImpl.h"
 				>
 			</File>
@@ -323,6 +324,10 @@
 			</File>
 			<File
 				RelativePath="..\..\..\runtime\das_lite\src\ResultSetMetaData.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\..\runtime\das_lite\src\SqlException.h"
 				>
 			</File>
 			<File

Modified: incubator/tuscany/cpp/das/VSExpress/tuscany_das/das_runtime/das_runtime.suo
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/VSExpress/tuscany_das/das_runtime/das_runtime.suo?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
Binary files - no diff available.

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Command.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Command.h?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Command.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Command.h Sat Apr 21 00:04:12 2007
@@ -26,7 +26,7 @@
 /**
  * A Command is used to execute a read or write to a database
  */
-virtual class Command {
+class Command {
 
 	public:
 
@@ -40,7 +40,7 @@
 		 * 
 		 * @return the root DataObject
 		 */
-		commonj::sdo::DataObjectPtr executeQuery(void);
+		virtual commonj::sdo::DataObjectPtr executeQuery(void) = 0;
 		
 };
 

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.cpp Sat Apr 21 00:04:12 2007
@@ -18,78 +18,113 @@
  */
 #include "Connection.h"
 
-Connection::Connection(HENV aEnvironment, HDBC aConnection) {
-	connection = aConnection;
-	environment = aEnvironment;
+Connection::Connection(string dns, string user, string password) throw (SqlException){
 	database = new Database(*this);
 
-   //try {
-//		SQLCHAR sqlDbmsName[255];
-		SQLSMALLINT strLen;
-		SQLINTEGER strLen2;
-//		SQLGetInfo(connection, SQL_DBMS_NAME, sqlDbmsName, sizeof(sqlDbmsName), &strLen);
-//		std::string dbmsName = (char*) sqlDbmsName;
-//
-//        if (dbmsName.find("Oracle") < 0) {
-////            boolUseGetGeneratedKeys = false;
-//        } else {
-//  //          boolUseGetGeneratedKeys = true;
-//        }
-
-		SQLSMALLINT autoCommit;
-		if (SQLGetConnectAttr(connection, SQL_ATTR_AUTOCOMMIT, &autoCommit, sizeof(autoCommit), &strLen2) == SQL_AUTOCOMMIT_ON) {
-            //throw new RuntimeException("AutoCommit must be off");
-        }
-
-//    } catch (SQLException e) {
-  //      throw new RuntimeException(e);
-    //}
+	SQLRETURN result;
 
+	SQLSMALLINT autoCommit;
+	SQLINTEGER strLen;
+
+	SQLINTEGER error;
+	SQLCHAR sqlStat;
+	SQLCHAR * message = 0;
+	SQLSMALLINT messageLength;
+
+	//Alloc environment handle
+	result = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&environment);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
+		throw SqlException("Error to alloc the environment handle - SQLHENV");
+
+	//Set the environment
+	result = SQLSetEnvAttr(environment, SQL_ATTR_ODBC_VERSION,(void*)SQL_OV_ODBC3, 0);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)){
+		SQLFreeHandle(SQL_HANDLE_ENV, environment);
+		throw SqlException("Error to set the environment handle - SQLHENV");
+	}	
+
+	//Allocate connection handle
+	result = SQLAllocHandle(SQL_HANDLE_DBC, environment, &connection);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)){
+		SQLFreeHandle(SQL_HANDLE_ENV, environment);
+		throw SqlException("Error to alloc the connection handle - SQLHDBC");
+	}
+
+	setAutoCommit(false);
+
+	//Connect to the datasource
+	result = SQLConnect(connection,  reinterpret_cast<SQLCHAR *>(const_cast<char *> (dns.c_str())), SQL_NTS,
+									 reinterpret_cast<SQLCHAR *>(const_cast<char *> (user.c_str())), SQL_NTS,
+									 reinterpret_cast<SQLCHAR *>(const_cast<char *> (password.c_str())), SQL_NTS);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)){
+
+		SQLGetDiagRec(SQL_HANDLE_DBC, connection,1, 
+		              &sqlStat, &error,message,100,&messageLength);
+
+		SQLFreeHandle(SQL_HANDLE_DBC, connection);
+		SQLFreeHandle(SQL_HANDLE_ENV, environment);
+
+		string error("Error to establish the connection.\nSQLSTATE: ");
+		error += reinterpret_cast<char*>(&sqlStat);
+		throw SqlException(error.c_str());
+	}
+
+	database = new Database(*this);
 }
 
-Connection::~Connection(void) {
+Connection::~Connection(void){
+
 	std::list<Statement*>::iterator it;
 
-	for (it = statements.begin() ; it != statements.end() ; it++ ) {
+	for(it=statements.begin(); it != statements.end(); it++)
 		delete *it;
-	}
 
 	delete database;
 
 	SQLDisconnect(connection);
-	SQLFreeConnect(connection);
-	SQLFreeEnv(environment);
-
+    SQLFreeHandle(SQL_HANDLE_DBC,connection);
+    SQLFreeHandle(SQL_HANDLE_ENV, environment);
 }
 
-HDBC Connection::getODBCConnection(void) const {
+SQLHDBC Connection::getODBCConnection(void) const{
 	return connection;
 }
 
-void Connection::cleanUp(void) {
+void Connection::commit(void){
 	SQLEndTran(SQL_HANDLE_DBC, connection, SQL_COMMIT);
 }
 
-void Connection::errorCleanUp(void) {
-	SQLTransact(environment, connection, SQL_ROLLBACK);
+void Connection::rollback(void){
+	SQLEndTran(SQL_HANDLE_DBC, connection, SQL_ROLLBACK);
+}
+
+void Connection::setAutoCommit(bool autoCommit){
+	if(autoCommit)
+		SQLSetConnectAttr(connection,SQL_ATTR_AUTOCOMMIT,reinterpret_cast<SQLPOINTER>(SQL_AUTOCOMMIT_ON), SQL_IS_INTEGER );
+	else
+		SQLSetConnectAttr(connection,SQL_ATTR_AUTOCOMMIT,SQL_AUTOCOMMIT_OFF, SQL_IS_INTEGER );
+}
+
+Database& Connection::getDatabase(void) const {
+	return *database;
 }
 
-//HSTMT* Connection::prepareStatement(std::string queryString) {
-//
-//	/*if (this.logger.isDebugEnabled()) {
-//		this.logger.debug("Preparing Statement: " + queryString);
-//	}*/
-//	HSTMT statement;
-//	SQLAllocStmt( connection, &statement);
-//	SQLPrepare(statement, (SQLCHAR*) queryString.c_str(), SQL_NTS);
-//	
-//	return &statement;
-//
-//}
-
-Statement& Connection::createStatement(void) {
-	HSTMT statementHandle;
-	SQLAllocStmt(connection, &statementHandle);
+Statement& Connection::createStatement(void) throw (SqlException){
+	SQLHSTMT statementHandle;
+	SQLRETURN result = SQLAllocHandle(SQL_HANDLE_STMT, connection, &statementHandle);
+
+	if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)){
+
+		SQLDisconnect(connection);
+		SQLFreeHandle(SQL_HANDLE_DBC, connection);
+		SQLFreeHandle(SQL_HANDLE_ENV, environment);
+
+		throw SqlException("Error to alloc the statement handle - SQLSTMT");
+	}
 
 	Statement* statement = new Statement(*this, statementHandle);
 	statements.push_back(statement);
@@ -98,21 +133,11 @@
 
 }
 
-void Connection::freeStatement(Statement& statement) {
+void Connection::freeStatement(Statement& statement){
 	std::list<Statement*>::iterator it;
 
-	for (it = statements.begin() ; it != statements.end() ; it++) {
-
-		if (&statement == *it) {
-			statements.erase(it);
-			return;
-
-		}
-
-	}
+	it = std::find(statements.begin(), statements.end(), &statement);
 
-}
-
-Database& Connection::getDatabase(void) const {
-	return *database;
+	if(it != statements.end() )
+		statements.erase(it);
 }

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.h?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Connection.h Sat Apr 21 00:04:12 2007
@@ -22,12 +22,18 @@
 #include <windows.h>
 #include <sql.h>
 #include <sqlext.h>
+
 #include <string>
 #include <list>
+#include <iostream>
+#include <algorithm>
 
 #include "Statement.h"
 #include "Database.h"
+#include "SqlException.h"
 
+using std::string;
+using std::exception;
 class Database;
 class Statement;
 
@@ -36,22 +42,23 @@
 	friend class Statement;
 
 	private:
-		HDBC connection;
-		HENV environment;
+		SQLHDBC connection;
+		SQLHENV environment;
 		Database* database;
 		std::list<Statement*> statements;
 
 		void freeStatement(Statement& statement);
 		
 	public:
-		Connection(HENV aEnvironment, HDBC aConnection);
+		Connection(string dns, string user, string password) throw (SqlException);
 		virtual ~Connection(void);
-		HDBC getODBCConnection(void) const;
-		void cleanUp(void);
-		void errorCleanUp(void);
-		Statement& createStatement(void);
+		SQLHDBC getODBCConnection(void) const;
+		void commit(void);
+		void rollback(void);
+		void setAutoCommit(bool autoCommit);
 		Database& getDatabase(void) const;
-		//Statement& prepareStatement(std::string queryString);
+		Statement& createStatement(void) throw (exception);
+		//PreparedStatement& prepareStatement(string sql);
 		
 };
 

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.cpp Sat Apr 21 00:04:12 2007
@@ -23,6 +23,6 @@
 
 DASFactory::~DASFactory(void) {}
 
-DAS* DASFactory::createDAS(HDBC* connection) {
+DAS* DASFactory::createDAS(Connection& connection) {
 	return 0;
 }

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.h?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactory.h Sat Apr 21 00:04:12 2007
@@ -24,15 +24,16 @@
 #include <string>
 
 #include "DAS.h"
+#include "Connection.h"
 
 class DAS;
 
-virtual class DASFactory {
+class DASFactory {
 
 	public:
 		DASFactory(void);
 		virtual ~DASFactory(void);
-		DAS* createDAS(HDBC* connection);
+		virtual DAS* createDAS(Connection& connection);
 
 };
 

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.cpp Sat Apr 21 00:04:12 2007
@@ -22,6 +22,6 @@
 
 DASFactoryImpl::~DASFactoryImpl(void) {}
 
-DAS* DASFactoryImpl::createDAS(Connection* connection) {
+DAS* DASFactoryImpl::createDAS(Connection& connection) {
 	return new DASImpl(connection);
 }

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.h?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/DASFactoryImpl.h Sat Apr 21 00:04:12 2007
@@ -32,7 +32,7 @@
 	public:
 		DASFactoryImpl(void);
 		virtual ~DASFactoryImpl(void);
-		DAS* createDAS(Connection* connection);
+		DAS* createDAS(Connection& connection);
 
 };
 

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.cpp Sat Apr 21 00:04:12 2007
@@ -60,8 +60,8 @@
 
 }
 
-DASImpl::DASImpl(Connection* inConnection) {
-    setConnection(inConnection);
+DASImpl::DASImpl(Connection& inConnection) {
+    setConnection(&inConnection);
 	config = new Config(*this);
 
 }

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.h?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/DASImpl.h Sat Apr 21 00:04:12 2007
@@ -47,7 +47,7 @@
 		Command* baseCreateCommand(std::string inSql);
 		
 	public:
-		DASImpl(Connection* inConnection);
+		DASImpl(Connection& inConnection);
 		virtual ~DASImpl(void);
 		Connection* getConnection(void);
 		Config& getConfig(void) const;

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilder.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilder.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilder.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilder.cpp Sat Apr 21 00:04:12 2007
@@ -20,6 +20,9 @@
 
 GraphBuilder::GraphBuilder(Config& config, ResultSet& resultSet) {
 	graphBuilderMetaData = new GraphBuilderMetaData(config, resultSet.getResultSetMetaData()) ;
+	commonj::sdo::DataFactoryPtr dataFactory = graphBuilderMetaData->createGraph();
+
+
 	/*this->resultSet* = resultSet;
 	
 	commonj::sdo::DataFactoryPtr dataFactory = graphBuiderMetaData.createGraph();

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilderMetaData.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilderMetaData.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilderMetaData.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilderMetaData.cpp Sat Apr 21 00:04:12 2007
@@ -35,15 +35,22 @@
 		if (table == 0) {
 			Table* newTable = new Table(config, columnTableName);
 			config.addTable(*newTable);
-			tablesColumns.insert(std::make_pair(columnTableName, new std::list<Column*>()));
 			table = newTable;
 
-		} else {
-			tablesColumns.insert(std::make_pair(table->getTableName(), new std::list<Column*>()));
 		}
 
-		graphTables->insert(std::make_pair(table->getTableName(), table));
-		tablesColumns[table->getTableName()]->push_back(new Column(columnName, columnSQLType));
+		std::map<std::string, std::list<Column*>*>::iterator it = tablesColumns.
+			find(columnTableName);
+
+		if (it == tablesColumns.end()) {
+			std::list<Column*>* columnsList = new std::list<Column*>();
+			columnsList->push_back(new Column(columnName, columnSQLType));	
+			tablesColumns.insert(std::make_pair(columnTableName, columnsList));
+			graphTables->insert(std::make_pair(table->getTableName(), table));
+
+		} else {
+			tablesColumns[columnTableName]->push_back(new Column(columnName, columnSQLType));
+		}
 
 	}
 
@@ -75,9 +82,10 @@
 		Table& table = *(it->second);
 		std::string tableName = table.getTableName();
 
-		dataFactory->addType(DAS_NAMESPACE, tableName);
-		dataFactory->addPropertyToType(DAS_NAMESPACE,DAS_ROOT_NAME,DAS_ROOT_NAME + 
-			tableName + "Property", DAS_NAMESPACE, tableName, true, false, true);
+		dataFactory->addType(DAS_NAMESPACE, tableName.c_str());
+		dataFactory->addPropertyToType(DAS_NAMESPACE, DAS_ROOT_NAME, 
+			((std::string) (DAS_ROOT_NAME + tableName + "Property")).c_str(), 
+			DAS_NAMESPACE, tableName.c_str(), true, false, true);
 
 	}
 

Added: incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.cpp?view=auto&rev=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.cpp Sat Apr 21 00:04:12 2007
@@ -0,0 +1,34 @@
+/*
+ * 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 "PreparedStatement.h"
+
+PreparedStatement::PreparedStatement(Connection& connection, SQLHSTMT statementHandle, string sql)
+	:Statement(connection,statementHandle){
+		this->sql = sql;
+
+		for(int i = 0; i < sql.size(); i++){
+			if(sql.at(i) == '?')
+				positions.push_back(i);
+		}
+}
+
+
+PreparedStatement::~PreparedStatement(){
+	Statement::~Statement();
+}

Added: incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.h?view=auto&rev=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.h (added)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/PreparedStatement.h Sat Apr 21 00:04:12 2007
@@ -0,0 +1,43 @@
+/*
+ * 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.    
+ */
+
+#ifndef PREPARED_STATEMENT_H
+#define PREPARED_STATEMENT_H
+
+#include "Statement.h";
+
+#include<vector>
+
+using std::vector;
+
+class PreparedStatement : Statement{
+
+	private:
+		string sql;
+		vector<int> positions;
+
+	public:
+		PreparedStatement(Connection& connection, SQLHSTMT statementHandle, string sql);
+		~PreparedStatement(void);
+
+		void setInt(int index, int elem);
+
+};
+
+#endif //PREPARED_STATEMENT_H

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.cpp Sat Apr 21 00:04:12 2007
@@ -95,18 +95,50 @@
 ReadCommandImpl::~ReadCommandImpl(void) {}
 
 commonj::sdo::DataObjectPtr ReadCommandImpl::executeQuery(void) {
-	ResultSet* results = statement->executeQuery(sql);
-    commonj::sdo::DataObjectPtr root = buildGraph(*results);
+	ResultSet& results = statement->executeQuery(sql);
+    commonj::sdo::DataObjectPtr root = buildGraph(results);
 	
-	delete results;
-
     return root;
 
 }
 
+//test
+#include "commonj/sdo/TypeList.h"
+#include "commonj/sdo/Type.h"
+#include <iostream>
+
+void printDataGraph(commonj::sdo::DataFactoryPtr dataFactory) {
+	const commonj::sdo::TypeList& typeList = dataFactory->getTypes();
+
+	for (int i = 0 ; i < typeList.size() ; i++) {
+		std::cout << "\n[" << typeList[i].getName() << "]\n";
+		commonj::sdo::PropertyList propertyList = typeList[i].getProperties();
+		
+		for (int j = 0 ; j < propertyList.size() ; j++) {
+
+			if (propertyList[j].isReference()) {
+				std::cout << "-> ";
+			}
+
+			if (propertyList[j].getType().isDataType()) {
+				std::cout << propertyList[j].getName() << " - ";
+			}
+			
+			std::cout << propertyList[j].getType().getName();
+
+			std::cout << "\n";
+
+		}
+
+	}
+
+}
+
 commonj::sdo::DataObjectPtr ReadCommandImpl::buildGraph(ResultSet& resultSet) { /*throws SQLException*/
 	GraphBuilderMetaData graphBuilderMetaData(((DASImpl*) das)->getConfig(), resultSet.getResultSetMetaData()); 
 	commonj::sdo::DataFactoryPtr dataFactory = graphBuilderMetaData.createGraph();
+	printDataGraph(dataFactory);
+	
 
 	//commonj::sdo::ChangeSummaryPtr changeSummary = rootDataObject->getChangeSummary();
 	

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.cpp Sat Apr 21 00:04:12 2007
@@ -22,10 +22,10 @@
 	resultSet = aResultSet;
 	unsigned int columnCount = getColumnCount();
 	
-	for (unsigned int i = 1 ; i <= columnCount ; i++) {
+	for (unsigned int i = 0 ; i < columnCount ; i++) {
 		std::string columnName = getColumnName(i);
 		std::string tableName = getTableName(i);
-		columnsIndexes.insert(std::make_pair(tableName + columnName, i - 1));
+		columnsIndexes.insert(std::make_pair(tableName + columnName, i));
 
 	}
 

Added: incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.cpp?view=auto&rev=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.cpp Sat Apr 21 00:04:12 2007
@@ -0,0 +1,25 @@
+/*
+ * 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 "SqlException.h"
+
+SqlException::SqlException(string errorText)
+	:exception(errorText.c_str()){}
+
+SqlException::~SqlException(){}

Added: incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.h?view=auto&rev=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.h (added)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/SqlException.h Sat Apr 21 00:04:12 2007
@@ -0,0 +1,34 @@
+/*
+ * 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.    
+ */
+
+#ifndef SQL_EXCEPTION_H
+#define SQL_EXCEPTION_H
+
+#include <string>
+
+using std::exception;
+using std::string;
+
+class SqlException : public exception{
+	public:
+		SqlException(string errorText);
+		~SqlException();
+};
+
+#endif;

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.cpp Sat Apr 21 00:04:12 2007
@@ -18,7 +18,7 @@
  */
 #include "Statement.h"
 
-Statement::Statement(Connection& connection, HSTMT statementHandle) {
+Statement::Statement(Connection& connection, SQLHSTMT statementHandle) {
 	this->statementHandle = statementHandle;	
 	this->connection = &connection;
 	resultSet = 0;
@@ -32,11 +32,11 @@
 
 }
 
-ResultSet* Statement::executeQuery(std::string sql) { /*throws SQLException*/
+ResultSet& Statement::executeQuery(std::string sql) { /*throws SQLException*/
 	SQLExecDirect(statementHandle, (SQLCHAR*) (char*) sql.c_str(), SQL_NTS);
 	resultSet = new ResultSet(*this);
 
-    return resultSet;
+    return *resultSet;
 
 }
 

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.h?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Statement.h Sat Apr 21 00:04:12 2007
@@ -29,23 +29,25 @@
 class Connection;
 class ResultSet;
 
+using std::string;
+
 class Statement {
 	
 	private:
-		HSTMT statementHandle;
+		SQLHSTMT statementHandle;
 		Connection* connection;
 		ResultSet* resultSet;
 		
 	protected:
-		std::string queryString;
+		string queryString;
 		
 	public:
-		Statement(Connection& connection, HSTMT statementHandle);
-		~Statement(void);
-		HSTMT getODBCStatement(void) const;
-		ResultSet* executeQuery(std::string sql); /*throws SQLException*/
-		Connection& getConnection(void);
-		void close(void);
+		Statement(Connection& connection, SQLHSTMT statementHandle);
+		virtual ~Statement(void);
+		virtual SQLHSTMT getODBCStatement(void) const;
+		virtual ResultSet& executeQuery(string sql); /*throws SQLException*/
+		virtual Connection& getConnection(void);
+		virtual void close(void);
 		
 };
 

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Table.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Table.cpp?view=diff&rev=530989&r1=530988&r2=530989
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Table.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Table.cpp Sat Apr 21 00:04:12 2007
@@ -59,9 +59,17 @@
 		std::string fkColumnName = fksResultSet->getSQLVarchar(7);
 		std::string pkTableName = fksResultSet->getSQLVarchar(2);
 		std::string pkColumnName = fksResultSet->getSQLVarchar(3);
+
+		fkColumnName = fkColumnName.substr(1, fkColumnName.size() - 2); 
+		pkColumnName = pkColumnName.substr(1, pkColumnName.size() - 2); 
+
+		Relationship* relationship = config.getRelationship(pkTableName, tableName);
 		
-		Relationship* relationship = new Relationship(pkTableName, tableName);
-		config.addRelationship(*relationship);
+		if (relationship == 0) {
+			relationship = new Relationship(pkTableName, tableName);
+			config.addRelationship(*relationship);
+
+		}
 		
 		KeyPair* keyPair = new KeyPair(pkColumnName, fkColumnName);
 		relationship->addKeyPair(*keyPair);
@@ -84,14 +92,12 @@
 }
 
 void Table::addColumns(std::list<Column*>& columns) {
-	ResultSet* pksResultSet = 0;
-
 	std::list<Column*>::iterator it;
 	for (it = columns.begin() ; it != columns.end() ;) {
 		std::map<std::string, Column*>::iterator it2 = this->columns.
 			find((*it)->getName());
 		
-		if (it2 != this->columns.end()) {
+		if (it2 == this->columns.end()) {
 			(*it)->setContainerTable(this);
 			this->columns.insert(std::make_pair((*it)->getName(), *it));
 			it++;
@@ -106,8 +112,7 @@
 	}
 
 	if (convOverConfig) {
-		std::list<Column*>::iterator it;
-
+		
 		for (it == columns.begin() ; it != columns.end() ; it++) {
 			Column* column = *it;
 			std::string columnName = column->getName();
@@ -122,6 +127,19 @@
 
 		loadConvOverConfigFKs(columns);
 
+	} else {
+		std::list<std::string>::iterator it2;
+
+		for (it2 = pkColumns.begin() ; it2 != pkColumns.end() ; it2++) {
+			for (it = columns.begin() ; it != columns.end() ; it++) {
+
+				if ((*it)->getName() == *it2) {
+					(*it)->setPK(true);
+				}
+
+			}
+		}
+
 	}
 
 }
@@ -160,9 +178,10 @@
 
 		if (it2 == columnsRelationships.end()) {
 			dataFactory->addType(DAS_NAMESPACE, column.getName());
-			dataFactory->addPropertyToType(DAS_NAMESPACE,tableName,
-				tableName + column.getName() + "Property", SDO_NAMESPACE, 
-				ODBCTypeHelper::getSDOType(column.getSQLType()) , false, false, true);
+			dataFactory->addPropertyToType(DAS_NAMESPACE, tableName.c_str(),
+				((std::string) (tableName + column.getName() + "Property")).c_str(), 
+				SDO_NAMESPACE, ODBCTypeHelper::getSDOType(column.getSQLType()).c_str() , false, 
+				false, true);
 
 			continue;
 	
@@ -171,9 +190,9 @@
 			Table* referecedTable = graphBuilderMetaData.getTable(relationship.getPKTableName());
 			
 			if (referecedTable != 0) {
-				dataFactory->addPropertyToType(DAS_NAMESPACE, tableName,
-				tableName + relationship.getPKTableName() + "Property", DAS_NAMESPACE, 
-					relationship.getPKTableName(), true, false, false);
+				dataFactory->addPropertyToType(DAS_NAMESPACE, tableName.c_str(),
+					((std::string) (tableName + relationship.getPKTableName() + "Property")).c_str(), 
+					DAS_NAMESPACE, relationship.getPKTableName().c_str(), true, false, false);
 
 			}
 			



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