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/05/11 23:36:57 UTC

svn commit: r537297 [7/10] - in /incubator/tuscany/cpp/das: VSExpress/tuscany_das/ VSExpress/tuscany_das/das_lite/ VSExpress/tuscany_das/das_runtime/ das_java_classes/ das_java_classes/config/ runtime/core/include/ runtime/core/include/apache/ runtime/...

Added: incubator/tuscany/cpp/das/das_java_classes/TableData.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/TableData.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/TableData.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/TableData.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,164 @@
+/*
+ * 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 "TableData.h"
+
+TableData::TableData(string tableName) {
+	boolHasValidPrimaryKey = true;
+
+	/*if (this.logger.isDebugEnabled()) {
+        this.logger.debug("Creating TableData for table " + tableName);
+    }*/
+
+    name = tableName;
+
+}
+
+TableData::~TableData(void) {
+}
+
+void TableData::addData(string columnName, bool isPrimaryKeyColumn, DASObject* data) {
+
+	/*if (this.logger.isDebugEnabled()) {
+        this.logger.debug("Adding column " + columnName + " with value " + data);
+    }*/
+
+    columnData.insert(make_pair(columnName, data));
+
+    if (isPrimaryKeyColumn) {
+
+        if (data == NULL) {
+
+            /*if (this.logger.isDebugEnabled()) {
+                this.logger.debug("Column " + columnName + " is a primary key column and is null");
+            }*/
+
+            boolHasValidPrimaryKey = false;
+
+        }
+
+        primaryKey.insert(data);
+
+    }
+
+}
+
+DASObject* TableData::getColumnData(string columnName) {
+	map<string, DASObject*>::iterator it = columnData.find(columnName);
+
+	if (it == columnData.end()) {
+		return NULL;
+	}
+
+	return it->second;
+
+}
+
+string TableData::getTableName(void) {
+	return name;
+}
+
+list<DASObject*>* TableData::getPrimaryKeyValues(void) {
+	return &primaryKey;
+}
+
+bool TableData::hasValidPrimaryKey(void) {
+	return boolHasValidPrimaryKey;
+}
+/*
+ * 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 "TableData.h"
+
+TableData::TableData(string tableName) {
+	boolHasValidPrimaryKey = true;
+
+	/*if (this.logger.isDebugEnabled()) {
+        this.logger.debug("Creating TableData for table " + tableName);
+    }*/
+
+    name = tableName;
+
+}
+
+TableData::~TableData(void) {
+}
+
+void TableData::addData(string columnName, bool isPrimaryKeyColumn, DASObject* data) {
+
+	/*if (this.logger.isDebugEnabled()) {
+        this.logger.debug("Adding column " + columnName + " with value " + data);
+    }*/
+
+    columnData.insert(make_pair(columnName, data));
+
+    if (isPrimaryKeyColumn) {
+
+        if (data == NULL) {
+
+            /*if (this.logger.isDebugEnabled()) {
+                this.logger.debug("Column " + columnName + " is a primary key column and is null");
+            }*/
+
+            boolHasValidPrimaryKey = false;
+
+        }
+
+        primaryKey.insert(data);
+
+    }
+
+}
+
+DASObject* TableData::getColumnData(string columnName) {
+	map<string, DASObject*>::iterator it = columnData.find(columnName);
+
+	if (it == columnData.end()) {
+		return NULL;
+	}
+
+	return it->second;
+
+}
+
+string TableData::getTableName(void) {
+	return name;
+}
+
+list<DASObject*>* TableData::getPrimaryKeyValues(void) {
+	return &primaryKey;
+}
+
+bool TableData::hasValidPrimaryKey(void) {
+	return boolHasValidPrimaryKey;
+}

