tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adrianocrest...@apache.org
Subject svn commit: r531156 - in /incubator/tuscany/cpp/das: VSExpress/tuscany_das/das_lite/ VSExpress/tuscany_das/das_runtime/ runtime/das_lite/src/
Date Sun, 22 Apr 2007 08:34:54 GMT
Author: adrianocrestani
Date: Sun Apr 22 01:34:52 2007
New Revision: 531156

URL: http://svn.apache.org/viewvc?view=rev&rev=531156
Log:
- Modified the location where relationships between tables to Config class
- Deleted unsed file: ResultMetaData .cpp and .h

Removed:
    incubator/tuscany/cpp/das/runtime/das_lite/src/ResultMetadata.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/ResultMetadata.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/Column.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/Column.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/Config.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/Config.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/KeyPair.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/KeyPair.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.h
    incubator/tuscany/cpp/das/runtime/das_lite/src/Table.cpp
    incubator/tuscany/cpp/das/runtime/das_lite/src/Table.h

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=531156&r1=531155&r2=531156
==============================================================================
--- 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 Sun Apr 22 01:34:52
2007
@@ -138,204 +138,204 @@
 	</References>
 	<Files>
 		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
 			>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\BaseCommandImpl.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\BaseCommandImpl.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Column.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\Column.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\CommandImpl.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\Command.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Config.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\CommandImpl.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Connection.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\Config.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\DAS.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\Connection.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\DASFactory.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\DAS.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\DASFactoryImpl.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\das_constants.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\DASImpl.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\DASFactory.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Database.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\DASFactoryImpl.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\GraphBuilder.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\DASImpl.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\GraphBuilderMetaData.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\Database.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\KeyPair.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\GraphBuilder.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\ODBCTypeHelper.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\GraphBuilderMetaData.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\PreparedStatement.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\KeyPair.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\ReadCommandImpl.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\ODBCTypeHelper.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Relationship.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\PreparedStatement.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\ResultSet.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\ReadCommandImpl.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\ResultSetMetaData.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\Relationship.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\SqlException.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\ResultSet.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Statement.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\ResultSetMetaData.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Table.cpp"
+				RelativePath="..\..\..\runtime\das_lite\src\SqlException.h"
 				>
 			</File>
-			<Filter
-				Name="Resource Files"
-				Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-				UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-				>
-			</Filter>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\BaseCommandImpl.h"
+				RelativePath="..\..\..\runtime\das_lite\src\Statement.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Column.h"
+				RelativePath="..\..\..\runtime\das_lite\src\Table.h"
 				>
 			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Command.h"
+				RelativePath="..\..\..\runtime\das_lite\src\BaseCommandImpl.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\CommandImpl.h"
+				RelativePath="..\..\..\runtime\das_lite\src\Column.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Config.h"
+				RelativePath="..\..\..\runtime\das_lite\src\CommandImpl.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Connection.h"
+				RelativePath="..\..\..\runtime\das_lite\src\Config.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\DAS.h"
+				RelativePath="..\..\..\runtime\das_lite\src\Connection.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\das_constants.h"
+				RelativePath="..\..\..\runtime\das_lite\src\DAS.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\DASFactory.h"
+				RelativePath="..\..\..\runtime\das_lite\src\DASFactory.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\DASFactoryImpl.h"
+				RelativePath="..\..\..\runtime\das_lite\src\DASFactoryImpl.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\DASImpl.h"
+				RelativePath="..\..\..\runtime\das_lite\src\DASImpl.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Database.h"
+				RelativePath="..\..\..\runtime\das_lite\src\Database.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\GraphBuilder.h"
+				RelativePath="..\..\..\runtime\das_lite\src\GraphBuilder.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\GraphBuilderMetaData.h"
+				RelativePath="..\..\..\runtime\das_lite\src\GraphBuilderMetaData.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\KeyPair.h"
+				RelativePath="..\..\..\runtime\das_lite\src\KeyPair.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\ODBCTypeHelper.h"
+				RelativePath="..\..\..\runtime\das_lite\src\ODBCTypeHelper.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\PreparedStatement.h"
+				RelativePath="..\..\..\runtime\das_lite\src\PreparedStatement.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\ReadCommandImpl.h"
+				RelativePath="..\..\..\runtime\das_lite\src\ReadCommandImpl.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Relationship.h"
+				RelativePath="..\..\..\runtime\das_lite\src\Relationship.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\ResultSet.h"
+				RelativePath="..\..\..\runtime\das_lite\src\ResultSet.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\ResultSetMetaData.h"
+				RelativePath="..\..\..\runtime\das_lite\src\ResultSetMetaData.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\SqlException.h"
+				RelativePath="..\..\..\runtime\das_lite\src\SqlException.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Statement.h"
+				RelativePath="..\..\..\runtime\das_lite\src\Statement.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\runtime\das_lite\src\Table.h"
+				RelativePath="..\..\..\runtime\das_lite\src\Table.cpp"
 				>
 			</File>
 		</Filter>

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=531156&r1=531155&r2=531156
==============================================================================
Binary files - no diff available.

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Column.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Column.cpp?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Column.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Column.cpp Sun Apr 22 01:34:52 2007
@@ -24,6 +24,7 @@
 	this->sqlType = sqlType;
 	containerTable = 0;
 	pk = false;