Added: incubator/tuscany/cpp/das/das_java_classes/TableData.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/TableData.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/TableData.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/TableData.h Fri May 11 14:36:45 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.    
+ */
+#ifndef TABLE_DATA_H
+#define TABLE_DATA_H
+
+#include <string>
+#include <map>
+#include <list>
+
+#include "DASObject.h"
+
+using namespace std;
+
+class TableData {
+
+	private:
+		map<string, DASObject*> columnData;
+		list<DASObject*> primaryKey;
+		string name;
+		bool boolHasValidPrimaryKey;
+
+	public:
+		TableData(string tableName);
+		~TableData(void);
+		void addData(string columnName, bool isPrimaryKeyColumn, DASObject* data);
+		DASObject* getColumnData(string columnName);
+		string getTableName(void);
+		list<DASObject*>* getPrimaryKeyValues(void);
+		bool hasValidPrimaryKey(void);
+		
+};
+
+#endif //TABLE_DATA_H
+/*
+ * 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 TABLE_DATA_H
+#define TABLE_DATA_H
+
+#include <string>
+#include <map>
+#include <list>
+
+#include "DASObject.h"
+
+using namespace std;
+
+class TableData {
+
+	private:
+		map<string, DASObject*> columnData;
+		list<DASObject*> primaryKey;
+		string name;
+		bool boolHasValidPrimaryKey;
+
+	public:
+		TableData(string tableName);
+		~TableData(void);
+		void addData(string columnName, bool isPrimaryKeyColumn, DASObject* data);
+		DASObject* getColumnData(string columnName);
+		string getTableName(void);
+		list<DASObject*>* getPrimaryKeyValues(void);
+		bool hasValidPrimaryKey(void);
+		
+};
+
+#endif //TABLE_DATA_H

Added: incubator/tuscany/cpp/das/das_java_classes/TableImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/TableImpl.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/TableImpl.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/TableImpl.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,514 @@
+/*
+ * 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 "TableImpl.h"
+
+TableImpl::TableImpl(void) {
+	list<Column*>* column = NULL;
+	Create* create = NULL;
+	Update* update = NULL;
+	Delete* delet = NULL;
+	string tableName = TABLE_NAME_DEFAULT_;
+	string typeName = TYPE_NAME_DEFAULT_;
+
+}
+
+TableImpl::~TableImpl(void) {
+}
+
+Type* TableImpl::getType(void) {
+	return ((ConfigFactoryImpl*) ConfigFactory::INSTANCE).getTable();
+}
+
+list<Column*>* TableImpl::getColumn(void) {
+
+	if (column == NULL) {
+      //column = createPropertyList(ListKind.CONTAINMENT, Column.class, COLUMN);
+    }
+
+    return column;
+
+}
+
+Create* TableImpl::getCreate(void) {
+	return create;
+}
+
+//ChangeContext* TableImpl::basicSetCreate(Create* newCreate, ChangeContext* changeContext) {
+//	Create* oldCreate = create;
+//    create = newCreate;
+//
+//    return changeContext;
+//
+//}
+
+void TableImpl::setCreate(Create* newCreate) {
+	if (newCreate != create) {
+		ChangeContext* changeContext = NULL;
+	
+		if (create != NULL) {
+			changeContext = inverseRemove(create, this, OPPOSITE_FEATURE_BASE - CREATE, NULL, changeContext);
+		}
+
+		if (newCreate != NULL) {
+			changeContext = inverseAdd(newCreate, this, OPPOSITE_FEATURE_BASE - CREATE, NULL, changeContext);
+		}
+
+		changeContext = basicSetCreate(newCreate, changeContext);
+
+		if (changeContext != NULL) {
+			//dispatch(changeContext);
+		}
+
+	}
+
+}
+
+Update* TableImpl::getUpdate(void) {
+	return update;
+}
+
+//ChangeContext* TableImpl::basicSetUpdate(Update* newUpdate, ChangeContext* changeContext) {
+//	Update* oldUpdate = update;
+//    update = newUpdate;
+//
+//    return changeContext;
+//
+//}
+
+void TableImpl::setUpdate(Update* newUpdate) {
+	if (newUpdate != update) {
+		ChangeContext* changeContext = NULL;
+	
+		if (update != NULL) {
+			changeContext = inverseRemove(update, this, OPPOSITE_FEATURE_BASE - UPDATE, NULL, changeContext);
+		}
+
+		if (newUpdate != null) {
+			changeContext = inverseAdd(newUpdate, this, OPPOSITE_FEATURE_BASE - UPDATE, NULL, changeContext);
+		}
+
+		changeContext = basicSetUpdate(newUpdate, changeContext);
+
+		if (changeContext != NULL) {
+			//dispatch(changeContext);
+		}
+
+	}
+
+}
+
+Delete* TableImpl::getDelete(void) {
+	return delete;
+}
+
+//ChangeContext* TableImpl::basicSetDelete(Delete* newDelete, ChangeContext* changeContext) {
+//	Delete* oldDelete = delet;
+//    delet = newDelete;
+//
+//    return changeContext;
+//
+//}
+
+void TableImpl::setDelete(Delete* newDelete) {
+	if (newDelete != delet) {
+      ChangeContext* changeContext = NULL;
+
+	  if (delete != null) {
+        changeContext = inverseRemove(delet, this, OPPOSITE_FEATURE_BASE - DELETE, NULL, changeContext);
+	  }
+
+	  if (newDelete != NULL) {
+        changeContext = inverseAdd(newDelete, this, OPPOSITE_FEATURE_BASE - DELETE, NULL, changeContext);
+	  }
+
+      changeContext = basicSetDelete(newDelete, changeContext);
+
+	  if (changeContext != NULL) {
+		  dispatch(changeContext);
+	  }
+
+    }
+
+}
+
+string TableImpl::getTableName(void) {
+	return tableName;
+}
+
+void TableImpl::setTableName(string newTableName) {
+	tableName = newTableName;
+}
+
+string TableImpl::getTypeName(void) {
+	return typeName;
+}
+
+void TableImpl::setTypeName(string newTypeName) {
+	typeName = newTypeName;
+}
+
+//ChangeContext* TableImpl::inverseRemove(DASObject* otherEnd, int propertyIndex, ChangeContext* changeContext) {}
+
+DASObject* TableImpl::get(int propertyIndex, bool resolve) {
+	/*switch (propertyIndex)
+    {
+      case COLUMN:
+        return getColumn();
+      case CREATE:
+        return getCreate();
+      case UPDATE:
+        return getUpdate();
+      case DELETE:
+        return getDelete();
+      case TABLE_NAME:
+        return getTableName();
+      case TYPE_NAME:
+        return getTypeName();
+    }
+    return super.get(propertyIndex, resolve);*/
+}
+
+void TableImpl::set(int propertyIndex, DASObject* newValue) {
+	/*switch (propertyIndex)
+    {
+      case COLUMN:
+        getColumn().clear();
+        getColumn().addAll((Collection)newValue);
+        return;
+      case CREATE:
+        setCreate((Create)newValue);
+        return;
+      case UPDATE:
+        setUpdate((Update)newValue);
+        return;
+      case DELETE:
+        setDelete((Delete)newValue);
+        return;
+      case TABLE_NAME:
+        setTableName((String)newValue);
+        return;
+      case TYPE_NAME:
+        setTypeName((String)newValue);
+        return;
+    }
+    super.set(propertyIndex, newValue);*/
+}
+
+void TableImpl::unset(int propertyIndex) {
+	/*switch (propertyIndex)
+    {
+      case COLUMN:
+        getColumn().clear();
+        return;
+      case CREATE:
+        setCreate((Create)null);
+        return;
+      case UPDATE:
+        setUpdate((Update)null);
+        return;
+      case DELETE:
+        setDelete((Delete)null);
+        return;
+      case TABLE_NAME:
+        setTableName(TABLE_NAME_DEFAULT_);
+        return;
+      case TYPE_NAME:
+        setTypeName(TYPE_NAME_DEFAULT_);
+        return;
+    }
+    super.unset(propertyIndex);*/
+}
+
+bool TableImpl::isSet(int propertyIndex) {
+	/*switch (propertyIndex)
+    {
+      case COLUMN:
+        return column != null && !column.isEmpty();
+      case CREATE:
+        return create != null;
+      case UPDATE:
+        return update != null;
+      case DELETE:
+        return delete != null;
+      case TABLE_NAME:
+        return TABLE_NAME_DEFAULT_ == null ? tableName != null : !TABLE_NAME_DEFAULT_.equals(tableName);
+      case TYPE_NAME:
+        return TYPE_NAME_DEFAULT_ == null ? typeName != null : !TYPE_NAME_DEFAULT_.equals(typeName);
+    }
+    return super.isSet(propertyIndex);*/
+}
+
+//string TableImpl::toString(void) {}
+/*
+ * 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 "TableImpl.h"
+
+TableImpl::TableImpl(void) {
+	list<Column*>* column = NULL;
+	Create* create = NULL;
+	Update* update = NULL;
+	Delete* delet = NULL;
+	string tableName = TABLE_NAME_DEFAULT_;
+	string typeName = TYPE_NAME_DEFAULT_;
+
+}
+
+TableImpl::~TableImpl(void) {
+}
+
+Type* TableImpl::getType(void) {
+	return ((ConfigFactoryImpl*) ConfigFactory::INSTANCE).getTable();
+}
+
+list<Column*>* TableImpl::getColumn(void) {
+
+	if (column == NULL) {
+      //column = createPropertyList(ListKind.CONTAINMENT, Column.class, COLUMN);
+    }
+
+    return column;
+
+}
+
+Create* TableImpl::getCreate(void) {
+	return create;
+}
+
+//ChangeContext* TableImpl::basicSetCreate(Create* newCreate, ChangeContext* changeContext) {
+//	Create* oldCreate = create;
+//    create = newCreate;
+//
+//    return changeContext;
+//
+//}
+
+void TableImpl::setCreate(Create* newCreate) {
+	if (newCreate != create) {
+		ChangeContext* changeContext = NULL;
+	
+		if (create != NULL) {
+			changeContext = inverseRemove(create, this, OPPOSITE_FEATURE_BASE - CREATE, NULL, changeContext);
+		}
+
+		if (newCreate != NULL) {
+			changeContext = inverseAdd(newCreate, this, OPPOSITE_FEATURE_BASE - CREATE, NULL, changeContext);
+		}
+
+		changeContext = basicSetCreate(newCreate, changeContext);
+
+		if (changeContext != NULL) {
+			//dispatch(changeContext);
+		}
+
+	}
+
+}
+
+Update* TableImpl::getUpdate(void) {
+	return update;
+}
+
+//ChangeContext* TableImpl::basicSetUpdate(Update* newUpdate, ChangeContext* changeContext) {
+//	Update* oldUpdate = update;
+//    update = newUpdate;
+//
+//    return changeContext;
+//
+//}
+
+void TableImpl::setUpdate(Update* newUpdate) {
+	if (newUpdate != update) {
+		ChangeContext* changeContext = NULL;
+	
+		if (update != NULL) {
+			changeContext = inverseRemove(update, this, OPPOSITE_FEATURE_BASE - UPDATE, NULL, changeContext);
+		}
+
+		if (newUpdate != null) {
+			changeContext = inverseAdd(newUpdate, this, OPPOSITE_FEATURE_BASE - UPDATE, NULL, changeContext);
+		}
+
+		changeContext = basicSetUpdate(newUpdate, changeContext);
+
+		if (changeContext != NULL) {
+			//dispatch(changeContext);
+		}
+
+	}
+
+}
+
+Delete* TableImpl::getDelete(void) {
+	return delete;
+}
+
+//ChangeContext* TableImpl::basicSetDelete(Delete* newDelete, ChangeContext* changeContext) {
+//	Delete* oldDelete = delet;
+//    delet = newDelete;
+//
+//    return changeContext;
+//
+//}
+
+void TableImpl::setDelete(Delete* newDelete) {
+	if (newDelete != delet) {
+      ChangeContext* changeContext = NULL;
+
+	  if (delete != null) {
+        changeContext = inverseRemove(delet, this, OPPOSITE_FEATURE_BASE - DELETE, NULL, changeContext);
+	  }
+
+	  if (newDelete != NULL) {
+        changeContext = inverseAdd(newDelete, this, OPPOSITE_FEATURE_BASE - DELETE, NULL, changeContext);
+	  }
+
+      changeContext = basicSetDelete(newDelete, changeContext);
+
+	  if (changeContext != NULL) {
+		  dispatch(changeContext);
+	  }
+
+    }
+
+}
+
+string TableImpl::getTableName(void) {
+	return tableName;
+}
+
+void TableImpl::setTableName(string newTableName) {
+	tableName = newTableName;
+}
+
+string TableImpl::getTypeName(void) {
+	return typeName;
+}
+
+void TableImpl::setTypeName(string newTypeName) {
+	typeName = newTypeName;
+}
+
+//ChangeContext* TableImpl::inverseRemove(DASObject* otherEnd, int propertyIndex, ChangeContext* changeContext) {}
+
+DASObject* TableImpl::get(int propertyIndex, bool resolve) {
+	/*switch (propertyIndex)
+    {
+      case COLUMN:
+        return getColumn();
+      case CREATE:
+        return getCreate();
+      case UPDATE:
+        return getUpdate();
+      case DELETE:
+        return getDelete();
+      case TABLE_NAME:
+        return getTableName();
+      case TYPE_NAME:
+        return getTypeName();
+    }
+    return super.get(propertyIndex, resolve);*/
+}
+
+void TableImpl::set(int propertyIndex, DASObject* newValue) {
+	/*switch (propertyIndex)
+    {
+      case COLUMN:
+        getColumn().clear();
+        getColumn().addAll((Collection)newValue);
+        return;
+      case CREATE:
+        setCreate((Create)newValue);
+        return;
+      case UPDATE:
+        setUpdate((Update)newValue);
+        return;
+      case DELETE:
+        setDelete((Delete)newValue);
+        return;
+      case TABLE_NAME:
+        setTableName((String)newValue);
+        return;
+      case TYPE_NAME:
+        setTypeName((String)newValue);
+        return;
+    }
+    super.set(propertyIndex, newValue);*/
+}
+
+void TableImpl::unset(int propertyIndex) {
+	/*switch (propertyIndex)
+    {
+      case COLUMN:
+        getColumn().clear();
+        return;
+      case CREATE:
+        setCreate((Create)null);
+        return;
+      case UPDATE:
+        setUpdate((Update)null);
+        return;
+      case DELETE:
+        setDelete((Delete)null);
+        return;
+      case TABLE_NAME:
+        setTableName(TABLE_NAME_DEFAULT_);
+        return;
+      case TYPE_NAME:
+        setTypeName(TYPE_NAME_DEFAULT_);
+        return;
+    }
+    super.unset(propertyIndex);*/
+}
+
+bool TableImpl::isSet(int propertyIndex) {
+	/*switch (propertyIndex)
+    {
+      case COLUMN:
+        return column != null && !column.isEmpty();
+      case CREATE:
+        return create != null;
+      case UPDATE:
+        return update != null;
+      case DELETE:
+        return delete != null;
+      case TABLE_NAME:
+        return TABLE_NAME_DEFAULT_ == null ? tableName != null : !TABLE_NAME_DEFAULT_.equals(tableName);
+      case TYPE_NAME:
+        return TYPE_NAME_DEFAULT_ == null ? typeName != null : !TYPE_NAME_DEFAULT_.equals(typeName);
+    }
+    return super.isSet(propertyIndex);*/
+}
+
+//string TableImpl::toString(void) {}