+	keyPairs = 0;
 	
 }
 
@@ -53,10 +54,28 @@
 	return sqlType;
 }
 
+std::list<KeyPair*>& Column::getKeyPairs(void) const {
+	return *keyPairs;
+}
+
+bool Column::isFK(void) const {
+	return (keyPairs == 0 || keyPairs->size() > 0);
+}
+
 void Column::setMappedName(std::string mappedName) {
 	this->mappedName = mappedName;
 }
 
 std::string Column::getMappedName(void) const {
 	return mappedName;
+}
+
+void Column::addKeyPair(KeyPair& keyPair) {
+
+	if (keyPairs == 0) {
+		keyPairs= new std::list<KeyPair*>();
+	}
+
+	keyPairs->push_back(&keyPair);
+
 }

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Column.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Column.h?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Column.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Column.h Sun Apr 22 01:34:52 2007
@@ -23,6 +23,7 @@
 #include <sql.h>
 #include <sqlext.h>
 #include <string>
+#include <list>
 
 #include "Table.h"
 #include "das_constants.h"
@@ -37,6 +38,7 @@
 		std::string mappedName;
 		SQLSMALLINT sqlType;
 		Table* containerTable;
+		std::list<KeyPair*>* keyPairs;
 
 		void setContainerTable(Table* containerTable);
 		
@@ -47,6 +49,7 @@
 		void setReferencedTableAndColumn(std::string referencedTableName, std::string referencedColumnName);
 		void setPK(bool pk);
 		void setMappedName(std::string mappedName);
+		void addKeyPair(KeyPair& keyPair);
 		
 		std::string getMappedName(void) const;
 		bool isFK(void) const;
@@ -55,6 +58,7 @@
 		bool isPK(void) const;
 		SQLSMALLINT getSQLType(void) const;
 		Table* getContainerTable(void) const;
+		std::list<KeyPair*>& getKeyPairs(void) const;
 
 		std::string getName(void) const;
 

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Config.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Config.cpp?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Config.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Config.cpp Sun Apr 22 01:34:52 2007
@@ -22,6 +22,7 @@
 	relationships = new std::map<std::string, Relationship*>();
 	tables = new std::map<std::string, Table*>();
 	this->das = &das;
+	convOverConfig = false;
 		
 }
 