Added: incubator/tuscany/cpp/das/das_java_classes/TableImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/TableImpl.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/TableImpl.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/TableImpl.h Fri May 11 14:36:45 2007
@@ -0,0 +1,160 @@
+/*
+ * 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 TABLE_IMPL_H
+#define TABLE_IMPL_H
+
+#include <string>
+
+#include "Table.h"
+#include "DASObject.h"
+
+#include "commonj/sdo/Type.h"
+
+using namespace commonj::sdo;
+using namespace std;
+
+class TableImpl : /*public DataObjectBase,*/ public Table {
+  
+	protected:
+		const static string TABLE_NAME_DEFAULT_;
+		const static string TYPE_NAME_DEFAULT_;
+
+		list<Column*>* column;
+		Create* create;
+		Update* update;
+		Delete* delet;
+		string tableName;
+		string typeName;
+
+	public:
+		const static int COLUMN = 0;
+		const static int CREATE = 1;
+		const static int UPDATE = 2;
+		const static int DELET = 3;
+		const static int TABLE_NAME = 4;
+		const static int TYPE_NAME = 5;
+		const static int SDO_PROPERTY_COUNT = 6;
+
+		TableImpl(void);
+		virtual ~TableImpl(void);
+		Type* getType(void);
+		list<Column*>* getColumn(void);
+		Create* getCreate(void);
+		//ChangeContext* basicSetCreate(Create* newCreate, ChangeContext* changeContext);
+		void setCreate(Create* newCreate);
+		Update* getUpdate(void);
+		//ChangeContext* basicSetUpdate(Update* newUpdate, ChangeContext* changeContext);
+		void setUpdate(Update* newUpdate);
+		Delete* getDelete(void);
+		//ChangeContext* basicSetDelete(Delete* newDelete, ChangeContext* changeContext);
+		void setDelete(Delete* newDelete);
+		string getTableName(void);
+		void setTableName(string newTableName);
+		string getTypeName(void);
+		void setTypeName(string newTypeName);
+		//ChangeContext* inverseRemove(DASObject* otherEnd, int propertyIndex, ChangeContext* changeContext);
+		DASObject* get(int propertyIndex, bool resolve);
+		void set(int propertyIndex, DASObject* newValue);
+		void unset(int propertyIndex);
+		bool isSet(int propertyIndex);
+		//string toString(void);
+
+};
+
+#endif //TABLE_IMPL_H
+/*
+ * 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 TABLE_IMPL_H
+#define TABLE_IMPL_H
+
+#include <string>
+
+#include "Table.h"
+#include "DASObject.h"
+
+#include "commonj/sdo/Type.h"
+
+using namespace commonj::sdo;
+using namespace std;
+
+class TableImpl : /*public DataObjectBase,*/ public Table {
+  
+	protected:
+		const static string TABLE_NAME_DEFAULT_;
+		const static string TYPE_NAME_DEFAULT_;
+
+		list<Column*>* column;
+		Create* create;
+		Update* update;
+		Delete* delet;
+		string tableName;
+		string typeName;
+
+	public:
+		const static int COLUMN = 0;
+		const static int CREATE = 1;
+		const static int UPDATE = 2;
+		const static int DELET = 3;
+		const static int TABLE_NAME = 4;
+		const static int TYPE_NAME = 5;
+		const static int SDO_PROPERTY_COUNT = 6;
+
+		TableImpl(void);
+		virtual ~TableImpl(void);
+		Type* getType(void);
+		list<Column*>* getColumn(void);
+		Create* getCreate(void);
+		//ChangeContext* basicSetCreate(Create* newCreate, ChangeContext* changeContext);
+		void setCreate(Create* newCreate);
+		Update* getUpdate(void);
+		//ChangeContext* basicSetUpdate(Update* newUpdate, ChangeContext* changeContext);
+		void setUpdate(Update* newUpdate);
+		Delete* getDelete(void);
+		//ChangeContext* basicSetDelete(Delete* newDelete, ChangeContext* changeContext);
+		void setDelete(Delete* newDelete);
+		string getTableName(void);
+		void setTableName(string newTableName);
+		string getTypeName(void);
+		void setTypeName(string newTypeName);
+		//ChangeContext* inverseRemove(DASObject* otherEnd, int propertyIndex, ChangeContext* changeContext);
+		DASObject* get(int propertyIndex, bool resolve);
+		void set(int propertyIndex, DASObject* newValue);
+		void unset(int propertyIndex);
+		bool isSet(int propertyIndex);
+		//string toString(void);
+
+};
+
+#endif //TABLE_IMPL_H

Added: incubator/tuscany/cpp/das/das_java_classes/TableWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/TableWrapper.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/TableWrapper.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/TableWrapper.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,174 @@
+/*
+ * 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 "TableWrapper.h"
+
+TableWrapper::TableWrapper(void) {
+	table = NULL;
+}
+
+TableWrapper::TableWrapper(Table* table) {
+	this->table = table;
+}
+
+TableWrapper::~TableWrapper(void) {
+}
+
+string TableWrapper::getTypeName(void) {
+	return table->getTypeName() == NULL ? table->getTableName() : table->getTypeName();
+}
+
+string TableWrapper::getTableName(void) {
+	return table->getTableName();
+}
+
+list<string>* TableWrapper::getPrimaryKeyNames(void) {
+	list<string> pkNames;
+	list<Column*>* columnList = table->getColumn();
+	list<Column*>::itrator i;
+
+	for (i = columnList.begin() ; i != columnList.end() ; i++) {
+        
+        if (i->isPrimaryKey()) {
+            pkNames.insert(i->getColumnName());
+        }
+
+    }
+
+    return pkNames;
+
+}
+
+list<string>* TableWrapper::getPrimaryKeyProperties(void) {
+	list<string> keyProperties;
+	list<Column*>* columnList = table->getColumn();
+	list<Column*>::iterator i;
+
+	for (i = columnList.begin() ; i != columnList.end() ; i++) {
+        
+        if (i->isPrimaryKey()) {
+            keyProperties.insert(getColumnPropertyName(i));
+        }
+
+    }
+
+    return keyProperties;
+
+}
+
+string TableWrapper::getColumnPropertyName(Column* c) {
+
+	if (c->getPropertyName() != NULL) {
+        return c->getPropertyName();
+    }
+
+    return c->getColumnName();
+
+}
+
+bool TableWrapper::isGeneratedColumnProperty(string name) {
+	Column* c = getColumnByPropertyName(name);
+
+    return c == NULL ? false : c->isGenerated();
+
+}
+
+string TableWrapper::getConverter(string propertyName) {
+	Column* c = getColumnByPropertyName(propertyName);
+
+    return (c == NULL) ? NULL : c->getConverterClassName();
+
+}
+
+Column* TableWrapper::getColumnByPropertyName(string propertyName) {
+	list<Column*>* columnList = table->getColumn();
+	list<Column*>::iterator i;
+	for (i = columnList->begin() ; i != columnList->end() i++) {
+        string propert = i->getPropertyName();
+
+        if (propert == NULL) {
+            propert = i->getColumnName();
+        }
+
+        if (strcmp(propertyName, propert) == 0) {
+            return i;
+        }
+
+    }
+
+    return NULL;
+
+}
+
+Column* TableWrapper::getCollisionColumn(void) {
+	list<Column*>* columnList = table->getColumn();
+	list<Column*>::iterator i;
+	for (i = columnList->begin() ; i != columnList->end() i++) {
+
+        if (i->isCollision()) {
+            return i;
+        }
+
+    }
+
+    return NULL;
+
+}
+
+string TableWrapper::getCollisionColumnPropertyName(void) {
+	Column* c = getCollisionColumn();
+
+    if (c->getPropertyName() != NULL) {
+        return c->getPropertyName();
+    } 
+
+    return c->getColumnName();
+
+}
+
+string TableWrapper::getManagedColumnPropertyName(void) {
+	list<Column*>* columnList = table->getColumn();
+	list<Column*>::iterator i;
+
+	for (i = columnList->begin() ; i != columnList->end() i++) {
+
+        if (i->isCollision() && i->isManaged()) {
+            return i->getPropertyName() == NULL ? i->getColumnName() : i->getPropertyName();
+        }
+
+    }
+
+    return NULL;
+
+}
+
+Column* TableWrapper::getManagedColumn(void) {
+	list<Column*>* columnList = table->getColumn();
+	list<Column*>::iterator i;
+
+	for (i = columnList->begin() ; i != columnList->end() i++) {
+
+        if (i->isCollision() && i->isManaged()) {
+            return i;
+        }
+
+    }
+
+    return NULL;
+
+}

Added: incubator/tuscany/cpp/das/das_java_classes/TableWrapper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/TableWrapper.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/TableWrapper.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/TableWrapper.h Fri May 11 14:36:45 2007
@@ -0,0 +1,46 @@
+/*
+ * 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 TABLE_WRAPPER_H
+#define TABLE_WRAPPER_H
+
+class TableWrapper {
+
+	private:
+		Table* table;
+
+	public:
+		TableWrapper(void);
+		TableWrapper(Table* table);
+		~TableWrapper(void);
+		string getTypeName(void);
+		string getTableName(void);
+		list<string>* getPrimaryKeyNames(void);
+		list<string>* getPrimaryKeyProperties(void);
+		string getColumnPropertyName(Column* c);
+		bool isGeneratedColumnProperty(string name);
+		string getConverter(string propertyName);
+		Column* getColumnByPropertyName(string propertyName);
+		Column* getCollisionColumn(void);
+		string getCollisionColumnPropertyName(void);
+		string getManagedColumnPropertyName(void);
+		Column* getManagedColumn(void);
+
+};
+
+#endif //TABLE_WRAPPER_H
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/Update.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/Update.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/Update.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/Update.h Fri May 11 14:36:45 2007
@@ -0,0 +1,74 @@
+/*
+ * 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 UPDATE_H
+#define UPDATE_H
+
+virtual class Update {
+  /**
+   * Returns the value of the '<em><b>Sql</b></em>' attribute.
+   * <!-- begin-user-doc -->
+   * <p>
+   * If the meaning of the '<em>Sql</em>' attribute isn't clear,
+   * there really should be more of a description here...
+   * </p>
+   * <!-- end-user-doc -->
+   * @return the value of the '<em>Sql</em>' attribute.
+   * @see #setSql(String)
+   * @generated
+   */
+  string getSql(void);
+
+  /**
+   * Sets the value of the '{@link org.apache.tuscany.das.rdb.config.Update#getSql <em>Sql</em>}' attribute.
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @param value the new value of the '<em>Sql</em>' attribute.
+   * @see #getSql()
+   * @generated
+   */
+  void setSql(string value);
+
+  /**
+   * Returns the value of the '<em><b>Parameters</b></em>' attribute.
+   * <!-- begin-user-doc -->
+   * <p>
+   * If the meaning of the '<em>Parameters</em>' attribute isn't clear,
+   * there really should be more of a description here...
+   * </p>
+   * <!-- end-user-doc -->
+   * @return the value of the '<em>Parameters</em>' attribute.
+   * @see #setParameters(String)
+   * @generated
+   */
+  string getParameters(void);
+
+  /**
+   * Sets the value of the '{@link org.apache.tuscany.das.rdb.config.Update#getParameters <em>Parameters</em>}' attribute.
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @param value the new value of the '<em>Parameters</em>' attribute.
+   * @see #getParameters()
+   * @generated
+   */
+  void setParameters(string value);
+
+}; // Update
+
+
+#endif //UPDATE_H
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateCommandImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateCommandImpl.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateCommandImpl.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateCommandImpl.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+#include "UpdateCommandImpl.h"
+
+UpdateCommandImpl::UpdateCommandImpl(string sqlString) {
+	super(sqlString);
+}
+
+UpdateCommandImpl::UpdateCommandImpl(Update* update) {
+	super(update->getSql());
+	addParameters(update->getParameters());
+
+}
+
+UpdateCommandImpl::~UpdateCommandImpl(void) {
+}

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateCommandImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateCommandImpl.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateCommandImpl.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateCommandImpl.h Fri May 11 14:36:45 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 UPDATE_COMMAND_IMPL_H
+#define UPDATE_COMMAND_IMPL_H
+
+#include "WriteCommandImpl.h"
+#include "Update.h"
+
+class UpdateCommandImpl : public WriteCommandImpl {
+
+	public:
+		UpdateCommandImpl(string sqlString);
+		UpdateCommandImpl(Update* update);
+		~UpdateCommandImpl(void);
+
+};
+
+#endif //UPDATE_COMMAND_IMPL_H
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateGenerator.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateGenerator.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateGenerator.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateGenerator.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,229 @@
+/*
+ * 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 "UpdateGenerator.h"
+
+UpdateGenerator::UpdateGenerator(void) {}
+
+UpdateGenerator::~UpdateGenerator(void) {
+}
+
+UpdateCommandImpl& UpdateGenerator::getUpdateCommand(MappingWrapper& mapping, DataObject& changedObject, Table& table); {
+	list<ParameterImpl*> parameters;
+    Type& type = changedObject.getType();
+    TableWrapper tableWrapper(table);
+    string statement = "update ";
+    statement += table.getTableName();
+    statement += " set ";
+
+    ChangeSummary& summary = changedObject.getDataGraph().getChangeSummary();
+    map<Property&, Property*>& changedFields = getChangedFields(mapping, summary, changedObject, tableWrapper);
+	map<Property&, Property*>::iterator it;
+  
+    int idx = 1;
+	for (it = changedFields.begin() ; it != changedFields.end() ; it++) {
+        
+        Column& c = tableWrapper.getColumnByPropertyName(it->getName());          
+        
+        if ((c == NULL) || !c.isCollision() || !c.isPrimaryKey()) { 
+            string columnName = (c == NULL) ? it->getName() : c.getColumnName();
+            appendFieldSet(statement, idx > 1, columnName);
+            parameters.insert(createParameter(tableWrapper, *it, idx++));
+
+        } 
+
+    }
+    
+    Column& c = tableWrapper.getManagedColumn();
+    if (c != NULL) {
+        appendFieldSet(statement, idx > 1, c.getColumnName());
+        string propertyName = (c.getPropertyName()) == NULL ? c.getColumnName() : c.getPropertyName();
+        parameters.insert(createManagedParameter(tableWrapper, 
+                changedObject.getProperty(propertyName), idx++));
+
+    }
+    
+    statement += " where ";
+
+	list<string>& pkNames = tableWrapper.getPrimaryKeyNames();
+	list<string>::iterator pkColumnNames = pkNammes.iterator();
+
+	list<string>& pkNamesProperties = tableWrapper.getPrimaryKeyProperties();
+	list<string>::iterator pkPropertyNames = pkNamesProperties.iterator();
+    
+    while (pkNames.end() != pkColumnNames && pkNamesProperties.end() != pkPropertyNames) {
+        string columnName = *pkColumnNames;
+		pkColumnNames++;
+
+        string propertyName = *pkPropertyNames;
+		pkPropertyNames++;
+
+        statement += columnName;
+        statement += " = ?";
+
+        if (pkNames.end() != pkColumnNames && pkNamesProperties.end() != pkPropertyNames) {
+            statement += " and ";
+        }
+
+        parameters.insert(createParameter(tableWrapper, type.getProperty(propertyName), idx++));
+
+    }
+
+    if (tableWrapper.getCollisionColumn() == NULL) {
+
+		for (it = changedFields.begin() ; it != changesFields.end() ; it++;) {
+            statement += " and ";
+            Property& changedProperty = *it;
+			
+            Column& column = tableWrapper.getColumnByPropertyName(changedProperty.getName()); 
+            statement += (column == NULL) ? changedProperty.getName() : column.getColumnName();
+                             
+            DASObject value;
+            Setting& setting = summary.getOldValue(changedObject, changedProperty);
+
+            // Setting is null if this is a relationship change
+            if (setting == NULL) {
+                value = changedObject.get(changedProperty);
+            } else {
+                value = setting.getValue();
+            }
+            
+            if (value == NULL) {                   
+                statement += " is null";                    
+            } else {
+                ParameterImpl& param = createCollisionParameter(tableWrapper, changedProperty, idx++);
+                statement += " = ?";
+                param.setValue(value);
+                parameters.insert(param);
+
+            }
+            
+           
+        }
+       
+    } else {
+        statement += " and ";
+        statement += tableWrapper.getCollisionColumn().getColumnName();
+        statement += " = ?";
+        parameters.insert(createParameter(tableWrapper, 
+                type.getProperty(tableWrapper.getCollisionColumnPropertyName()), idx++));                       
+
+    }                  
+
+    UpdateCommandImpl* updateCommand = new OptimisticWriteCommandImpl(statement.c_chr());
+    
+	list<ParameterImpl*>::iterator params;
+	for (params = parameters.begin() ; params != parameters.end() ; params++) {
+        updateCommand.addParameter(*params);
+    }
+       
+    /*if (this.logger.isDebugEnabled()) {
+        this.logger.debug(statement.toString());
+    }*/
+
+    return updateCommand;
+
+}
+
+void UpdateGenerator::appendFieldSet(string statement, bool appendComma, string columnName) {
+	if (appendComma) {
+        statement += ", ";
+    }
+
+    statement += columnName;
+    statement += " = ?";
+
+}
+
+map<Property&, Property*> UpdateGenerator::getChangedFields(MappingWrapper& config, ChangeSummary& summary, DataObject& obj, TableWrapper& tw) {
+	map<Property&, Property*> changes;
+	list<ChangeSummary::Setting*>& oldValuesList = summary.getOldValues(obj);
+	list<ChangeSummary::Setting*>::iterator i;
+
+	for (i = oldValuesList.begin() ; i != oldValuesList.end() ; i++) {
+        
+        if (i->getProperty().getType().isDataType()) {
+
+		   Property& p = i->getProperty();
+		   map<Property&, Property*>::iterator changesIterator = changes.find(p);
+		   
+		   if (changesIterator != changes.end()) {
+			   //throw new RuntimeException("Foreign key properties should not be set when the corresponding relationship has changed");
+		   }
+
+		   changes.insert(make_pair(p, p));
+
+        } else {
+			Property& ref = i->getProperty();
+
+            if (!ref.isMany()) {
+
+                RelationshipWrapper r(config.getRelationshipByReference(ref));
+				list<string>& fkList = r.getForeignKeys();
+				list<string>::iterator fkIterator;
+                
+				for (fkIterator = fkList.begin() ; fkIterator != fkList.end() ; fkIterator++) {
+                    string keyProperty = config.getColumnPropertyName(tw.getTableName(), *fkIterator);
+                    Property& keyProp = obj.getType().getProperty(keyProperty);
+
+					if ( keyProp == NULL ) {
+                        //throw new RuntimeException("Invalid foreign key column: " + *fkIterator);
+					}
+
+					map<Property&, Property*>::iterator changesIterator = changes.find(keyProp);
+		   
+					if (changesIterator != changes.end()) {
+                        //throw new RuntimeException("Foreign key properties should not be set when the corresponding relationship has changed");
+                    }
+
+                }
+
+            }
+
+        }
+
+    }
+
+    return changes;
+
+}
+
+ParameterImpl& UpdateGenerator::fillParameter(ParameterImpl& param, TableWrapper& table, Property& propert, int idx) {
+	param.setName(propert.getName());
+    param.setType(propert.getType());
+    param.setConverter(getConverter(table.getConverter(propert.getName())));
+
+    if (idx != -1) {
+        param.setIndex(idx);
+    }
+
+    return param;
+
+}
+
+ParameterImpl& UpdateGenerator::createCollisionParameter(TableWrapper& tableWrapper, Property& propert, int i) {
+	return fillParameter(param, tableWrapper, *(new CollisionParameter()), i);
+}
+
+ParameterImpl& UpdateGenerator::createManagedParameter(TableWrapper& table, Property& propert, int idx) {
+	return fillParameter(*(new ManagedParameterImpl()), table, propert, idx);
+}
+
+ParameterImpl& UpdateGenerator::createParameter(TableWrapper& table, Property propert, int idx) {
+	 return fillParameter(*(new ParameterImpl()), table, propert, idx);
+}

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateGenerator.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateGenerator.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateGenerator.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateGenerator.h Fri May 11 14:36:45 2007
@@ -0,0 +1,42 @@
+/*
+ * 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 UPDATE_GENERATOR_H
+#define UPDATE_GENERATOR_H
+
+class UpdateGenerator : public BaseGenerator {
+
+	private:
+		UpdateGenerator(void);
+		void appendFieldSet(string statement, bool appendComma, string columnName);
+		map<Property*, Property*>* getChangedFields(MappingWrapper* config, ChangeSummary* summary, DataObject* obj, TableWrapper* tw);
+		ParameterImpl* fillParameter(ParameterImpl* param, TableWrapper* table, Property* propert, int idx);
+		ParameterImpl* createCollisionParameter(TableWrapper* tableWrapper, Property* propert, int i);
+		ParameterImpl* createManagedParameter(TableWrapper* table, Property* propert, int idx);
+		ParameterImpl* createParameter(TableWrapper* table, Property* propert, int idx);
+
+
+	public:
+		static UpdateGenerator INSTANCE;
+
+		~UpdateGenerator(void);
+		UpdateCommandImpl* getUpdateCommand(MappingWrapper* mapping, DataObject* changedObject, Table* table);
+
+};
+
+#endif //UPDATE_GENERATOR_H
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateImpl.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateImpl.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateImpl.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,196 @@
+/*
+ * 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 "TableImpl.h"
+
+UpdateImpl::UpdateImpl(void) {
+	sql = SQL_DEFAULT_;
+	parameters = PARAMETERS_DEFAULT_;
+
+}
+
+UpdateImpl::~UpdateImpl(void) {
+}
+
+Type* UpdateImpl::getType(void) {
+	return ((ConfigFactoryImpl*) ConfigFactory::INSTANCE).getUpdate();
+}
+
+string UpdateImpl::getSql(void) {
+	return sql;
+}
+
+void UpdateImpl::setSql(string newSql) {
+	sql = newSql;
+}
+
+string UpdateImpl::getParameters(void) {
+	return parameters;
+}
+
+void UpdateImpl::setParameters(string newParameters) {
+	parameters = newParameters;
+}
+
+DASObject* UpdateImpl::get(int propertyIndex, bool resolve) {
+	/*switch (propertyIndex)
+    {
+      case SQL:
+        return getSql();
+      case PARAMETERS:
+        return getParameters();
+    }
+    return super.get(propertyIndex, resolve);*/
+}
+
+void UpdateImpl::set(int propertyIndex, DASObject* newValue) {
+	/*switch (propertyIndex)
+    {
+      case SQL:
+        setSql((String)newValue);
+        return;
+      case PARAMETERS:
+        setParameters((String)newValue);
+        return;
+    }
+    super.set(propertyIndex, newValue);*/
+}
+
+void UpdateImpl::unset(int propertyIndex) {
+	/*switch (propertyIndex)
+    {
+      case SQL:
+        setSql(SQL_DEFAULT_);
+        return;
+      case PARAMETERS:
+        setParameters(PARAMETERS_DEFAULT_);
+        return;
+    }
+    super.unset(propertyIndex);*/
+}
+
+bool UpdateImpl::isSet(int propertyIndex) {
+	/*switch (propertyIndex)
+    {
+      case SQL:
+        return SQL_DEFAULT_ == null ? sql != null : !SQL_DEFAULT_.equals(sql);
+      case PARAMETERS:
+        return PARAMETERS_DEFAULT_ == null ? parameters != null : !PARAMETERS_DEFAULT_.equals(parameters);
+    }
+    return super.isSet(propertyIndex);*/
+}
+
+//string UpdateImpl::toString(void) {}
+/*
+ * 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 "TableImpl.h"
+
+UpdateImpl::UpdateImpl(void) {
+	sql = SQL_DEFAULT_;
+	parameters = PARAMETERS_DEFAULT_;
+
+}
+
+UpdateImpl::~UpdateImpl(void) {
+}
+
+Type* UpdateImpl::getType(void) {
+	return ((ConfigFactoryImpl*) ConfigFactory::INSTANCE).getUpdate();
+}
+
+string UpdateImpl::getSql(void) {
+	return sql;
+}
+
+void UpdateImpl::setSql(string newSql) {
+	sql = newSql;
+}
+
+string UpdateImpl::getParameters(void) {
+	return parameters;
+}
+
+void UpdateImpl::setParameters(string newParameters) {
+	parameters = newParameters;
+}
+
+DASObject* UpdateImpl::get(int propertyIndex, bool resolve) {
+	/*switch (propertyIndex)
+    {
+      case SQL:
+        return getSql();
+      case PARAMETERS:
+        return getParameters();
+    }
+    return super.get(propertyIndex, resolve);*/
+}
+
+void UpdateImpl::set(int propertyIndex, DASObject* newValue) {
+	/*switch (propertyIndex)
+    {
+      case SQL:
+        setSql((String)newValue);
+        return;
+      case PARAMETERS:
+        setParameters((String)newValue);
+        return;
+    }
+    super.set(propertyIndex, newValue);*/
+}
+
+void UpdateImpl::unset(int propertyIndex) {
+	/*switch (propertyIndex)
+    {
+      case SQL:
+        setSql(SQL_DEFAULT_);
+        return;
+      case PARAMETERS:
+        setParameters(PARAMETERS_DEFAULT_);
+        return;
+    }
+    super.unset(propertyIndex);*/
+}
+
+bool UpdateImpl::isSet(int propertyIndex) {
+	/*switch (propertyIndex)
+    {
+      case SQL:
+        return SQL_DEFAULT_ == null ? sql != null : !SQL_DEFAULT_.equals(sql);
+      case PARAMETERS:
+        return PARAMETERS_DEFAULT_ == null ? parameters != null : !PARAMETERS_DEFAULT_.equals(parameters);
+    }
+    return super.isSet(propertyIndex);*/
+}
+
+//string UpdateImpl::toString(void) {}

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateImpl.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateImpl.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateImpl.h Fri May 11 14:36:45 2007
@@ -0,0 +1,122 @@
+/*
+ * 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 UPDATE_IMPL_H
+#define UPDATE_IMPL_H
+
+#include <string>
+
+#include "Update.h"
+#include "DASObject.h"
+
+#include "commonj/sdo/Type.h"
+
+using namespace commonj::sdo;
+using namespace std;
+
+class UpdateImpl : /*public DataObjectBase,*/ public Update {
+
+	protected:
+		const static string SQL_DEFAULT_;
+		const static string PARAMETERS_DEFAULT_;
+
+		string sql;
+		string parameters;
+
+	public:
+		const static int SQL = 0;
+		const static int PARAMETERS = 1;
+		const static int SDO_PROPERTY_COUNT = 2;
+
+		UpdateImpl(void);
+		virtual ~UpdateImpl(void);
+		Type* getType(void);
+		string getSql(void);
+		void setSql(string newSql);
+		string getParameters(void);
+		void setParameters(string newParameters);
+		DASObject* get(int propertyIndex, bool resolve);
+		void set(int propertyIndex, DASObject* newValue);
+		void unset(int propertyIndex);
+		bool isSet(int propertyIndex);
+		//string toString(void);
+
+};
+
+#endif //TABLE_IMPL_H
+/*
+ * 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 UPDATE_IMPL_H
+#define UPDATE_IMPL_H
+
+#include <string>
+
+#include "Update.h"
+#include "DASObject.h"
+
+#include "commonj/sdo/Type.h"
+
+using namespace commonj::sdo;
+using namespace std;
+
+class UpdateImpl : /*public DataObjectBase,*/ public Update {
+
+	protected:
+		const static string SQL_DEFAULT_;
+		const static string PARAMETERS_DEFAULT_;
+
+		string sql;
+		string parameters;
+
+	public:
+		const static int SQL = 0;
+		const static int PARAMETERS = 1;
+		const static int SDO_PROPERTY_COUNT = 2;
+
+		UpdateImpl(void);
+		virtual ~UpdateImpl(void);
+		Type* getType(void);
+		string getSql(void);
+		void setSql(string newSql);
+		string getParameters(void);
+		void setParameters(string newParameters);
+		DASObject* get(int propertyIndex, bool resolve);
+		void set(int propertyIndex, DASObject* newValue);
+		void unset(int propertyIndex);
+		bool isSet(int propertyIndex);
+		//string toString(void);
+
+};
+
+#endif //TABLE_IMPL_H

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateList.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateList.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateList.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateList.cpp Fri May 11 14:36:45 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 "UpdateList.h"
+
+UpdateList::UpdateList(void) {
+	super();
+}
+
+UpdateList::~UpdateList(void) {
+}
+
+void UpdateList::add(ChangeOperation* c) {
+	updates.insert(c);
+}
+
+list<ChangeOperation*>* UpdateList::getSortedList(void) {
+	return &updates;
+}
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateList.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateList.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateList.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateList.h Fri May 11 14:36:45 2007
@@ -0,0 +1,41 @@
+/*
+ * 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 UPDATE_LIST_H
+#define UPDATE_LIST_H
+
+#include <list>
+
+#include "ChangeOperation.h"
+
+using namespace std;
+
+class UpdateList {
+
+	private:
+		list<ChangeOperation*> updates;
+	
+	public:
+		UpdateList(void);
+		~UpdateList(void);
+		void add(ChangeOperation* c);
+		list<ChangeOperation*>* getSortedList(void);
+
+};
+
+#endif //UPDATE_LIST_H
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateOperation.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateOperation.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateOperation.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateOperation.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,28 @@
+/*
+ * 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 "UpdateOperation.h"
+
+UpdateOperation::UpdateOperation(UpdateCommandImpl* command, DataObject* changedObject, string id) {
+	super(command, changedObject);
+    propagatedID = id;
+
+}
+
+UpdateOperation::~UpdateOperation(void) {
+}
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/UpdateOperation.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/UpdateOperation.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/UpdateOperation.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/UpdateOperation.h Fri May 11 14:36:45 2007
@@ -0,0 +1,37 @@
+/*
+ * 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 UPDATE_OPERATION_H
+#define UPDATE_OPERATION_H
+
+#include "ChangeOperation.h"
+#include "UpdateCommandImpl.h"
+
+#include "commonj/sdo/DataFactory.h"
+
+using namespace commonj::sdo;
+
+class UpdateOperation : public ChangeOperation {
+
+	public:
+		UpdateOperation(UpdateCommandImpl* command, DataObject* changedObject, string id);
+		~UpdateOperation(void);
+
+};
+
+#endif //UPDATE_OPERATION_H
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/WriteCommandImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/WriteCommandImpl.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/WriteCommandImpl.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/WriteCommandImpl.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,110 @@
+/*
+ * 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 "WriteCommandImpl.h"
+
+WriteCommandImpl::WriteCommandImpl(string sqlString) {
+	super(sqlString);
+}
+
+WriteCommandImpl::~WriteCommandImpl(void) {
+}
+
+void WriteCommandImpl::execute(void) {
+	int success = 0;
+
+    //try {
+        statement->executeUpdate(parameters);
+        success = 1;
+
+    //} catch (SQLException e) {
+      //  throw new RuntimeException(e);
+    //} finally {
+        if (success) {
+            statement->getConnection()->cleanUp();
+        } else {
+            statement->getConnection()->errorCleanUp();
+        }
+
+    }
+
+}
+
+DataObject* WriteCommandImpl::executeQuery(void) {
+//	throw new UnsupportedOperationException();
+}
+
+Config* WriteCommandImpl::getMappingModel(void) {
+	return configWrapper.getConfig();
+}
+
+//string WriteCommandImpl::toString(void) {}
+
+int WriteCommandImpl::getGeneratedKey(void) {
+	//throw new RuntimeException("No generated key is available");
+}
+
+void WriteCommandImpl::addParameters(string parameters) {
+	int i, j, sp, tb, nl, cr, ff, next, pos = 0, idx = 1;
+	int size = strlen(parameters);
+	string strParams = (string) parameters;
+
+	do {
+		next = min(strParams.find(' ', pos), strParams.find('\t', pos));
+		next = min(next, strParams.find('\n', pos));
+		next = min(next, strParams.find('\r', pos));
+		next = min(next, strParams.find('\f', pos));
+
+		if (next == pos) {
+			pos++;
+		} else {
+			
+			string param;
+
+			if (next == string::npos) {
+				param = strParams.substr(pos, size);
+			} else {
+				param = strParams.substr(pos, (next - 1) - pos);
+			}
+
+			ParameterImpl p;
+			p.setName((string) param);
+			p.setIndex(idx);
+			addParameter(&p);
+
+			idx++;
+
+			pos = next + 1;
+
+		}
+
+		
+
+	} while (next != string::npos && pos < size);
+
+}
+
+int WriteCommandImpl::min(int value1, int value2) {
+
+	if (value2 > value1) {
+		return value2;
+	}
+
+	return value1;
+
+}
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/WriteCommandImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/WriteCommandImpl.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/WriteCommandImpl.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/WriteCommandImpl.h Fri May 11 14:36:45 2007
@@ -0,0 +1,49 @@
+/*
+ * 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 WRITE_COMMAND_IMPL_H
+#define WRITE_COMMAND_IMPL_H
+
+#include <string>
+
+#include "CommandImpl.h"
+#include "Config.h"
+#include "ParameterImpl.h"
+
+#include "commonj/sdo/DataFactory.h"
+
+using namespace commonj::sdo;
+
+class WriteCommandImpl : public CommandImpl {
+
+	private:
+		int minValue(int value1, int value2);
+
+	public:
+		WriteCommandImpl(string sqlString);
+		~WriteCommandImpl(void);
+		void execute(void);
+		DataObject* executeQuery(void);
+		Config* getMappingModel(void);
+		//string toString(void);
+		int getGeneratedKey(void);
+		void addParameters(string parameters);
+
+};
+
+#endif //WRITE_COMMAND_IMPL_H
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/config/Command.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/config/Command.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/config/Command.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/config/Command.h Fri May 11 14:36:45 2007
@@ -0,0 +1,50 @@
+/*
+ * 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 CONFIG_COMMAND_H
+#define CONFIG_COMMAND_H
+
+#include <string>
+#include <list>
+#include <vector>
+
+#include "../Parameter.h"
+#include "../ResultDescriptor.h"
+
+using namespace std;
+
+namespace config {
+
+	virtual class Command {
+
+		public:
+			list<Parameter*>* getParameter(void);
+			vector<ResultDescriptor*>* getResultDescriptor(void);
+			string getName();
+			void setName(string value);
+			string getSQL();
+			void setSQL(string value);
+			string getKind();
+			void setKind(string value);
+
+	};
+
+};
+
+
+#endif //CONFIG_COMMAND_H
\ No newline at end of file

Added: incubator/tuscany/cpp/das/das_java_classes/config/CommandImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/config/CommandImpl.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/config/CommandImpl.cpp (added)
+++ incubator/tuscany/cpp/das/das_java_classes/config/CommandImpl.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,71 @@
+/*
+ * 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 "CommandImpl.h"
+
+CommandImpl::CommandImpl(string sqlString) {
+	statement = new Statement(sqlString);
+
+    //try {
+        /*URL url = getClass().getResource("/xml/sdoJava.xsd");
+        if (url == null) {
+            //throw new RuntimeException("Could not find resource: xml/sdoJava.xsd");
+        }
+
+        InputStream inputStream = url.openStream();
+        XSDHelper.INSTANCE.define(inputStream, url.toString());
+        inputStream.close();*/
+    //} catch (IOException ex) {
+      //  throw new RuntimeException(ex);
+    //}
+
+}
+
+CommandImpl::~CommandImpl() {
+}
+
+void CommandImpl::setParameter(int index, DASObject* value) {
+	parameters.setParameter(index, value);
+}
+
+void CommandImpl::addParameter(ParameterImpl* param) {
+	parameters.add(param);
+}
+
+vector<ParameterImpl*>* CommandImpl::getParameters(void) {
+	return parameters.parameterList();
+}
+
+DASObject* CommandImpl::getParameter(int index) {
+	return parameters.parameterWithIndex(index)->getValue();
+}
+
+void CommandImpl::setConnection(ConnectionImpl* connection) {
+	statement->setConnection(connection);
+}
+
+int CommandImpl::getGeneratedKey(void) {
+	//throw new RuntimeException("This method is only valid for insert commands");
+}
+
+void CommandImpl::close(void) {
+	statement->close();
+}
+ConnectionImpl* CommandImpl::getConnection(void) {
+	return statement->getConnection();
+}