@@ -47,16 +48,96 @@
 
 void Config::addTable(Table& table) {
 	tables->insert(std::make_pair(table.getTableName(), &table));
+
+	//load PKs
+	ResultSet* pksResultSet = 0;
+	Connection* conn = ((DASImpl*) das)->getConnection();
+
+	try {
+		pksResultSet = conn->getDatabase().getPKs(table.getTableName());
+	} catch (std::runtime_error& e) {
+		convOverConfig = true;
+		return;
+
+	}
+
+	if (pksResultSet != 0) {
+			
+		while (pksResultSet->next()) {
+			table.addPKColumn(pksResultSet->getSQLVarchar(3));
+		}
+
+	}
+	
+	//load FKs
+	ResultSet* fksResultSet = 0;
+
+	try {
+		fksResultSet = conn->getDatabase().getFKs(table.getTableName());
+	} catch (std::runtime_error& e) {
+		convOverConfig = true;
+		return;
+
+	}
+			
+	while (fksResultSet->next()) {
+		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 = getRelationship(pkTableName, table.getTableName());
+		
+		if (relationship == 0) {
+			relationship = new Relationship(pkTableName, table.getTableName());
+			addRelationship(*relationship);
+
+		}
+		
+		KeyPair* keyPair = new KeyPair(pkColumnName, fkColumnName);
+		relationship->addKeyPair(*keyPair);
+
+	}
+
 }
 
 void Config::addRelationship(Relationship& relationship) {
-	relationships->insert(std::make_pair(relationship.getPKTableName() + relationship.getFKTableName(),

+	relationships->insert(std::make_pair(relationship.getPKTableName() + relationship.getFKTableName(),
 		&relationship));
+	relationship.setConfig(this);
+
+}
+
+std::list<Relationship*>* Config::getRelationships(std::string tableName, bool pkTable)
const {
+	std::list<Relationship*>* relationshipList = new std::list<Relationship*>();
+	std::map<std::string, Relationship*>::const_iterator it;
+
+	for (it = relationships->begin() ; it != relationships->end() ; it++) {
+		
+		if (pkTable) {
+
+			if (it->second->getPKTableName() == tableName) {
+				relationshipList->push_back(it->second);
+			}
+
+		} else {
+
+			if (it->second->getFKTableName() == tableName) {
+				relationshipList->push_back(it->second);
+			}
+
+		}
+
+	}
+
+	return relationshipList;
+
 }
 
 Relationship* Config::getRelationship(std::string tableName, std::string referencedTableName)
const {
-	std::map<std::string, Relationship*>::iterator it = 
-		relationships->find(tableName + referencedTableName);
+	std::map<std::string, Relationship*>::iterator it = relationships->find(tableName
+ referencedTableName);
 
 	if (it == relationships->end()) {
 		return 0;
@@ -74,6 +155,10 @@
 	return *tables;
 }
 
+bool Config::isConvOverConfig(void) const {
+	return convOverConfig;
+}
+
 Table* Config::getTable(std::string tableName) const {
 	std::map<std::string, Table*>::iterator tableIterator = tables->find(tableName);
 
@@ -85,23 +170,19 @@
 
 }
 
-std::list<Relationship*>* Config::getRelationships(std::string tableName) const {
-	std::map<std::string, Relationship*>::iterator it;
-	std::list<Relationship*>* relationshipList = new std::list<Relationship*>();
+DAS& Config::getDAS(void) const {
+	return *das;
+}
 
-	for (it = relationships->begin() ; it != relationships->end() ; it++) {
-		Relationship* relationship = it->second;
+void Config::loadConvOverConfigFKs(std::list<Column*>& columns) {
+	std::list<Column*>::iterator it;
 
-		if (relationship->getFKTableName() == tableName) {
-			relationshipList->push_back(relationship);
-		}	
+	for (it == columns.begin() ; it != columns.end() ; it++) {
+		Column* column = *it;
+		std::string columnName = column->getName();
 
+		
+		
 	}
 
-	return relationshipList;
-
-}
-
-DAS& Config::getDAS(void) const {
-	return *das;
 }

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Config.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Config.h?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Config.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Config.h Sun Apr 22 01:34:52 2007
@@ -28,6 +28,7 @@
 #include "Relationship.h"
 
 class Table;
+class Column;
 
 class Config {
 
@@ -35,6 +36,7 @@
 		std::map<std::string, Relationship*>* relationships;
 		std::map<std::string, Table*>* tables;
 		DAS* das;
+		bool convOverConfig;
 
 	public:
 		Config(DAS& das);
@@ -47,11 +49,13 @@
 		std::map<std::string, Table*>& getTables(void) const;
 
 		DAS& getDAS(void) const;
-		
+		bool isConvOverConfig(void) const;
+
+		void loadConvOverConfigFKs(std::list<Column*>& columns);
 		Table* getTable(std::string tableName) const;
 		Relationship* getRelationship(std::string tableName, std::string referencedTableName) const;
-		std::list<Relationship*>* getRelationships(std::string tableName) const;
-		
-};
+		std::list<Relationship*>* getRelationships(std::string tableName, bool pkTable =
true) const;
 
+};
+		
 #endif //CONFIG_H

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=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilder.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilder.cpp Sun Apr 22 01:34:52 2007
@@ -21,12 +21,9 @@
 GraphBuilder::GraphBuilder(Config& config, ResultSet& resultSet) {
 	graphBuilderMetaData = new GraphBuilderMetaData(config, resultSet.getResultSetMetaData())
;
 	commonj::sdo::DataFactoryPtr dataFactory = graphBuilderMetaData->createGraph();
-
-
-	/*this->resultSet* = resultSet;
+	this->resultSet = &resultSet;
 	
-	commonj::sdo::DataFactoryPtr dataFactory = graphBuiderMetaData.createGraph();
-	root = dataFactory->create(DAS_NAMESPACE, DAS_ROOT_NAME);
+	/*root = dataFactory->create(DAS_NAMESPACE, DAS_ROOT_NAME);
 	
 	const std::map<std::string, Table*> tables = graphBuiderMetaData.getTables();
 	std::map<std::string, Table*>::const_iterator it;
@@ -34,9 +31,10 @@
 
 		for (it = tables.begin() ; it != tables.end() ; i++) {
 			Table* table = it->second;
-			DataObjectPtr tableDataObject = root->createDataObject();
+			DataObjectPtr tableDataObject = root->create(DAS_NAMESPACE, 
+				table->getTableName());
 
-			root->
+			
 
 		}
 

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=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilderMetaData.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/GraphBuilderMetaData.cpp Sun Apr 22 01:34:52
2007
@@ -84,8 +84,7 @@
 
 		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);
+			tableName.c_str(), DAS_NAMESPACE, tableName.c_str(), true, false, true);
 
 	}
 

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/KeyPair.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/KeyPair.cpp?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/KeyPair.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/KeyPair.cpp Sun Apr 22 01:34:52 2007
@@ -21,6 +21,7 @@
 KeyPair::KeyPair(std::string pkColumnName, std::string fkColumnName) {
 	this->pkColumnName = pkColumnName;
 	this->fkColumnName = fkColumnName;
+	relationship = 0;
 
 }
 
@@ -32,4 +33,12 @@
 
 std::string KeyPair::getFKColumnName(void) const {
 	return fkColumnName;
-}
\ No newline at end of file
+}
+
+void KeyPair::setRelationship(Relationship* relationship) {
+	this->relationship = relationship;
+}
+
+Relationship* KeyPair::getRelationship(void) const {
+	return relationship;
+}

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/KeyPair.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/KeyPair.h?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/KeyPair.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/KeyPair.h Sun Apr 22 01:34:52 2007
@@ -24,9 +24,14 @@
 
 class KeyPair {
 
+	friend class Relationship;
+
 	private:
 		std::string pkColumnName;
 		std::string fkColumnName;
+		Relationship* relationship;
+
+		void setRelationship(Relationship* relationship);
 		
 	public:
 		KeyPair(std::string pkColumnName, std::string fkColumnName);
@@ -34,6 +39,7 @@
 
 		std::string getPKColumnName(void) const;
 		std::string getFKColumnName(void) const;
+		Relationship* getRelationship(void) const;
 
 };
 

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=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.cpp Sun Apr 22 01:34:52
2007
@@ -135,11 +135,9 @@
 }
 
 commonj::sdo::DataObjectPtr ReadCommandImpl::buildGraph(ResultSet& resultSet) { /*throws
SQLException*/
-	GraphBuilderMetaData graphBuilderMetaData(((DASImpl*) das)->getConfig(), resultSet.getResultSetMetaData());

-	commonj::sdo::DataFactoryPtr dataFactory = graphBuilderMetaData.createGraph();
-	printDataGraph(dataFactory);
+	GraphBuilder graphBuilder(((DASImpl*) das)->getConfig(), resultSet); 
 	
-
+	//printDataGraph(dataFactory);
 	//commonj::sdo::ChangeSummaryPtr changeSummary = rootDataObject->getChangeSummary();
 	
 	return 0;

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.h?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/ReadCommandImpl.h Sun Apr 22 01:34:52 2007
@@ -22,7 +22,7 @@
 #include <list>
 
 #include "CommandImpl.h"
-#include "GraphBuilderMetaData.h"
+#include "GraphBuilder.h"
 
 #include "commonj/sdo/DataFactory.h"
 #include "commonj/sdo/DataObject.h"

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.cpp?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.cpp Sun Apr 22 01:34:52 2007
@@ -22,6 +22,7 @@
 	this->pkTableName = pkTableName;
 	this->fkTableName = fkTableName;
 	keyPairs = new std::map<std::string, KeyPair*>();
+	config = 0;
 
 }
 
@@ -54,8 +55,26 @@
 }
 
 void Relationship::addKeyPair(KeyPair& keyPair) {
+	keyPair.setRelationship(this);
 	keyPairs->insert(
 		std::make_pair(keyPair.getPKColumnName() + keyPair.getFKColumnName(), &keyPair));
 
+	if (config != 0) {
+		Table* table = config->getTable(fkTableName);
+
+		if (table != 0) {
+			Column* column = table->getColumn(keyPair.getFKColumnName());
+
+			if (column != 0) {
+				column->addKeyPair(keyPair);
+			}
+
+		}
+
+	}
+	
 }
 
+void Relationship::setConfig(Config* config) {
+	this->config = config;
+}

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.h?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Relationship.h Sun Apr 22 01:34:52 2007
@@ -23,13 +23,19 @@
 #include <map>
 
 #include "KeyPair.h"
+#include "Config.h"
 
 class Relationship {
 
+	friend class Config;
+
 	private:
 		std::string pkTableName;
 		std::string fkTableName;
 		std::map<std::string, KeyPair*>* keyPairs;
+		Config* config;
+
+		void setConfig(Config* config);
 		
 	public:
 		Relationship(std::string pkTableName, std::string fkTableName);

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=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.cpp Sun Apr 22 01:34:52
2007
@@ -33,7 +33,7 @@
 
 ResultSetMetaData::~ResultSetMetaData(void) {}
 
-SQLSMALLINT ResultSetMetaData::getSQLCType(SQLSMALLINT sqlType) const {
+SQLSMALLINT ResultSetMetaData::getSQLCType(SQLSMALLINT sqlType) {
 
 	switch (sqlType) {
 

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.h?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/ResultSetMetaData.h Sun Apr 22 01:34:52
2007
@@ -32,12 +32,11 @@
 		ResultSet* resultSet;
 		std::map<std::string, unsigned int> columnsIndexes;
 
-		SQLSMALLINT getSQLCType(SQLSMALLINT sqlType) const;
+		static SQLSMALLINT getSQLCType(SQLSMALLINT sqlType);
 
 	public:
 		ResultSetMetaData(ResultSet* aResultSet);
 		virtual ~ResultSetMetaData(void);
-
 
 		const ResultSet& getResultSet(void) const;
 

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=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Table.cpp (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Table.cpp Sun Apr 22 01:34:52 2007
@@ -22,59 +22,6 @@
 	this->config = &config;
 	this->tableName = tableName;
 	this->mappedName = tableName;
-	convOverConfig = false;
-	Connection* conn = ((DASImpl&) config.getDAS()).getConnection();
-
-	//load PKs
-	ResultSet* pksResultSet = 0;
-
-	try {
-		pksResultSet = conn->getDatabase().getPKs(tableName);
-	} catch (std::runtime_error& e) {
-		convOverConfig = true;
-		return;
-
-	}
-
-	if (pksResultSet != 0) {
-			
-		while (pksResultSet->next()) {
-			pkColumns.push_back(pksResultSet->getSQLVarchar(3));
-		}
-
-	}
-	
-	//load FKs
-	ResultSet* fksResultSet = 0;
-
-	try {
-		fksResultSet = conn->getDatabase().getFKs(tableName);
-	} catch (std::runtime_error& e) {
-		convOverConfig = true;
-		return;
-
-	}
-			
-	while (fksResultSet->next()) {
-		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);
-		
-		if (relationship == 0) {
-			relationship = new Relationship(pkTableName, tableName);
-			config.addRelationship(*relationship);
-
-		}
-		
-		KeyPair* keyPair = new KeyPair(pkColumnName, fkColumnName);
-		relationship->addKeyPair(*keyPair);
-
-	}
 	
 }
 
@@ -111,7 +58,7 @@
 
 	}
 
-	if (convOverConfig) {
+	if (config->isConvOverConfig()) {
 		
 		for (it == columns.begin() ; it != columns.end() ; it++) {
 			Column* column = *it;
@@ -121,12 +68,24 @@
 				column->setPK(true);
 				pkColumns.push_back(columnName);
 
+			} else if (columnName.substr(columnName.size() - 4, 3) == "_id") {
+				std::string referencedTable = columnName.substr(0, columnName.size() - 3);
+				std::string tableName = column->getContainerTable()->getTableName();
+				Relationship* relationship = config->getRelationship(tableName, referencedTable);
+
+				if (relationship == 0) {
+					relationship = new Relationship(tableName, referencedTable);
+					config->addRelationship(*relationship);
+					
+				}
+
+				KeyPair* keyPair = new KeyPair("id", column->getName());
+				relationship->addKeyPair(*keyPair);
+
 			}
 			
 		}
 
-		loadConvOverConfigFKs(columns);
-
 	} else {
 		std::list<std::string>::iterator it2;
 
@@ -142,60 +101,71 @@
 
 	}
 
-}
-
-Config& Table::getConfig(void) const {
-	return *config;
-}
+	std::list<Relationship*>* relationships = config->getRelationships(tableName, false);
+	std::list<Relationship*>::const_iterator it2;
 
-void Table::createGraph(const GraphBuilderMetaData& graphBuilderMetaData, commonj::sdo::DataFactoryPtr
dataFactory) const {
-	std::map<std::string, Column*>::const_iterator it;
-	std::list<Relationship*>* relationships = config->getRelationships(tableName);
-	std::map<std::string, Relationship*> columnsRelationships;
-	
-	for (std::list<Relationship*>::iterator relationshipsIterator = relationships->begin()
; 
-		relationshipsIterator != relationships->end() ; relationshipsIterator++) {
-			Relationship* relationship = *relationshipsIterator;
-			std::map<std::string, KeyPair*>& keyPairs = relationship->getKeyPairs();
-			
-			for (std::map<std::string, KeyPair*>::iterator keyPairsIterator = keyPairs.begin()
; 
-				keyPairsIterator != keyPairs.end() ; keyPairsIterator++) {
-					KeyPair* keyPair = keyPairsIterator->second;
+	for (it2 = relationships->begin() ; it2 != relationships->end() ; it2++) {
+		Relationship& relationship = **it2;
+		std::map<std::string, KeyPair*>& keyPairs = relationship.getKeyPairs();
+		std::map<std::string, KeyPair*>::const_iterator it3;
+
+		for (it3 == keyPairs.begin() ; it3 != keyPairs.end() ; it3++) {
+			for (it == columns.begin() ; it != columns.end() ; it++) {
+				Column& column = **it;
 
-					columnsRelationships.insert(std::make_pair(keyPair->getFKColumnName(), 
-						relationship));
+				if (column.getName() == it3->second->getFKColumnName()) {
+					column.addKeyPair(*(it3->second));
+				}
 
 			}
+		}
 
 	}
 
 	delete relationships;
 
+}
+
+Config& Table::getConfig(void) const {
+	return *config;
+}
+
+void Table::addPKColumn(std::string columnName) {
+	pkColumns.push_back(columnName);
+}
+
+void Table::createGraph(const GraphBuilderMetaData& graphBuilderMetaData, commonj::sdo::DataFactoryPtr
dataFactory) const {
+	std::map<std::string, Column*>::const_iterator it;
+	
 	for (it = columns.begin() ; it != columns.end() ; it++) {
 		Column& column = *(it->second);
 	
-		std::map<std::string, Relationship*>::const_iterator it2 = columnsRelationships.find(column.getName());
+		if (column.isFK()) {
+			std::list<KeyPair*>& keyPairs = column.getKeyPairs();
+			std::list<KeyPair*>::const_iterator it2;
+
+			for (it2 = keyPairs.begin() ; it2 != keyPairs.end() ; it2++) {
+				KeyPair& keyPair = **it2;
+				Table* referecedTable = graphBuilderMetaData.getTable(
+					keyPair.getRelationship()->getPKTableName());			
+
+				if (referecedTable != 0) {
+					dataFactory->addPropertyToType(DAS_NAMESPACE, tableName.c_str(),
+						column.getName().c_str(), DAS_NAMESPACE, 
+						keyPair.getRelationship()->getPKTableName().c_str(), true, false, false);
+
+				}
 
-		if (it2 == columnsRelationships.end()) {
+			}
+	
+		} else {
 			dataFactory->addType(DAS_NAMESPACE, column.getName());
 			dataFactory->addPropertyToType(DAS_NAMESPACE, tableName.c_str(),
-				((std::string) (tableName + column.getName() + "Property")).c_str(), 
-				SDO_NAMESPACE, ODBCTypeHelper::getSDOType(column.getSQLType()).c_str() , false, 
+				column.getName().c_str(), SDO_NAMESPACE, 
+				ODBCTypeHelper::getSDOType(column.getSQLType()).c_str() , false, 
 				false, true);
 
-			continue;
-	
-		} else {
-			Relationship& relationship = *(it2->second);
-			Table* referecedTable = graphBuilderMetaData.getTable(relationship.getPKTableName());
-			
-			if (referecedTable != 0) {
-				dataFactory->addPropertyToType(DAS_NAMESPACE, tableName.c_str(),
-					((std::string) (tableName + relationship.getPKTableName() + "Property")).c_str(), 
-					DAS_NAMESPACE, relationship.getPKTableName().c_str(), true, false, false);
 
-			}
-			
 		}
 	
 	}
@@ -220,37 +190,17 @@
 	this->mappedName = mappedName;
 }
 
-std::string Table::getMappedName(void) const {
-	return mappedName;
-}
-
-void Table::loadConvOverConfigFKs(std::list<Column*>& columns) {
-	std::list<Column*>::iterator it;
+Column* Table::getColumn(std::string columnName) const {
+	std::map<std::string, Column*>::const_iterator it = columns.find(columnName);
 
-	for (it == columns.begin() ; it != columns.end() ; it++) {
-		Column* column = *it;
-		std::string columnName = column->getName();
-
-		if (columnName.substr(columnName.size() - 4, 3) == "_id") {
-			std::string referencedTable = columnName.substr(0, columnName.size() - 3);
-			Relationship* relationship = config->
-				getRelationship(tableName, referencedTable);
-
-			if (relationship == 0) {
-				relationship = new Relationship(tableName, referencedTable);
-				config->addRelationship(*relationship);
-				
-			}
-
-			KeyPair* keyPair = new KeyPair("id", column->getName());
-			relationship->addKeyPair(*keyPair);
-
-		}
-		
+	if (it == columns.end()) {
+		return 0;
 	}
 
+	return it->second;
+
 }
 
-void Table::removeAllColumns(void) {
-	columns.clear();
+std::string Table::getMappedName(void) const {
+	return mappedName;
 }

Modified: incubator/tuscany/cpp/das/runtime/das_lite/src/Table.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/das_lite/src/Table.h?view=diff&rev=531156&r1=531155&r2=531156
==============================================================================
--- incubator/tuscany/cpp/das/runtime/das_lite/src/Table.h (original)
+++ incubator/tuscany/cpp/das/runtime/das_lite/src/Table.h Sun Apr 22 01:34:52 2007
@@ -47,20 +47,19 @@
 		Config* config;
 		std::string tableName;
 		std::string mappedName;
-		bool convOverConfig;
 		
 	public:
 		Table(Config& config, std::string tableName);
 		virtual ~Table(void);
 
 		void addColumns(std::list<Column*>& columns);
-		void loadConvOverConfigFKs(std::list<Column*>& columns);
 		void setMappedName(std::string mappedName);
-		void removeAllColumns(void);
+		void addPKColumn(std::string columnName);
 
 		std::string getMappedName(void) const;
 		Config& getConfig(void) const;
 		std::string getTableName(void) const;
+		Column* getColumn(std::string columnName) const;
 		
 		void createGraph(const GraphBuilderMetaData& graphBuilderMetaData, commonj::sdo::DataFactoryPtr
dataFactory) const;
 		void populateGraph(commonj::sdo::DataObjectPtr dataObject/*, ResultSet& resultSet*/)
const;



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


Mime
View raw message