Added: incubator/tuscany/cpp/das/das_java_classes/config/CommandImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/das_java_classes/config/CommandImpl.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/das_java_classes/config/CommandImpl.h (added)
+++ incubator/tuscany/cpp/das/das_java_classes/config/CommandImpl.h Fri May 11 14:36:45 2007
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+#ifndef CONFIG_COMMAND_IMPL_H
+#define CONFIG_COMMAND_IMPL_H
+
+#include <string>
+#include <list>
+
+#include "../Parameter.h"
+#include "../ResultDescriptor.h"
+#include "../DASObject.h"
+#include "Command.h"
+
+#include "commonj/sdo/Type.h"
+
+using namespace commonj::sdo;
+using namespace std;
+
+namespace config {
+
+	class CommandImpl : public Command {
+
+	protected:
+		const static string NAME_DEFAULT_;
+		const static string SQL_DEFAULT_;
+		const static string KIND_DEFAULT_;
+
+		list<Parameter*>* parameter;
+		list<ResultDescriptor*>* resultDescriptor;
+		string name;
+		string sql;
+		string kind;
+
+		
+
+		public:
+
+			const static int PARAMETER = 0;
+			const static int RESULT_DESCRIPTOR = 1;
+			const static int NAME = 2;
+			const static int SQL = 3;
+			const static int KIND = 4;
+			const static int SDO_PROPERTY_COUNT = 5;
+
+			CommandImpl(void);
+			virtual ~CommandImpl(void);
+			Type* getType(void);
+			list<Parameter*>* getParameter(void);
+			list<ResultDescriptor*>* getResultDescriptor(void);
+			string getName(void);
+			void setName(string newName);
+			string getSQL(void);
+			void setSQL(string newSQL);
+			string getKind(void);
+			void setKind(string newKind);
+			//ChangeContext* inverseRemove(DASObject* otherEnd, int propertyIndex, ChangeContext* changeContext);
+			DASObject* get(int propertyIndex, bool resolve);
+			void set(int propertyIndex, DASObject* newValue);
+			void unset(int propertyIndex);
+			bool isSet(int propertyIndex);
+			string toString(void);
+
+	};
+
+};
+
+
+#endif //CONFIG_COMMAND_IMPL_H
\ No newline at end of file

Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/Command.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/Command.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/Command.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/Command.h Fri May 11 14:36:45 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+#ifndef COMMAND_H
+#define COMMAND_H
+
+#include "commonj/sdo/DataObject.h"
+
+#include <string>
+
+namespace apache {
+	namespace das {
+
+/**
+ * A Command is used to execute a read or write to a database
+ */
+class Command {
+
+	public:
+		Command(void);
+		virtual ~Command(void);
+
+		/**
+		 * Performs the function defined by the command
+		 */
+		//void execute(void);
+
+		/**
+		 * Performs the function defined by the command and return the results in the root DataObject
+		 * 
+		 * @return the root DataObject
+		 */
+		virtual commonj::sdo::DataObjectPtr executeQuery(void);
+		
+};
+
+	};
+};
+
+#endif //COMMAND_H

Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/DAS.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/DAS.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/DAS.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/DAS.h Fri May 11 14:36:45 2007
@@ -0,0 +1,49 @@
+/*
+ * 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 D_A_S_H
+#define D_A_S_H
+
+#include "apache/das/DASFactory.h"
+#include "apache/das/Command.h"
+
+#include "commonj/sdo/DataObject.h"
+
+namespace apache {
+	namespace das {
+
+class DASFactory;
+
+class DAS {
+
+	private:
+		static DASFactory* FACTORY;
+
+	public:
+		static DASFactory* getFACTORY(void);
+
+		DAS(void);
+		virtual ~DAS(void);
+		
+};
+
+	};
+};
+
+#endif //D_A_S_H

Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/DASFactory.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/DASFactory.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/DASFactory.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/DASFactory.h Fri May 11 14:36:45 2007
@@ -0,0 +1,46 @@
+/*
+ * 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 D_A_S_FACTORY_H
+#define D_A_S_FACTORY_H
+
+#include <windows.h>
+#include <sql.h>
+#include <string>
+
+#include "apache/das/DAS.h"
+#include "apache/das/rdb/Connection.h"
+
+namespace apache {
+	namespace das {
+
+class DAS;
+
+class DASFactory {
+
+	public:
+		DASFactory(void);
+		virtual ~DASFactory(void);
+		virtual DAS* createDAS(rdb::Connection& connection);
+
+};
+
+	};
+};
+
+#endif //D_A_S_FACTORY_H

Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/NullPointerException.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/NullPointerException.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/NullPointerException.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/NullPointerException.h Fri May 11 14:36:45 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+/* $Rev: 452786 $ $Date: 2006-10-04 08:57:36 +0100 (Wed, 04 Oct 2006) $ */
+
+#ifndef NULL_POINTER_EXCEPTION_H
+#define NULL_POINTER_EXCEPTION_H
+
+#include <stdexcept>
+
+namespace apache {
+	namespace das {
+
+class NullPointerException : public std::exception {
+
+	public:
+		NullPointerException(void);
+		virtual ~NullPointerException(void);
+
+};
+
+	};
+};
+
+#endif //NULL_POINTER_EXCEPTION_H



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