diff options
Diffstat (limited to 'java/das/rdb/src/main')
74 files changed, 14494 insertions, 0 deletions
diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Command.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Command.java new file mode 100644 index 0000000000..1e641b71e7 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Command.java @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +import org.apache.tuscany.das.rdb.config.ResultDescriptor; + +import commonj.sdo.DataObject; + +/** + * A Command is used to execute a read or write to a database + */ +public interface Command { + + /** + * Performs the function defined by the command + */ + void execute(); + + /** + * Performs the function defined by the command and return the results in the root DataObject + * + * @return the root DataObject + */ + DataObject executeQuery(); + + /** + * Sets the value of the associated Parameter + * + * @param index + * the index of the Parameter + * @param value + * the value for the Parameter + */ + void setParameter(int index, Object value); + + /** + * Returns the value of the associated Parameter + * + * @param index + * the index of the Parameter + * @return the value of the Parameter + */ + Object getParameter(int index); + + /** + * + * @param name Name of parameter - should match exact name of database table column + * as appearing in Command + * @param value + * the value of the parameter + */ + void setParameter(String name, Object value); + + /** + * + * @param name + * the name of the parameter - should match exact name of database table column + * @return the value of the parameter + */ + Object getParameter(String name); + + /** + * Returns the value of the database-generated key. This method is specific + * to an "insert" command and will be valid only after the command has + * been executed. + * + * @return the generated key + */ + int getGeneratedKey(); + + /** + * Allow set of ResultDescriptor when command is created on-the-fly + * @param resultDescriptorList + */ + void setResultDescriptors(List resultDescriptorList); + + List getResultDescriptors(); + + /** + * Add/replace based on columnIndex (>=0)embedded in resultDescriptor else add at end + * @param resultDescriptor + */ + void addResultDescriptor(ResultDescriptor resultDescriptor); + + /** + * remove ResultDescriptor at given columnIndex(>=0) and return same. If not + * present return null. For -ve index, return null + * @param columnIndex + * @return + */ + ResultDescriptor removeResultDescriptor(int columnIndex); + + /** + * Remove resultDescriptor only if matched for index(>=0), name, type, schema + * name and table name and return same, else return null For -ve index, ignore + * index and if unique match for rest of the attriutes, remove/return, if multiple + * matches found, throw RuntimeException + * @param resultDescriptor + * @return + */ + ResultDescriptor removeResultDescriptor(ResultDescriptor resultDescriptor); + + /** + * Return resultDescriptor if exact match for columnIndex(>=0) found + * else return null; + * + * @param columnIndex + * @return + */ + ResultDescriptor getResultDescriptor(int columnIndex); + + /** + * Utility method + * @param ostrm + * @throws IOException + */ + void printResultDescriptors(OutputStream ostrm) throws IOException; +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/ConfigHelper.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/ConfigHelper.java new file mode 100644 index 0000000000..ecfe8416b5 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/ConfigHelper.java @@ -0,0 +1,318 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb; + +import java.io.InputStream; +import java.util.Vector; + +import org.apache.tuscany.das.rdb.config.Column; +import org.apache.tuscany.das.rdb.config.Command; +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.ConfigFactory; +import org.apache.tuscany.das.rdb.config.Parameters; +import org.apache.tuscany.das.rdb.config.Relationship; +import org.apache.tuscany.das.rdb.config.Table; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.util.ConfigUtil; +import org.apache.tuscany.das.rdb.impl.ParametersExtendedImpl; + +/** + * A ConfigHelper is used as an aid in programmatic construction of Config instances. + * Manual contrution fo COnfig is an alternative to providing needed configuration + * information in an XML file + * + */ +public class ConfigHelper { + + private Config config; + + private MappingWrapper configWrapper; + + private ConfigFactory factory = ConfigFactory.INSTANCE; + + /** + * Default constructor + */ + public ConfigHelper() { + config = factory.createConfig(); + configWrapper = new MappingWrapper(config); + } + + /** + * Constructor that receives a Config stream + * This is usefull to extend a config file + * @param configStream The configuration stream + */ + public ConfigHelper(InputStream configStream) { + this.config = ConfigUtil.loadConfig(configStream); + configWrapper = new MappingWrapper(config); + } + + /** + * Constructor that receives a Config object + * @param config The configuration object + */ + public ConfigHelper(Config config) { + this.config = config; + configWrapper = new MappingWrapper(config); + } + + /** + * Add PK information + * @param columnName The column to be taken as PK + */ + public void addPrimaryKey(String columnName) { + configWrapper.addPrimaryKey(columnName); + } + + /** + * Add PK information, with different TypeName + * @param columnName + * @param typeName + */ + public void addPrimaryKey(String columnName, String propertyName) { + configWrapper.addPrimaryKey(columnName, propertyName); + } + + /** + * Add relationship information + * @param parentName + * @param childName + * @return + */ + public Relationship addRelationship(String parentName, String childName) { + return addRelationship(parentName, childName, null); + } + + /** + * Add relationship information + * @param parentName + * @param childName + * @param relationshipName + * @return + */ + public Relationship addRelationship(String parentName, String childName, String relationshipName) { + return configWrapper.addRelationship(parentName, childName, relationshipName); + } + + /** + * Add relationship information + * @param parentNames + * @param childNames + * @return + */ + public Relationship addRelationship(Vector parentNames, Vector childNames) { + return addRelationship(parentNames, childNames, null); + } + + /** + * Add relationship information + * @param parentNames + * @param childNames + * @param relationshipName + * @return + */ + public Relationship addRelationship(Vector parentNames, Vector childNames, String relationshipName) { + return configWrapper.addRelationship(parentNames, childNames, relationshipName); + } + + /** + * Add table information + * @param name + * @param typeName + * @return + */ + public Table addTable(String name, String typeName) { + return configWrapper.addTable(name, typeName); + } + + /** + * Add table information with schema information + * @param name + * @param schemaName + * @param typeName + * @return + */ + public Table addTable(String name, String schemaName, String typeName) { + return configWrapper.addTable(name, schemaName, typeName); + } + + /** + * Add column information + * @param table + * @param columnName + * @param propertyName + * @return + */ + public Column addColumn(Table table, String columnName, String propertyName) { + return configWrapper.addColumn(table, columnName, propertyName); + } + + /** + * Add an update statement for a given table + * @param table + * @param statement + * @param parameters String - names separated with space + */ + public void addUpdateStatement(Table table, String statement, String parameters) { + ParametersExtendedImpl parametersExtendedImpl = new ParametersExtendedImpl(); + parametersExtendedImpl.addParameters(ParametersExtendedImpl.getParameters(parameters)); + configWrapper.addUpdateStatement(table, statement, parametersExtendedImpl); + } + + /** + * Add an update statement for a given table + * @param table + * @param statement + * @param parameters <Parameters> + */ + public void addUpdateStatement(Table table, String statement, Parameters parameters) { + configWrapper.addUpdateStatement(table, statement, parameters); + } + + /** + * Add create statement for a given table + * @param table + * @param statement + * @param parameters String - names separated with space + */ + public void addCreateStatement(Table table, String statement, String parameters) { + ParametersExtendedImpl parametersExtendedImpl = new ParametersExtendedImpl(); + parametersExtendedImpl.addParameters(ParametersExtendedImpl.getParameters(parameters)); + configWrapper.addCreateStatement(table, statement, parametersExtendedImpl); + } + + /** + * Add create statement for a given table + * @param table + * @param statement + * @param parameters <Parameters> + */ + public void addCreateStatement(Table table, String statement, Parameters parameters) { + configWrapper.addCreateStatement(table, statement, parameters); + } + + /** + * Add delete statement for a given table + * @param table + * @param statement + * @param parameters String - names separated with space + */ + public void addDeleteStatement(Table table, String statement, String parameters) { + ParametersExtendedImpl parametersExtendedImpl = new ParametersExtendedImpl(); + parametersExtendedImpl.addParameters(ParametersExtendedImpl.getParameters(parameters)); + configWrapper.addDeleteStatement(table, statement, parametersExtendedImpl); + } + + /** + * Add delete statement for a given table + * @param table + * @param statement + * @param parameters <Parameters> + */ + public void addDeleteStatement(Table table, String statement, Parameters parameters) { + configWrapper.addDeleteStatement(table, statement, parameters); + } + + /** + * Add datasource connection information + * @param dataSourceName + */ + public void addConnectionInfo(String dataSourceName) { + configWrapper.addConnectionInfo(dataSourceName, true); + } + + /** + * Add datasource connection information and flag about using managed transactions + * @param dataSourceName + * @param managedtx + */ + public void addConnectionInfo(String dataSourceName, boolean managedtx) { + configWrapper.addConnectionInfo(dataSourceName, managedtx); + } + + /** + * Add driver manager connection information + * @param driverClass + * @param databaseURL + * @param user + * @param password + * @param loginTimeout + */ + public void addConnectionInfo(String driverClass, String databaseURL, String user, String password, int loginTimeout) { + configWrapper.addConnectionInfo(driverClass, databaseURL, user, password, loginTimeout); + } + + /** + * Set the data object model + * @param dataObjectModel + */ + public void setDataObjectModel(String dataObjectModel) { + configWrapper.getConfig().setDataObjectModel(dataObjectModel); + } + + /** + * Add a select command + * @param name + * @param sql + * @return + */ + public Command addSelectCommand(String name, String sql) { + return configWrapper.addCommand(name, sql, "select"); + } + + /** + * Add a update command + * @param name + * @param sql + * @return + */ + public Command addUpdateCommand(String name, String sql) { + return configWrapper.addCommand(name, sql, "update"); + } + + /** + * Add a insert command + * @param name + * @param sql + * @return + */ + public Command addInsertCommand(String name, String sql) { + return configWrapper.addCommand(name, sql, "insert"); + } + + /** + * Add a delete command + * @param name + * @param sql + * @return + */ + public Command addDeleteCommand(String name, String sql) { + return configWrapper.addCommand(name, sql, "delete"); + } + + /** + * Get a reference to the config object + * @return + */ + public Config getConfig() { + return config; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Converter.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Converter.java new file mode 100644 index 0000000000..24f2e5ee2e --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Converter.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb; + +/** + * A lightweight Table-column <--> DataObject-property converter framework. Converters + * allow a user to insert a transformation between a column value + * and is destination DataObject property value. For example, by default, a VARCHAR + * column will be represented as a String in its corresponding + * DataObject property. A user could insert a converter that transforms the the VARCHAR + * value to an Integer. If this is done then although the column + * returns character data, the DataObject property will be an Integer + * + * + */ +public interface Converter { + + /** + * Transform the columnData object to a new value and possibly + * new type. This should be the invers operation of #getColumnValue + * + * @param columnData + * The column value to transorm + * @return Returns the transformed value + */ + Object getPropertyValue(Object columnData); + + /** + * Transform the columnData object to a new value and possibly new + * type. This should be the invers operation of #getPropertyValue + * + * @param propertyData + * The property value to transform + * @return Returns the transformed value + */ + Object getColumnValue(Object propertyData); + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DAS.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DAS.java new file mode 100644 index 0000000000..43f1e30d1a --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DAS.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb; + +import org.apache.tuscany.das.rdb.impl.DASFactoryImpl; + +import commonj.sdo.DataObject; + +/** + * A CommandGroup represents a set of {@link Command} and single {@link ApplyChangesCommand} + * that are created from a common config file. + * + */ +public interface DAS { + + DASFactory FACTORY = new DASFactoryImpl(); + + /** + * The change history is scanned and modifications to the graph of data objects are flushed to the database. + * + * @param root + * the topmost containing data object + */ + void applyChanges(DataObject root); + + /** + * Gets the named command from this factory's inventory + * + * @param name + * The identifying name of the requested command + * @return Returns the identified command + */ + Command getCommand(String name); + + /** + * If the CommandGroup is managing connections then this method must be called + * when the client is done with the instance. + * + */ + void releaseResources(); + + /** + * Creates a Command based on the provided SQL statement + * + * @param sql + * The SQL statement + * @return returns a Command instance + */ + Command createCommand(String sql); + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DASFactory.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DASFactory.java new file mode 100644 index 0000000000..313fff225a --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DASFactory.java @@ -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. + */ +package org.apache.tuscany.das.rdb; + +import java.io.InputStream; +import java.sql.Connection; + +import org.apache.tuscany.das.rdb.config.Config; + +/** + * A DASFactory produces {@link DAS} instances. + */ +public interface DASFactory { + + /** + * Creates a DAS based on the provided config file stream + * + * @param configStream + * A stream over a DAS config file + * @return returns a DAS instance + */ + DAS createDAS(InputStream configStream); + + /** + * Creates a DAS based on the provide config file stream and connection + * @param configStream + * @param connection + * @return + */ + DAS createDAS(InputStream configStream, Connection connection); + + /** + * Creates a DAS based on the provided config + * + * @param config + * A DAS config object + * @return returns a DAS instance + */ + DAS createDAS(Config config); + + /** + * Creates a DAS based on the provided config and connection + * @param config + * @param connection + * @return + */ + DAS createDAS(Config config, Connection connection); + + /** + * Creates a DAS based on the provided connection + * @param connection + * @return + */ + DAS createDAS(Connection connection); + + +} + diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Pager.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Pager.java new file mode 100644 index 0000000000..aa18558fce --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Pager.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb; + +import commonj.sdo.DataObject; + +/** + * An iterator-like interface to conveniently move through chunks of data. The + * idea is that a Pager works with a read Command. The read command + * returns a large amount of data and the client wants to work with chunks + * of it at a time. So the Pager is created on the command and each call to + * next returns the next chunk of data. This is done completely disconnected. + * No cursor is maintained between calls to #next. + * + * TODO - This is very preliminary. We need to look at this interface + * in the context of disonnected scenarios such as a web app. The Pager instance + * will probably be saved in session so it must be very light and cannot + * reference a connection. Also, we probably need to define a factory or add a + * method to set page size. + * + * + */ +public interface Pager { + + /** + * Get the next page of data + * + * @return the next page of data + */ + DataObject next(); + + /** + * Get the page prior to the last page returned + * + * @return the previous page + */ + DataObject previous(); + + /** + * Return a specific identified page. + * + * @param page + * The number of the page to return + * @return the indicated page + */ + DataObject getPage(int page); + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/MappingWrapper.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/MappingWrapper.java new file mode 100644 index 0000000000..484d0c54c3 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/MappingWrapper.java @@ -0,0 +1,888 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.config.wrapper; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.Column; +import org.apache.tuscany.das.rdb.config.Command; +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.ConfigFactory; +import org.apache.tuscany.das.rdb.config.ConnectionInfo; +import org.apache.tuscany.das.rdb.config.ConnectionProperties; +import org.apache.tuscany.das.rdb.config.Create; +import org.apache.tuscany.das.rdb.config.Delete; +import org.apache.tuscany.das.rdb.config.KeyPair; +import org.apache.tuscany.das.rdb.config.Parameters; +import org.apache.tuscany.das.rdb.config.Relationship; +import org.apache.tuscany.das.rdb.config.Table; +import org.apache.tuscany.das.rdb.config.Update; + +import commonj.sdo.Property; + +public class MappingWrapper { + + private static final ConfigFactory FACTORY = ConfigFactory.INSTANCE; + + private final Logger logger = Logger.getLogger(MappingWrapper.class); + + private Config config; + + // TUSCANY-2288 + private List insertOrder; + private List deleteOrder; + // -- + + + public MappingWrapper() { + config = FACTORY.createConfig(); + //JIRA-952 + this.checkSchemaNameSupport(); + } + + //JIRA-952 - check if there is any entry with no schemaName when support is ON + public void checkSchemaNameSupport(){ + if(config.isDatabaseSchemaNameSupported()){ + List tableList = config.getTable(); + for(int i=0; i<tableList.size(); i++){ + Table t = (Table)tableList.get(i); + if(t.getSchemaName() == null || t.getSchemaName().equals("")){ + throw new RuntimeException("No schemaName provided for tableName "+t.getTableName()+" when schemaNameSupport is ON"); + } + + if(t.getTypeName()==null){ + t.setTypeName(t.getSchemaName()+"."+t.getTableName()); + } + } + } + } + public MappingWrapper(Config mapping) { + if (mapping == null) { + this.config = FACTORY.createConfig(); + } else { + this.config = mapping; + } + //JIRA-952 + checkSchemaNameSupport(); + } + + public Config getConfig() { + return this.config; + } + + public Table getTable(String tableName) { + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Looking for table " + tableName); + } + + Iterator i = config.getTable().iterator(); + while (i.hasNext()) { + Table t = (Table) i.next(); + //JIRA-952 + if(this.config.isDatabaseSchemaNameSupported()){ + if (tableName.equalsIgnoreCase(t.getSchemaName()+"."+t.getTableName())) { + return t; + } + }else{ + if (tableName.equalsIgnoreCase(t.getTableName())) { + return t; + } + } + } + + return null; + } + + public Table getTableByTypeName(String typeName) { + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Looking for table by property: " + typeName); + } + + Iterator i = config.getTable().iterator(); + while (i.hasNext()) { + Table t = (Table) i.next(); + TableWrapper wrapper = new TableWrapper(t); + if (typeName.equals(wrapper.getTypeName())) { + return t; + } + } + return null; + + } + + public void addImpliedRelationship(String parentTableName, String childTableName, String fkColumnName) { + + // Don't create a relationship for something like Book.Book_ID + if (parentTableName.equalsIgnoreCase(childTableName)) { + return; + } + + // Don't create a relationship if one already exists in the config + Iterator i = config.getRelationship().iterator(); + while (i.hasNext()) { + Relationship r = (Relationship) i.next(); + if (r.getPrimaryKeyTable().equals(parentTableName) && r.getForeignKeyTable().equals(childTableName)) { + return; + } + } + + Relationship r = FACTORY.createRelationship(); + r.setName(childTableName); + r.setPrimaryKeyTable(parentTableName); + r.setForeignKeyTable(childTableName); + + KeyPair pair = FACTORY.createKeyPair(); + pair.setPrimaryKeyColumn("ID"); + pair.setForeignKeyColumn(fkColumnName); + + r.getKeyPair().add(pair); + r.setMany(true); + + config.getRelationship().add(r); + } + + public Relationship addRelationship(String parentName, String childName) { + return addRelationship(parentName, childName, null); + } + + public Relationship addRelationship(String parentName, String childName, String relationshipName) { + + //JIRA-952 + QualifiedColumn parent = null; + QualifiedColumn child = null; + + if(this.config.isDatabaseSchemaNameSupported()){ + parent = new QualifiedColumn(parentName, true); + child = new QualifiedColumn(childName, true); + } + else{ + parent = new QualifiedColumn(parentName); + child = new QualifiedColumn(childName); + } + + Relationship r = FACTORY.createRelationship(); + //JIRA-952 + if(this.config.isDatabaseSchemaNameSupported()){ + if(relationshipName == null) + r.setName(child.getSchemaName()+"."+child.getTableName()); + else + r.setName(relationshipName); + + r.setPrimaryKeyTable(parent.getSchemaName()+"."+parent.getTableName()); + r.setForeignKeyTable(child.getSchemaName()+"."+child.getTableName()); + } + else{ + if(relationshipName == null) + r.setName(child.getTableName()); + else + r.setName(relationshipName); + + r.setPrimaryKeyTable(parent.getTableName()); + r.setForeignKeyTable(child.getTableName()); + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Created relationship from " + r.getPrimaryKeyTable() + + " to " + r.getForeignKeyTable() + " named " + r.getName()); + } + + KeyPair pair = FACTORY.createKeyPair(); + pair.setPrimaryKeyColumn(parent.getColumnName()); + pair.setForeignKeyColumn(child.getColumnName()); + + r.getKeyPair().add(pair); + r.setMany(true); + + config.getRelationship().add(r); + + return r; + + } + + public Relationship addRelationship(Vector parentNames, Vector childNames) { + return addRelationship(parentNames, childNames, null); + } + + public Relationship addRelationship(Vector parentNames, Vector childNames, String relationshipName) { + //create vector for each + if(parentNames.size() != childNames.size()){ + throw new RuntimeException("Can not for relationship for multiple keys, different sizes"); + } + + Vector parentColumns = new Vector(); + Vector childColumns = new Vector(); + + for(int i=0; i<parentNames.size(); i++){ + QualifiedColumn parent = null; + QualifiedColumn child = null; + + if(this.config.isDatabaseSchemaNameSupported()){ + parent = new QualifiedColumn((String)parentNames.get(i), true); + child = new QualifiedColumn((String)childNames.get(i), true); + } + else{ + parent = new QualifiedColumn((String)parentNames.get(i)); + child = new QualifiedColumn((String)childNames.get(i)); + } + + parentColumns.add(parent); + childColumns.add(child); + } + + //all parent columns should be from same table and schema + //all child columns should be from same table and schema + checkTableNames(parentColumns); + checkSchemaNames(parentColumns); + + checkTableNames(childColumns); + checkSchemaNames(childColumns); + + Relationship r = FACTORY.createRelationship(); + //JIRA-952 + if(this.config.isDatabaseSchemaNameSupported()){ + if(relationshipName == null) + r.setName(((QualifiedColumn)childColumns.get(0)).getSchemaName()+"." + +((QualifiedColumn)childColumns.get(0)).getTableName()); + else + r.setName(relationshipName); + + r.setPrimaryKeyTable(((QualifiedColumn)parentColumns.get(0)).getSchemaName()+"." + +((QualifiedColumn)parentColumns.get(0)).getTableName()); + r.setForeignKeyTable(((QualifiedColumn)childColumns.get(0)).getSchemaName()+"." + +((QualifiedColumn)childColumns.get(0)).getTableName()); + } + else{ + if(relationshipName == null) + r.setName(((QualifiedColumn)childColumns.get(0)).getTableName()); + else + r.setName(relationshipName); + + r.setPrimaryKeyTable(((QualifiedColumn)parentColumns.get(0)).getTableName()); + r.setForeignKeyTable(((QualifiedColumn)childColumns.get(0)).getTableName()); + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Created relationship from " + r.getPrimaryKeyTable() + + " to " + r.getForeignKeyTable() + " named " + r.getName()); + } + + KeyPair pair = null; + + for(int i=0; i<parentColumns.size(); i++){ + pair = FACTORY.createKeyPair(); + pair.setPrimaryKeyColumn(((QualifiedColumn)parentColumns.get(i)).getColumnName()); + pair.setForeignKeyColumn(((QualifiedColumn)childColumns.get(i)).getColumnName()); + r.getKeyPair().add(pair); + } + + r.setMany(true); + config.getRelationship().add(r); + + return r; + } + + public void checkTableNames(Vector columns){ + String expectedTableName = ((QualifiedColumn)columns.get(0)).getTableName(); + + for(int i=0; i<columns.size(); i++){ + QualifiedColumn currColumn = (QualifiedColumn)columns.get(i); + String currTableName = currColumn.getTableName(); + + if(!currTableName.equals(expectedTableName)){ + throw new RuntimeException("Columns in one side of relationship can not be from different tables"); + } + } + } + + public void checkSchemaNames(Vector columns){ + if(!this.config.isDatabaseSchemaNameSupported()){ + return; + } + + String expectedSchemaName = ((QualifiedColumn)columns.get(0)).getSchemaName(); + + for(int i=0; i<columns.size(); i++){ + QualifiedColumn currColumns = (QualifiedColumn)columns.get(i); + String currSchemaName = currColumns.getSchemaName(); + + if(!currSchemaName.equals(expectedSchemaName)){ + throw new RuntimeException("Columns in one side of relationship can not be from different schema"); + } + } + } + public void addPrimaryKey(String columnName) { + addPrimaryKey(Collections.singletonList(columnName)); + } + + public void addPrimaryKey(String columnName, String propertyName) { + addPrimaryKey(Collections.singletonList(columnName), propertyName); + } + + public void addPrimaryKey(List columnNames) { + + Iterator i = columnNames.iterator(); + while (i.hasNext()) { + String columnName = (String) i.next(); + + QualifiedColumn pkColumn = null; + pkColumn = new QualifiedColumn(columnName, this.config.isDatabaseSchemaNameSupported()); + //Table t = findOrCreateTable(pkColumn.getTableName()); + Table t = findOrCreateTable(pkColumn); + Column c = findOrCreateColumn(t, pkColumn.getColumnName()); + c.setPrimaryKey(true); + } + } + + public void addPrimaryKey(List columnNames, String propertyName) { + + Iterator i = columnNames.iterator(); + while (i.hasNext()) { + String columnName = (String) i.next(); + + QualifiedColumn pkColumn = null; + pkColumn = new QualifiedColumn(columnName, this.config.isDatabaseSchemaNameSupported()); + //Table t = findOrCreateTable(pkColumn.getTableName()); + Table t = findOrCreateTable(pkColumn); + Column c = findOrCreateColumn(t, pkColumn.getColumnName()); + c.setPrimaryKey(true); + c.setPropertyName(propertyName); + } + } + + public String getTableTypeName(String tableName) { + Table t = getTable(tableName); + if (t == null) { + return tableName; + } + String propertyName = t.getTypeName(); + + if (propertyName == null) { + return tableName; + } + + return propertyName; + } + + public Column getColumn(Table t, String columnName) { + if (t == null) { + return null; + } + Iterator i = t.getColumn().iterator(); + while (i.hasNext()) { + Column c = (Column) i.next(); + if (c.getColumnName().equals(columnName)) { + return c; + } + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug("WARNING: Could not find column " + columnName + " in table " + t.getTableName()); + } + + return null; + } + + public Column getColumnByPropertyName(Table t, String propertyName) { + if (t == null) { + return null; + } + + Iterator i = t.getColumn().iterator(); + while (i.hasNext()) { + Column c = (Column) i.next(); + + if (c.getColumnName().equals(propertyName)) { + return c; + } + + if (c.getPropertyName() != null && c.getPropertyName().equals(propertyName)) { + return c; + } + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug("WARNING: Could not find column " + propertyName + " in table " + t.getTableName()); + } + + return null; + } + + public String getColumnPropertyName(String tableName, String columnName) { + Table t = getTable(tableName); + Column c = getColumn(t, columnName); + if (c == null) { + return columnName; + } + + String propertyName = c.getPropertyName(); + if (propertyName == null) { + return c.getColumnName(); + } + + return propertyName; + } + + public Table addTable(String tableName, String typeName) { + Table table = getTable(tableName); + if (table != null) { + throw new RuntimeException("Table " + tableName + "already exists"); + } + + table = ConfigFactory.INSTANCE.createTable(); + table.setTableName(tableName); + table.setTypeName(typeName); + config.getTable().add(table); + + return table; + } + + //JIRA-952 + public Table addTable(String tableName, String schemaName, String typeName) { + Table table = null; + + if(this.config.isDatabaseSchemaNameSupported()){ + table = getTable(schemaName+"."+tableName); + } + else{ + table = getTable(tableName); + } + + if (table != null) { + if(this.config.isDatabaseSchemaNameSupported()){ + throw new RuntimeException("Table " + schemaName+"."+tableName + "already exists"); + } + else{ + throw new RuntimeException("Table " + tableName + "already exists"); + } + } + + table = ConfigFactory.INSTANCE.createTable(); + table.setTableName(tableName); + + if(this.config.isDatabaseSchemaNameSupported()){ + table.setSchemaName(schemaName); + } + else{ + table.setSchemaName(""); + } + + table.setTypeName(typeName); + config.getTable().add(table); + + return table; + } + public Column addColumn(Table table, String name, String propertyName) { + Column column = ConfigFactory.INSTANCE.createColumn(); + column.setColumnName(name); + column.setPropertyName(propertyName); + + table.getColumn().add(column); + return column; + } + + //JIRA-952 + private Table findOrCreateTable(String schemaName, String tableName) { + Table table = null; + + if(this.config.isDatabaseSchemaNameSupported()){ + table = getTable(schemaName+"."+tableName); + } + else{ + table = getTable(tableName); + } + if (table == null) { + table = ConfigFactory.INSTANCE.createTable(); + table.setTableName(tableName); + table.setSchemaName(schemaName); + + if(this.config.isDatabaseSchemaNameSupported()){ + table.setTypeName(schemaName+"."+tableName); + } + else{ + table.setTypeName(tableName); + } + config.getTable().add(table); + } + return table; + + } + + //JIRA-952 + private Table findOrCreateTable(QualifiedColumn column) { + Table table = null; + if(this.config.isDatabaseSchemaNameSupported()){ + table = getTable(column.getSchemaName()+"."+column.getTableName()); + } + else{ + table = getTable(column.getTableName()); + } + + if (table == null) { + table = ConfigFactory.INSTANCE.createTable(); + table.setTableName(column.getTableName()); + table.setSchemaName(column.getSchemaName()); + config.getTable().add(table); + } + return table; + + } + private Column findOrCreateColumn(Table t, String name) { + Iterator i = t.getColumn().iterator(); + while (i.hasNext()) { + Column c = (Column) i.next(); + if (name.equals(c.getColumnName())) { + return c; + } + } + + Column c = ConfigFactory.INSTANCE.createColumn(); + c.setColumnName(name); + t.getColumn().add(c); + return c; + } + + public boolean hasRecursiveRelationships() { + if (config != null) { + Iterator i = getConfig().getRelationship().iterator(); + while (i.hasNext()) { + Relationship r = (Relationship) i.next(); + if (r.getPrimaryKeyTable().equals(r.getForeignKeyTable())) { + return true; + } + } + } + return false; + } + + /*Parameter name is SDO Type name and so requires mapping in table<->type, if one is available in Config*/ + public Collection getRelationshipsByChildTable(String name) { + Table table = getTableByTypeName(name); + + if(table != null) { + if(config.isDatabaseSchemaNameSupported()) { + name = table.getSchemaName()+"."+table.getTableName(); + } else { + name = table.getTableName(); + } + } + //table can be null, when no <Table> in Config and Query based Dynamic Types are used during query + + List results = new ArrayList(); + if (config != null) { + Iterator i = getConfig().getRelationship().iterator(); + while (i.hasNext()) { + Relationship r = (Relationship) i.next(); + if (name.equals(r.getForeignKeyTable())) { + results.add(r); + } + } + } + return results; + } + + // TUSCANY-2288 + public List getInsertOrder() { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Getting insert order"); + } + if (insertOrder == null) { + insertOrder = new ArrayList(); + if (config == null) return insertOrder; + // correct insert order: tables sorted by ascending depth + // parse all relationships + Set allParents = new HashSet(); + Set allChildren = new HashSet(); + Map parentToChild = new HashMap(); + Iterator i = getConfig().getRelationship().iterator(); + while (i.hasNext()) { + Relationship r = (Relationship) i.next(); + String parent = r.getPrimaryKeyTable(); + String child = r.getForeignKeyTable(); + if (parent.equals(child)) { + // self-relationship + // do not add to parent to child map to avoid loops + // do not add to all children list to allow root detection + allParents.add(parent); + } else { + allParents.add(parent); + allChildren.add(child); + Set children = (Set) parentToChild.get(parent); + if (children == null) { + children = new HashSet(); + parentToChild.put(parent, children); + } + children.add(child); + } + } + // build list of tables ordered by depth + List depthList = new ArrayList(); + // find roots (depth 0) + // roots are tables that are present in the parents set, but not in the children set + Set roots = new HashSet(); + for (Iterator itParents = allParents.iterator(); itParents.hasNext(); ) { + String parent = (String) itParents.next(); + if (!allChildren.contains(parent)) { + roots.add(parent); + } + } + // traverse table graph to populate depth list + traverseTableGraph(roots, 0, parentToChild, depthList, new ArrayList()); + // build insert order from depth list + for (Iterator itDepths = depthList.iterator(); itDepths.hasNext(); ) { + Set tables = (Set) itDepths.next(); + insertOrder.addAll(tables); + } + } + if (this.logger.isDebugEnabled()) { + this.logger.debug(insertOrder); + } + return insertOrder; + } + + private void traverseTableGraph(Set parents, int parentDepth, Map parentToChild, List depthList, List branch) { + int childDepth = parentDepth + 1; + // expand depth list if necessary + for (int i = depthList.size() - 1; i < parentDepth; i++) { + Set tables = new HashSet(); + depthList.add(tables); + } + // loop thru parents + for (Iterator itParents = parents.iterator(); itParents.hasNext(); ) { + String parent = (String) itParents.next(); + if (branch.contains(parent)) { + // we found a cycle + // we don't handle cycles + // stop traversing branch to avoid infinite loop + break; + } + // add parent to depth list + addTableToDepthList(parent, parentDepth, depthList); + // make recursive call on children + Set children = (Set) parentToChild.get(parent); + if (children != null && children.size() > 0) { + List parentBranch = new ArrayList(); + parentBranch.addAll(branch); + parentBranch.add(parent); + traverseTableGraph(children, childDepth, parentToChild, depthList, parentBranch); + } + } + } + + private void addTableToDepthList(String table, int depth, List depthList) { + // in this method, keep in mind that the same table can appear multiple times at multiple depths inside the table graph + // check if table is already somewhere in depth list + int currentDepth = getTableDepth(table, depthList); + if (currentDepth == -1) { + // table not in depth list + // add it + Set tables = (Set) depthList.get(depth); + tables.add(table); + } else if (currentDepth < depth) { + // table already in depth list, at a lower depth + // the table should only be present once, at the greatest possible depth + // replace table at the new depth + Set tables = (Set) depthList.get(currentDepth); + tables.remove(table); + tables = (Set) depthList.get(depth); + tables.add(table); + } else { + // table already in depth list, at a greater or same depth + // nothing to do, since the table should only be present once, at the greatest possible depth + } + } + + private int getTableDepth(String table, List depthList) { + int depth = -1; + // loop thru depth list + int count = depthList.size(); + for (int i = 0; i < count; i++) { + Set tables = (Set) depthList.get(i); + if (tables != null && tables.contains(table)) { + depth = i; + break; + } + } + return depth; + } + + + public List getDeleteOrder() { + if (deleteOrder == null) { + deleteOrder = new ArrayList(); + deleteOrder.addAll(getInsertOrder()); + Collections.reverse(deleteOrder); + } + return deleteOrder; + } + + // -- + + + //JIRA-952 + public void addConverter(String name, String converter) { + QualifiedColumn column = new QualifiedColumn(name, this.config.isDatabaseSchemaNameSupported()); + Table t = null; + t = findOrCreateTable(column); + Column c = findOrCreateColumn(t, column.getColumnName()); + c.setConverterClassName(converter); + } + + public String getConverter(String tableName, String columnName) { + Table t = getTable(tableName); + Column c = getColumn(t, columnName); + if (c != null) { + return c.getConverterClassName(); + } + return null; + } + + public Map getConverters(Table table) { + Map converters = new HashMap(); + + Iterator columns = table.getColumn().iterator(); + while (columns.hasNext()) { + Column c = (Column) columns.next(); + if (c.getConverterClassName() != null) { + String property = c.getPropertyName(); + if (property == null) { + property = c.getColumnName(); + } + converters.put(property, c.getConverterClassName()); + } + } + return converters; + } + + public Relationship getRelationshipByReference(Property ref) { + Iterator i = config.getRelationship().iterator(); + while (i.hasNext()) { + Relationship r = (Relationship) i.next(); + if (ref.getName().equals(r.getName()) || ref.getOpposite().getName().equals(r.getName())) { + return r; + } + } + throw new RuntimeException("Could not find relationship " + ref.getName() + " in the configuration"); + } + + public Relationship getRelationshipByName(String name) { + Iterator i = config.getRelationship().iterator(); + while (i.hasNext()) { + Relationship r = (Relationship) i.next(); + if (name.equals(r.getName())) { + return r; + } + } + throw new RuntimeException("Could not find relationship " + name + " in the configuration"); + } + + public void addUpdateStatement(Table table, String statement, Parameters parameters) { + + Update update = ConfigFactory.INSTANCE.createUpdate(); + update.setSql(statement); + update.setParameters(parameters); + table.setUpdate(update); + + } + + public void addDeleteStatement(Table table, String statement, Parameters parameters) { + + Delete delete = ConfigFactory.INSTANCE.createDelete(); + delete.setSql(statement); + delete.setParameters(parameters); + table.setDelete(delete); + + } + + public void addCreateStatement(Table table, String statement, Parameters parameters) { + + Create create = ConfigFactory.INSTANCE.createCreate(); + create.setSql(statement); + create.setParameters(parameters); + table.setCreate(create); + + } + + //JIRA-948 support for driver manager connection + public void addConnectionInfo(String dataSourceName, boolean managedtx){ + ConnectionInfo info = ConfigFactory.INSTANCE.createConnectionInfo(); + info.setDataSource(dataSourceName); + info.setManagedtx(managedtx); + + config.setConnectionInfo(info); + } + + public void addConnectionInfo(String driverClass, String connectionURL, String user, String password, int loginTimeout) { + ConnectionInfo info = ConfigFactory.INSTANCE.createConnectionInfo(); + + ConnectionProperties connectionProperties = ConfigFactory.INSTANCE.createConnectionProperties(); + connectionProperties.setDriverClass(driverClass); + connectionProperties.setDatabaseURL(connectionURL); + connectionProperties.setUserName(user); + connectionProperties.setPassword(password); + connectionProperties.setLoginTimeout(loginTimeout); + + info.setConnectionProperties(connectionProperties); + config.setConnectionInfo(info); + } + //JIRA-948 end + + public Command addCommand(String name, String sql, String kind) { + Command cmd = ConfigFactory.INSTANCE.createCommand(); + cmd.setName(name); + cmd.setKind(kind); + cmd.setSQL(sql); + + config.getCommand().add(cmd); + + return cmd; + } + + //JIRA-952 + public void addImpliedPrimaryKey(String schemaName, String tableName, String columnName) { + Table t = findOrCreateTable(schemaName, tableName);//JIRA-952 + + Iterator i = t.getColumn().iterator(); + boolean hasPK = false; + while (i.hasNext()) { + Column c = (Column) i.next(); + if (c.isPrimaryKey()) { + hasPK = true; + } + } + + if (!hasPK) { + Column c = findOrCreateColumn(t, columnName); + c.setPrimaryKey(true); + } + + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/QualifiedColumn.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/QualifiedColumn.java new file mode 100644 index 0000000000..95e5e78c54 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/QualifiedColumn.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.config.wrapper; + +import org.apache.log4j.Logger; + +public class QualifiedColumn { + + private final String tableName; + + private final String columnName; + private final String schemaName;//JIRA-952 + + private final Logger logger = Logger.getLogger(QualifiedColumn.class); + + public QualifiedColumn(String name) { + this.schemaName = ""; + int index = name.indexOf('.'); + if ( index == -1 ) { + throw new RuntimeException("Column " + name + " must be qualified with a table name"); + } + tableName = name.substring(0, index); + columnName = name.substring(index + 1); + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Table name: " + tableName); + this.logger.debug("Column name: " + columnName); + } + } + + //JIRA-952 + public QualifiedColumn(String name, boolean isDatabaseSchemaNameSupported) { + int index = name.indexOf('.'); + if ( index == -1 ) { + throw new RuntimeException("Column " + name + " must be qualified with a table name and optional schema name"); + } + + int lastIndex = name.lastIndexOf('.'); + + if(index == lastIndex && isDatabaseSchemaNameSupported){ + throw new RuntimeException("Column " + name + " must be qualified with a table name and schema name"); + } + + if(isDatabaseSchemaNameSupported){ + schemaName = name.substring(0, index); + tableName = name.substring(index+1, lastIndex); + columnName = name.substring(lastIndex + 1); + } + else{ + schemaName = ""; + tableName = name.substring(0, index); + columnName = name.substring(index + 1); + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Table name: " + tableName); + this.logger.debug("Column name: " + columnName); + } + } + public String getTableName() { + return this.tableName; + } + + //JIRA-952 + public String getSchemaName() { + return this.schemaName; + } + public String getColumnName() { + return this.columnName; + } + //JIRA-952 + public String toString(){ + if(this.schemaName == null || this.schemaName.equals("")) + return this.tableName+"."+this.columnName; + else + return this.schemaName+"."+this.tableName+"."+this.columnName; + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/RelationshipWrapper.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/RelationshipWrapper.java new file mode 100644 index 0000000000..0e4447bf8b --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/RelationshipWrapper.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.config.wrapper; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.das.rdb.config.KeyPair; +import org.apache.tuscany.das.rdb.config.Relationship; + +public class RelationshipWrapper { + + private Relationship relationship; + + public RelationshipWrapper(Relationship r) { + this.relationship = r; + } + + public Collection getForeignKeys() { + List keys = new ArrayList(); + Iterator i = this.relationship.getKeyPair().iterator(); + while (i.hasNext()) { + KeyPair pair = (KeyPair) i.next(); + keys.add(pair.getForeignKeyColumn()); + } + return keys; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/TableWrapper.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/TableWrapper.java new file mode 100644 index 0000000000..ef420eedf2 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/config/wrapper/TableWrapper.java @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.config.wrapper; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.das.rdb.config.Column; +import org.apache.tuscany.das.rdb.config.Table; + +public class TableWrapper { + + private Table table; + + public TableWrapper(Table table) { + this.table = table; + } + + public String getTypeName() { + return table.getTypeName() == null ? table.getTableName() : table.getTypeName(); + } + + public String getTableName() { + return table.getTableName(); + } + + public Collection getPrimaryKeyNames() { + List pkNames = new ArrayList(); + Iterator i = table.getColumn().iterator(); + while (i.hasNext()) { + Column c = (Column) i.next(); + if (c.isPrimaryKey()) { + pkNames.add(c.getColumnName()); + } + } + return pkNames; + } + + public Collection getPrimaryKeyProperties() { + + List keyProperties = new ArrayList(); + Iterator columns = table.getColumn().iterator(); + while (columns.hasNext()) { + Column c = (Column) columns.next(); + if (c.isPrimaryKey()) { + keyProperties.add(getColumnPropertyName(c)); + } + } + + return keyProperties; + } + + private String getColumnPropertyName(Column c) { + if (c.getPropertyName() != null) { + return c.getPropertyName(); + } + + return c.getColumnName(); + } + + public boolean isGeneratedColumnProperty(String name) { + Column c = getColumnByPropertyName(name); + return c == null ? false : c.isGenerated(); + } + + public String getConverter(String propertyName) { + Column c = getColumnByPropertyName(propertyName); + return (c == null) ? null : c.getConverterClassName(); + } + + public Column getColumnByPropertyName(String propertyName) { + Iterator columns = table.getColumn().iterator(); + while (columns.hasNext()) { + Column c = (Column) columns.next(); + String property = c.getPropertyName(); + if (property == null) { + property = c.getColumnName(); + } + if (propertyName.equals(property)) { + return c; + } + } + + return null; + } + + public Column getCollisionColumn() { + Iterator columns = table.getColumn().iterator(); + while (columns.hasNext()) { + Column c = (Column) columns.next(); + if (c.isCollision()) { + return c; + } + } + + return null; + + } + + public String getCollisionColumnPropertyName() { + Column c = getCollisionColumn(); + if (c.getPropertyName() != null) { + return c.getPropertyName(); + } + return c.getColumnName(); + + } + + public String getManagedColumnPropertyName() { + Iterator i = table.getColumn().iterator(); + while (i.hasNext()) { + Column c = (Column) i.next(); + if (c.isCollision() && c.isManaged()) { + return c.getPropertyName() == null ? c.getColumnName() : c.getPropertyName(); + } + } + return null; + + } + + public Column getManagedColumn() { + Iterator i = table.getColumn().iterator(); + while (i.hasNext()) { + Column c = (Column) i.next(); + if (c.isCollision() && c.isManaged()) { + return c; + } + } + return null; + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/exception/DataSourceInitializationException.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/exception/DataSourceInitializationException.java new file mode 100644 index 0000000000..6a644b7ed9 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/exception/DataSourceInitializationException.java @@ -0,0 +1,36 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.rdb.exception;
+
+public class DataSourceInitializationException extends RuntimeException {
+
+ private static final long serialVersionUID = 302160989411041041L;
+
+ public DataSourceInitializationException(String string) {
+ super(string);
+ }
+
+ public DataSourceInitializationException(Throwable e){
+ super(e);
+ }
+
+ public DataSourceInitializationException(String string, Throwable e) {
+ super(string, e);
+ }
+}
diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/exception/OptimisticConcurrencyException.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/exception/OptimisticConcurrencyException.java new file mode 100644 index 0000000000..dc64d7dc94 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/exception/OptimisticConcurrencyException.java @@ -0,0 +1,31 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.rdb.exception;
+
+
+public class OptimisticConcurrencyException extends RuntimeException {
+
+ private static final long serialVersionUID = -8430445422807942933L;
+
+ public OptimisticConcurrencyException(String string) {
+ super(string);
+ }
+
+
+}
diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/BaseGenerator.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/BaseGenerator.java new file mode 100644 index 0000000000..05d97723a7 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/BaseGenerator.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.generator.impl; + +import org.apache.tuscany.das.rdb.Converter; + +public class BaseGenerator { + + protected Converter getConverter(String converter) { + if (converter != null) { + try { + return (Converter) Thread.currentThread().getContextClassLoader().loadClass(converter).newInstance(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + return null; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/DeleteGenerator.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/DeleteGenerator.java new file mode 100644 index 0000000000..ad2a90c841 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/DeleteGenerator.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.generator.impl; + +import java.util.Iterator; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.Table; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.TableWrapper; +import org.apache.tuscany.das.rdb.impl.DeleteCommandImpl; +import org.apache.tuscany.das.rdb.impl.ParameterExtendedImpl; +import org.apache.tuscany.das.rdb.impl.SDODataTypeHelper; +import org.apache.tuscany.das.rdb.impl.SDODataTypes; + +public final class DeleteGenerator extends BaseGenerator { + + public static final DeleteGenerator INSTANCE = new DeleteGenerator(); + + private final Logger logger = Logger.getLogger(DeleteGenerator.class); + + private DeleteGenerator() { + super(); + } + + //JIRA-952 + private String getDeleteStatement(MappingWrapper mapping, Table t) { + TableWrapper table = new TableWrapper(t); + + StringBuffer statement = new StringBuffer(); + statement.append("delete from "); + if(mapping.getConfig().isDatabaseSchemaNameSupported()){ + statement.append(t.getSchemaName()+"."+t.getTableName()); + } + else{ + statement.append(t.getTableName()); + } + statement.append(" where "); + + Iterator names = table.getPrimaryKeyNames().iterator(); + Iterator properties = table.getPrimaryKeyProperties().iterator(); + while (names.hasNext() && properties.hasNext()) { + String name = (String) names.next(); + statement.append(name); + statement.append(" = ?"); + if (names.hasNext() && properties.hasNext()) { + statement.append(" and "); + } + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug(statement.toString()); + } + + return statement.toString(); + } + + public DeleteCommandImpl getDeleteCommand(MappingWrapper mapping, Table t) { + TableWrapper tw = new TableWrapper(t); + DeleteCommandImpl deleteCommand = new DeleteCommandImpl(getDeleteStatement(mapping, t)); + + Iterator i = tw.getPrimaryKeyProperties().iterator(); + for (int idx = 1; i.hasNext(); idx++) { + String property = (String) i.next(); + ParameterExtendedImpl p = new ParameterExtendedImpl(); + p.setName(property); + p.setColumnType(SDODataTypeHelper.columnTypeForSDOType(SDODataTypes.OBJECT)); + p.setConverter(getConverter(tw.getConverter(property))); + p.setIndex(idx); + deleteCommand.addParameter(p); + } + return deleteCommand; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/InsertGenerator.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/InsertGenerator.java new file mode 100644 index 0000000000..d174629ad9 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/InsertGenerator.java @@ -0,0 +1,182 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.generator.impl; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.Column; +import org.apache.tuscany.das.rdb.config.Relationship; +import org.apache.tuscany.das.rdb.config.Table; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.RelationshipWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.TableWrapper; +import org.apache.tuscany.das.rdb.impl.InsertCommandImpl; +import org.apache.tuscany.das.rdb.impl.ParameterExtendedImpl; +import org.apache.tuscany.das.rdb.impl.SDODataTypeHelper; +import org.apache.tuscany.das.rdb.util.CollectionsUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; + +public final class InsertGenerator extends BaseGenerator { + + public static final InsertGenerator INSTANCE = new InsertGenerator(); + + private final Logger logger = Logger.getLogger(InsertGenerator.class); + + private InsertGenerator() { + super(); + } + + public InsertCommandImpl getInsertCommand(MappingWrapper config, DataObject changedObject, Table t) { + List parameters = new ArrayList(); + TableWrapper table = new TableWrapper(t); + StringBuffer statement = new StringBuffer("insert into "); + //JIRA-952 + if(config.getConfig().isDatabaseSchemaNameSupported()){ + statement.append(t.getSchemaName()+"."+t.getTableName()); + } + else{ + statement.append(t.getTableName()); + } + HashSet changedProperties = getAttributeProperties(changedObject, config, table); + Iterator i; + if ( changedProperties.isEmpty() ) { + i = changedObject.getType().getProperties().iterator(); + } else { + i = changedProperties.iterator(); + } + + List attributes = new ArrayList(); + List generatedKeys = new ArrayList(); + while (i.hasNext()) { + Property attr = (Property) i.next(); + if ( attr.getType().isDataType()) { + if (table.isGeneratedColumnProperty(attr.getName())) { + generatedKeys.add(attr.getName()); + } else { + attributes.add(attr.getName()); + parameters.add(changedObject.getType().getProperty(attr.getName())); + } + } + } + + statement.append("("); + Iterator attrs = attributes.iterator(); + while (attrs.hasNext()) { + String name = (String) attrs.next(); + statement.append(""); + Column c = config.getColumnByPropertyName(t, name); + statement.append(c == null ? name : c.getColumnName()); + if (attrs.hasNext()) { + statement.append(", "); + } else { + statement.append(")"); + } + } + + statement.append(" values ("); + for (int idx = 1; idx <= attributes.size(); idx++) { + statement.append('?'); + if (idx < attributes.size()) { + statement.append(", "); + } else { + statement.append(")"); + } + } + + InsertCommandImpl cmd = new InsertCommandImpl(statement.toString(), + (String[]) generatedKeys.toArray(new String[0])); + Iterator params = parameters.iterator(); + for (int idx = 1; params.hasNext(); idx++) { + Property property = (Property) params.next(); + ParameterExtendedImpl p = new ParameterExtendedImpl(); + p.setName(property.getName()); + p.setType(property.getType()); + p.setColumnType(SDODataTypeHelper.columnTypeForSDOType(property.getType())); + p.setConverter(getConverter(table.getConverter(property.getName()))); + p.setIndex(idx); + cmd.addParameter(p); + + } + if (this.logger.isDebugEnabled()) { + this.logger.debug(statement.toString()); + } + + return cmd; + + } + + private HashSet getAttributeProperties(DataObject obj, MappingWrapper config, TableWrapper tw) { + HashSet fields = new HashSet(); + Iterator i = obj.getType().getProperties().iterator(); + while (i.hasNext()) { + Property p = (Property) i.next(); + if (p.getType().isDataType()) { + if (obj.isSet(p)) { + if (fields.add(p) == false) { + throw new RuntimeException("Foreign key properties should not be set when the corrsponding relationship has changed"); + } + } + } else { + if (obj.isSet(p)) { + Relationship relationship = config.getRelationshipByReference(p); + if ((p.getOpposite() != null && p.getOpposite().isMany()) + || (hasState(tw, relationship, obj))) { + RelationshipWrapper r = new RelationshipWrapper(relationship); + Iterator keys = r.getForeignKeys().iterator(); + while (keys.hasNext()) { + String key = (String) keys.next(); + String keyProperty = config.getColumnPropertyName(tw.getTableName(), key); + Property keyProp = obj.getType().getProperty(keyProperty); + if ( keyProp == null ) + throw new RuntimeException("Invalid foreign key column: " + key); + if (fields.add(keyProp) == false) { + throw new RuntimeException("Foreign key properties should not be set when the corresponding relationship has changed"); + } + } + } + + } + } + } + + return fields; + + } + + private boolean hasState(TableWrapper tw, Relationship rel, DataObject changedObject) { + + if (!rel.isMany()) { + + RelationshipWrapper rw = new RelationshipWrapper(rel); + if ((rel.getForeignKeyTable().equals(tw.getTableName())) + && (CollectionsUtil.disjoint(tw.getPrimaryKeyProperties(), rw.getForeignKeys()))) { + return true; + } + } + + return false; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/UpdateGenerator.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/UpdateGenerator.java new file mode 100644 index 0000000000..7c353b3c57 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/UpdateGenerator.java @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.generator.impl; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.Column; +import org.apache.tuscany.das.rdb.config.Relationship; +import org.apache.tuscany.das.rdb.config.Table; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.RelationshipWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.TableWrapper; +import org.apache.tuscany.das.rdb.impl.CollisionParameter; +import org.apache.tuscany.das.rdb.impl.ManagedParameterImpl; +import org.apache.tuscany.das.rdb.impl.OptimisticWriteCommandImpl; +import org.apache.tuscany.das.rdb.impl.ParameterExtendedImpl; +import org.apache.tuscany.das.rdb.impl.SDODataTypeHelper; +import org.apache.tuscany.das.rdb.impl.UpdateCommandImpl; +import org.apache.tuscany.das.rdb.util.CollectionsUtil; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.ChangeSummary.Setting; + +public final class UpdateGenerator extends BaseGenerator { + + public static final UpdateGenerator INSTANCE = new UpdateGenerator(); + + private final Logger logger = Logger.getLogger(UpdateGenerator.class); + + private UpdateGenerator() { + super(); + } + + /*Utility to check if the given HashSet of Properties contains a property with certain name*/ + private boolean isContained(HashSet changedFields, String propertyName) { + Iterator itr = changedFields.iterator(); + while(itr.hasNext()) { + Property changedProperty = (Property)itr.next(); + if(changedProperty.getName().equals(propertyName)) { + return true; + } + } + return false; + } + + public UpdateCommandImpl getUpdateCommand(MappingWrapper mapping, DataObject changedObject, Table table) { + List parameters = new ArrayList(); + Type type = changedObject.getType(); + TableWrapper tableWrapper = new TableWrapper(table); + StringBuffer statement = new StringBuffer("update "); + if(mapping.getConfig().isDatabaseSchemaNameSupported()){ + statement.append(table.getSchemaName()+"."+table.getTableName()); + } + else{ + statement.append(table.getTableName()); + } + statement.append(" set "); + + ChangeSummary summary = changedObject.getDataGraph().getChangeSummary(); + HashSet changedFields = getChangedFields(mapping, summary, changedObject, tableWrapper); + Iterator i = changedFields.iterator(); + + int idx = 1; + while (i.hasNext()) { + Property property = (Property) i.next(); + Column c = tableWrapper.getColumnByPropertyName(property.getName()); + + if ((c == null) || !c.isCollision() || !c.isPrimaryKey()) { + String columnName = c == null ? property.getName() : c.getColumnName(); + appendFieldSet(statement, idx > 1, columnName); + parameters.add(createParameter(tableWrapper, property, idx++)); + } + } + + Column c = tableWrapper.getManagedColumn(); + if (c != null) { + appendFieldSet(statement, idx > 1, c.getColumnName()); + String propertyName = c.getPropertyName() == null ? c.getColumnName() : c.getPropertyName(); + parameters.add(createManagedParameter(tableWrapper, + changedObject.getInstanceProperty(propertyName), idx++)); + } + + statement.append(" where "); + + Iterator pkColumnNames = tableWrapper.getPrimaryKeyNames().iterator(); + Iterator pkPropertyNames = tableWrapper.getPrimaryKeyProperties().iterator(); + while (pkColumnNames.hasNext() && pkPropertyNames.hasNext()) { + String columnName = (String) pkColumnNames.next(); + String propertyName = (String) pkPropertyNames.next(); + + if(!isContained(changedFields, propertyName)) {//if PK itself is changed, don't add here, will get added below as collision parameter + statement.append(columnName); + statement.append(" = ?"); + if (pkColumnNames.hasNext() && pkPropertyNames.hasNext()) { + statement.append(" and "); + } + parameters.add(createParameter(tableWrapper, type.getProperty(propertyName), idx++)); + } + } + + if (tableWrapper.getCollisionColumn() == null) { + Iterator iter = changedFields.iterator(); + while (iter.hasNext()) { + if(statement.lastIndexOf(" where ") != statement.length()-7) + statement.append(" and "); + + Property changedProperty = (Property) iter.next(); + Column column = tableWrapper.getColumnByPropertyName(changedProperty.getName()); + statement.append(column == null ? changedProperty.getName() : column.getColumnName()); + + Object 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.append(" is null"); + } else { + ParameterExtendedImpl param = createCollisionParameter(tableWrapper, changedProperty, idx++); + statement.append(" = ?"); + param.setValue(value); + parameters.add(param); + } + + + } + + } else { + if(statement.lastIndexOf(" where ") != statement.length()-7) + statement.append(" and "); + + statement.append(tableWrapper.getCollisionColumn().getColumnName()); + statement.append(" = ?"); + parameters.add(createParameter(tableWrapper, + type.getProperty(tableWrapper.getCollisionColumnPropertyName()), idx++)); + } + + UpdateCommandImpl updateCommand = new OptimisticWriteCommandImpl(statement.toString()); + + Iterator params = parameters.iterator(); + while (params.hasNext()) { + ParameterExtendedImpl ptemp = (ParameterExtendedImpl) params.next(); + updateCommand.addParameter(ptemp); + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug(statement.toString()); + } + + return updateCommand; + } + + + + private void appendFieldSet(StringBuffer statement, boolean appendComma, String columnName) { + if (appendComma) { + statement.append(", "); + } + statement.append(columnName); + statement.append(" = ?"); + } + + + + private HashSet getChangedFields(MappingWrapper config, ChangeSummary summary, DataObject obj, TableWrapper tw) { + HashSet changes = new HashSet(); + + Iterator i = summary.getOldValues(obj).iterator(); + while (i.hasNext()) { + ChangeSummary.Setting setting = (ChangeSummary.Setting) i.next(); + + if (setting.getProperty().getType().isDataType()) { + if ( changes.add(setting.getProperty()) == false ) { + throw new RuntimeException("Foreign key properties should not be set when the corresponding relationship has changed"); + } + } else { + Property ref = setting.getProperty(); + + Relationship relationship = config.getRelationshipByReference(ref); + if ((ref.getOpposite() != null && ref.getOpposite().isMany()) + || (hasState(tw, relationship, obj))) { + RelationshipWrapper r = new RelationshipWrapper(config.getRelationshipByReference(ref)); + + Iterator keys = r.getForeignKeys().iterator(); + while (keys.hasNext()) { + String key = (String) keys.next(); + String keyProperty = config.getColumnPropertyName(tw.getTableName(), key); + Property keyProp = obj.getType().getProperty(keyProperty); + if ( keyProp == null ) { + throw new RuntimeException("Invalid foreign key column: " + key); + } + if (changes.add(keyProp) == false) { + throw new RuntimeException("Foreign key properties should not be set when the corresponding relationship has changed"); + } + } + } + } + } + return changes; + } + + private boolean hasState(TableWrapper tw, Relationship rel, DataObject changedObject) { + if (!rel.isMany()) { + RelationshipWrapper rw = new RelationshipWrapper(rel); + if ((rel.getForeignKeyTable().equals(tw.getTableName())) + && (CollectionsUtil.disjoint(tw.getPrimaryKeyProperties(), rw.getForeignKeys()))) { + return true; + } + } + + return false; + } + + private ParameterExtendedImpl fillExtendedParameter(ParameterExtendedImpl param, TableWrapper table, Property property, int idx) { + param.setName(property.getName()); + param.setType(property.getType()); + param.setConverter(getConverter(table.getConverter(property.getName()))); + if (idx != -1) { + param.setIndex(idx); + } + param.setColumnType(SDODataTypeHelper.columnTypeForSDOType(property.getType())); + return param; + } + private ParameterExtendedImpl createCollisionParameter(TableWrapper tableWrapper, Property property, int i) { + ParameterExtendedImpl param = new CollisionParameter(); + return fillExtendedParameter(param, tableWrapper, property, i); + } + + private ParameterExtendedImpl createManagedParameter(TableWrapper table, Property property, int idx) { + ParameterExtendedImpl param = new ManagedParameterImpl(); + return fillExtendedParameter(param, table, property, idx); + } + + private ParameterExtendedImpl createParameter(TableWrapper table, Property property, int idx) { + ParameterExtendedImpl param = new ParameterExtendedImpl(); + return fillExtendedParameter(param, table, property, idx); + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java new file mode 100644 index 0000000000..58e1fd3ff0 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.util.Iterator; + +import org.apache.log4j.Logger; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; + +public class DataObjectMaker { + + private final DataObject rootObject; + + private final Logger logger = Logger.getLogger(DataObjectMaker.class); + + public DataObjectMaker(DataObject root) { + this.rootObject = root; + } + + /** + * @param tableData + * @return + */ + public DataObject createAndAddDataObject(TableData tableData, ResultMetadata resultMetadata) { + // Get a Type from the package and create a standalone DataObject + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Looking for Type for " + tableData.getTableName()); + } + + Type tableClass = findTableTypeByPropertyName(tableData.getTableName()); + + if (tableClass == null) { + throw new RuntimeException("An SDO Type with name " + tableData.getTableName() + " was not found"); + } + + DataObject obj = DataFactory.INSTANCE.create(tableClass); + + // Now, check to see if the root data object has a containment reference + // to this EClass. If so, add it to the graph. If not, it will be taken + // care + // of when we process relationships + + Iterator i = this.rootObject.getType().getProperties().iterator(); + while (i.hasNext()) { + Property p = (Property) i.next(); + + if (p.isContainment() && p.getType().equals(tableClass)) { + if (p.isMany()) { + rootObject.getList(p).add(obj); + } else { + this.rootObject.set(p, obj); + } + } + + } + + Iterator columnNames = resultMetadata.getPropertyNames(tableData.getTableName()).iterator(); + while (columnNames.hasNext()) { + String propertyName = (String) columnNames.next(); + + Property p = findProperty(obj.getType(), propertyName); + if (p == null) { + throw new RuntimeException("Type " + obj.getType().getName() + + " does not contain a property named " + propertyName); + } + + Object value = tableData.getColumnData(propertyName); + + obj.set(p, value); + } + + return obj; + } + + // temporary, ignoring case + private Property findProperty(Type type, String columnName) { + Iterator properties = type.getProperties().iterator(); + while (properties.hasNext()) { + Property p = (Property) properties.next(); + if (columnName.equalsIgnoreCase(p.getName())) { + return p; + } + } + return null; + } + + private Type findTableTypeByPropertyName(String tableName) { + Iterator i = rootObject.getType().getProperties().iterator(); + while (i.hasNext()) { + Property p = (Property) i.next(); + if (tableName.equals(p.getType().getName())) { + return p.getType(); + } + } + + return null; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DefaultConverter.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DefaultConverter.java new file mode 100644 index 0000000000..a08f184b9a --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DefaultConverter.java @@ -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. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.sql.Blob; +import java.sql.SQLException; + +import org.apache.tuscany.das.rdb.Converter; + +public class DefaultConverter implements Converter { + + public DefaultConverter() { + super(); + } + + public Object getColumnValue(Object data) { + return data; + } + + public Object getPropertyValue(Object data) { + // if (type.isInstance(data)) + // return data; + // + // if ( data == null ) + // return null; + // + // String name = type.getInstanceClass().getName(); + // if (name == "java.lang.Byte" || name == "byte") { + // return new Byte(data.toString()); + // } + // + // else if (name == "java.lang.Double" || name == "double") { + // return new Double(data.toString()); + // } + // + // else if (name == "java.lang.Float" || name == "float") { + // return new Float(data.toString()); + // } + // + // else if (name == "java.lang.Integer" || name == "int") { + // return new Integer(data.toString()); + // } + // + // else if (name == "java.lang.Long" || name == "long") { + // return new Long(data.toString()); + // } + // + // else if (name == "java.lang.Short" || name == "short") { + // return new Short(data.toString()); + // } + // + // else if (name == "java.lang.String") { + // return String.valueOf(data.toString()); + // } + + if (data instanceof Blob) { + Blob b = (Blob) data; + try { + return b.getBytes(1, (int) b.length()); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + return data; + + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/GraphBuilderMetadata.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/GraphBuilderMetadata.java new file mode 100644 index 0000000000..8559b63b78 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/GraphBuilderMetadata.java @@ -0,0 +1,279 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.Relationship; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.impl.ResultSetShape; +import org.apache.tuscany.sdo.api.SDOUtil; + +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.impl.HelperProvider; + +/** + */ +public class GraphBuilderMetadata { + + private final Logger logger = Logger.getLogger(GraphBuilderMetadata.class); + + private MappingWrapper configWrapper; + + private final Collection resultSets = new ArrayList(); + + private String typeURI; + + private Type rootType; + + private HelperContext defaultHelperContext = HelperProvider.getDefaultContext(); + private HelperContext helperContext = HelperProvider.getInstance().getDefaultContext(); + + + public GraphBuilderMetadata(Collection results, Config model, ResultSetShape shape) throws SQLException { + this.configWrapper = new MappingWrapper(model); + if (model != null) { + this.typeURI = model.getDataObjectModel(); + } + + Iterator i = results.iterator(); + while (i.hasNext()) { + ResultSet rs = (ResultSet) i.next(); + ResultMetadata resultMetadata = new ResultMetadata(rs, configWrapper, shape); + resultSets.add(resultMetadata); + } + + } + + /** + * Returns the collection of ResultMetadata objects + */ + public Collection getResultMetadata() { + return this.resultSets; + } + + /** + * Returns the set of defined relationships + */ + + public Collection getRelationships() { + return configWrapper.getConfig().getRelationship(); + } + + /** + * Returns the root Type + */ + public Type getRootType() { + if (this.rootType == null) { + if (this.typeURI == null) { + createDynamicTypes(); + } else { + createDynamicRoot(); + } + } + + return this.rootType; + } + + public MappingWrapper getConfigWrapper() { + return this.configWrapper; + } + + /** + * Creates a set of SDO Types based on the query results and supplied config information + */ + + private void createDynamicTypes() { + + Type root = SDOUtil.createType(helperContext, getDefaultURI(), "DataGraphRoot", false); + if (this.logger.isDebugEnabled()) { + this.logger.debug("GBMD.createDynamicTypes():created Type for "+getDefaultURI()); + } + + Iterator iter = getResultMetadata().iterator(); + while (iter.hasNext()) { + + ResultMetadata resultMetadata = (ResultMetadata) iter.next(); + + // Create a Type for each Table represented in the ResultSet + Iterator names = resultMetadata.getAllTablePropertyNames().iterator(); + while (names.hasNext()) { + String tableName = (String) names.next(); + if (root.getProperty(tableName) == null) { + Type tableType = SDOUtil.createType(helperContext, getDefaultURI(), tableName, false); + Property property = SDOUtil.createProperty(root, tableName, tableType); + SDOUtil.setMany(property, true); + SDOUtil.setContainment(property, true); + if (this.logger.isDebugEnabled()) { + this.logger.debug("GBMD.createDynamicTypes():CREATING NEW TABLE TYPE & PROPERTY :"+tableName); + } + } + } + + // TODO tablePropertyMap is temporary until Tuscany-203 is fixed + Map tablePropertyMap = new HashMap(); + + for (int i = 1; i <= resultMetadata.getResultSetSize(); i++) { + + Property ref = root.getProperty(resultMetadata.getTablePropertyName(i)); + + if (ref == null) { + throw new RuntimeException("Could not find table " + resultMetadata.getTablePropertyName(i) + + " in the SDO model"); + } + + // TODO Temporary code to check to see if a property has already been added. + // Replace when Tuscany-203 is fixed + List addedProperties = (List) tablePropertyMap.get(ref.getName()); + if (addedProperties == null) { + addedProperties = new ArrayList(); + tablePropertyMap.put(ref.getName(), addedProperties); + } + + + + String columnName = resultMetadata.getColumnPropertyName(i); + + // TODO temporary check until Tuscany-203 is fixed + if (!addedProperties.contains(columnName)) { + addedProperties.add(columnName); + Type atype = resultMetadata.getDataType(i); + + SDOUtil.createProperty(ref.getType(), columnName, atype); + + } + + } + } + + MappingWrapper wrapper = getConfigWrapper(); + Iterator i = getRelationships().iterator(); + while (i.hasNext()) { + Relationship r = (Relationship) i.next(); + + String parentName = wrapper.getTableTypeName(r.getPrimaryKeyTable()); + String childName = wrapper.getTableTypeName(r.getForeignKeyTable()); + + if (parentName == null) { + throw new RuntimeException("The parent table (" + r.getPrimaryKeyTable() + + ") in relationship " + r.getName() + + " was not found in the mapping information."); + } else if (childName == null) { + throw new RuntimeException("The child table (" + r.getForeignKeyTable() + + ") in relationship " + r.getName() + + " was not found in the mapping information."); + } + + Property parentProperty = root.getProperty(parentName); + Property childProperty = root.getProperty(childName); + + if (parentProperty == null) { + throw new RuntimeException("The parent table (" + parentName + ") in relationship " + + r.getName() + " was not found."); + } else if (childProperty == null) { + throw new RuntimeException("The child table (" + childName + ") in relationship " + + r.getName() + " was not found."); + } + + Type parent = parentProperty.getType(); + Type child = childProperty.getType(); + + Property parentProp = SDOUtil.createProperty(parent, r.getName(), child); + Property childProp = SDOUtil.createProperty(child, r.getName() + "_opposite", parent); + SDOUtil.setOpposite(parentProp, childProp); + SDOUtil.setOpposite(childProp, parentProp); + SDOUtil.setMany(parentProp, r.isMany()); + } + + this.rootType = root; + } + + private String getDefaultURI() { + return "http:///org.apache.tuscany.das.rdb/das"; + } + + /** + * Create a dynamic root Type to act as a container Type for a set of generated Types + * + */ + private void createDynamicRoot() { + Type root = SDOUtil.createType(helperContext, getDefaultURI() + "/DataGraphRoot", "DataGraphRoot", false); + + List types = getDefinedTypes(); + + if (types == null) { + throw new RuntimeException("SDO Types have not been registered for URI " + typeURI); + } + + Iterator i = types.iterator(); + while (i.hasNext()) { + Type type = (Type) i.next(); + Property property = SDOUtil.createProperty(root, type.getName(), type); + SDOUtil.setContainment(property, true); + SDOUtil.setMany(property, true); + } + this.rootType = root; + } + + public List getDefinedTypes() { + List types = null; + List defaultTypes = null; + if (this.typeURI == null) { + types = SDOUtil.getTypes(helperContext, getDefaultURI()); + defaultTypes = SDOUtil.getTypes(defaultHelperContext, getDefaultURI()); + if(defaultTypes != null){ + if(types == null) { + types = defaultTypes; + } + else { + types.addAll(defaultTypes); + } + } + return types; + } + + types = SDOUtil.getTypes(helperContext, typeURI); + defaultTypes = SDOUtil.getTypes(defaultHelperContext, typeURI); + if(defaultTypes != null){ + if(types == null) { + types = defaultTypes; + } + else { + types.addAll(defaultTypes); + } + } + + if(rootType != null) + types.add(rootType); + return types; + + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/MultiTableRegistry.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/MultiTableRegistry.java new file mode 100644 index 0000000000..15ac74ab45 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/MultiTableRegistry.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import commonj.sdo.DataObject; + +/** + * + * Used to store and look up table objects based on primary key This could be a lot more + * efficient if we could use LinkedHashMap from JDK 1.4 + */ +public class MultiTableRegistry implements TableRegistry { + private final Logger logger = Logger.getLogger(MultiTableRegistry.class); + + private Map tableNameMap; + + private Map tableValueMap; + + public MultiTableRegistry() { + tableNameMap = new HashMap(); + tableValueMap = new HashMap(); + } + + /** + * Get the table with the specified name and primary key + * + * @param tableName + * @param primaryKey + * @return EDataObject + */ + public DataObject get(String tableName, List primaryKey) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Looking for table " + tableName + " with PK " + primaryKey); + this.logger.debug("\tReturning " + getPkMap(tableName).get(primaryKey)); + } + return (DataObject) getPkMap(tableName).get(primaryKey); + } + + /** + * Add the table with the specified name and primary key + * + * @param tableName + * @param primaryKey + * @param value + */ + public void put(String tableName, List primaryKey, DataObject value) { + if (getPkMap(tableName).put(primaryKey, value) == null) { + getCreateValueList(tableName).add(value); + } + } + + /** + * Get the HashMap that contains the primary key to table object mappings. + * + * @param tableName + * @return HashMap + */ + private Map getPkMap(String tableName) { + Map pkMap = (HashMap) tableNameMap.get(tableName); + if (pkMap == null) { + pkMap = new HashMap(); + tableNameMap.put(tableName, pkMap); + } + return pkMap; + } + + private List getCreateValueList(String tableName) { + List values = (List) tableValueMap.get(tableName); + if (values == null) { + values = new ArrayList(); + tableValueMap.put(tableName, values); + } + return values; + } + + public boolean contains(String tableName, List primaryKey) { + return get(tableName, primaryKey) == null ? false : true; + + } + + public void remove(String tableName, List primaryKey) { + getPkMap(tableName).get(primaryKey); + Map pkMap = (HashMap) tableNameMap.get(tableName); + + if(pkMap.get(primaryKey) != null) { + pkMap.remove(primaryKey); + } + + if(pkMap.size() == 0) { + tableNameMap.remove(tableName); + } + } +}
\ No newline at end of file diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultMetadata.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultMetadata.java new file mode 100644 index 0000000000..e94f3e3b3b --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultMetadata.java @@ -0,0 +1,401 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.das.rdb.Converter; +import org.apache.tuscany.das.rdb.config.Column; +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.Table; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.TableWrapper; +import org.apache.tuscany.das.rdb.impl.ResultSetShape; + +import commonj.sdo.Type; + +public class ResultMetadata { + + private Map tableToPropertyMap = new HashMap(); + + private List typeNames = new ArrayList(); + + private List propertyNames = new ArrayList(); + + private final ResultSet resultSet; + + private final ResultSetShape resultSetShape; + + private final MappingWrapper configWrapper; + + private Converter[] converters; + + private Map tableToPrimaryKeysMap = new HashMap(); + + //JIRA-952 + public ResultMetadata(ResultSet rs, MappingWrapper cfgWrapper, ResultSetShape shape) throws SQLException { + + this.resultSet = rs; + this.configWrapper = cfgWrapper; + + if (shape == null) { + this.resultSetShape = new ResultSetShape(rs.getMetaData(), configWrapper.getConfig()); + } else { + this.resultSetShape = shape; + } + + this.converters = new Converter[resultSetShape.getColumnCount()]; + + Map impliedRelationships = new HashMap(); + String schemaName = ""; + String idSpell = null; + for (int i = 1; i <= resultSetShape.getColumnCount(); i++) { + String tableName = resultSetShape.getTableName(i); + schemaName = resultSetShape.getSchemaName(i); + if (( tableName == null ) || ( tableName.equals(""))) { + throw new RuntimeException("Unable to obtain table information from JDBC. DAS configuration must specify ResultDescriptors"); + } + String typeName = null; + + if(this.configWrapper.getConfig().isDatabaseSchemaNameSupported()){ + typeName = configWrapper.getTableTypeName(schemaName+"."+tableName); + } + else{ + typeName = configWrapper.getTableTypeName(tableName); + } + String columnName = resultSetShape.getColumnName(i); + + String colName = ""; + if (columnName.regionMatches(true, columnName.length()-3, "_ID", 0, 3)) { + idSpell = columnName.substring(columnName.length()-3, columnName.length()); + if(this.configWrapper.getConfig().isDatabaseSchemaNameSupported()){ + colName = schemaName+"."+columnName; + impliedRelationships.put(colName, schemaName+"."+tableName); + } + else{ + colName = columnName; + impliedRelationships.put(colName, tableName); + } + } else if (columnName.equalsIgnoreCase("ID")) { + configWrapper.addImpliedPrimaryKey(schemaName, tableName, columnName); + } + + String propertyName = null; + + if(this.configWrapper.getConfig().isDatabaseSchemaNameSupported()){ + propertyName = configWrapper.getColumnPropertyName(schemaName+"."+tableName, columnName); + } + else{ + propertyName = configWrapper.getColumnPropertyName(tableName, columnName); + } + String converterName = null; + + if(this.configWrapper.getConfig().isDatabaseSchemaNameSupported()){ + converterName = configWrapper.getConverter(schemaName+"."+tableName, resultSetShape.getColumnName(i)); + } + else{ + converterName = configWrapper.getConverter(tableName, resultSetShape.getColumnName(i)); + } + + converters[i - 1] = loadConverter(converterName); + + typeNames.add(typeName); + propertyNames.add(propertyName); + + Collection properties = (Collection) tableToPropertyMap.get(typeName); + if (properties == null) { + properties = new ArrayList(); + } + properties.add(propertyName); + tableToPropertyMap.put(typeName, properties); + + } + + //System.out.println("tableToPropertyMap "+tableToPropertyMap); + fillTableToPrimaryKeysMap(); + + Iterator i = impliedRelationships.keySet().iterator(); + while (i.hasNext()) { + String columnName = (String) i.next(); + String pkTableName = columnName.substring(0, columnName.indexOf(idSpell));//_id, _Id, _iD, _ID anything + String fkTableName = (String) impliedRelationships.get(columnName); + List pkTableProperties = (List) tableToPropertyMap.get(pkTableName); + if ((pkTableProperties != null) && (pkTableProperties.contains("ID"))) { + configWrapper.addImpliedRelationship(pkTableName, fkTableName, columnName); + } + } + // Add any tables defined in the model but not included in the ResultSet + // to the list of propertyNames + Config model = configWrapper.getConfig(); + if (model != null) { + Iterator tablesFromModel = model.getTable().iterator(); + while (tablesFromModel.hasNext()) { + TableWrapper t = new TableWrapper((Table) tablesFromModel.next()); + if (tableToPropertyMap.get(t.getTypeName()) == null) { + tableToPropertyMap.put(t.getTypeName(), Collections.EMPTY_LIST); + } + } + } + } + + //Now fill tableToPrimaryKeysMap.Complete for whichever tables are there in tableToPrimaryKeysMap, + //Also case of implied PK and it is not there in SELECT, provide way to still fill it in + //tableToPrimaryKeysMap - the column should be present in Config (though not defed as PK) + //And consider the classic case, when we assume all columns to be PKs - when no info + //in config for table or "all columns" + private void fillTableToPrimaryKeysMap(){ + Iterator itr = tableToPropertyMap.keySet().iterator(); + while(itr.hasNext()){ + String curTableName = (String)itr.next(); + boolean treatAllPKs = false;//flag for, when all cols need to be treated as PKs + + if(tableToPrimaryKeysMap.containsKey(curTableName)){ + continue;//don't keep refilling same hashset for each ResultMetadata constructor, + } + + List columnsForTable = null; + if(configWrapper.getTableByTypeName(curTableName) != null) { + columnsForTable = configWrapper.getTableByTypeName(curTableName).getColumn(); + } + else if(configWrapper.getTable(curTableName) != null){ + columnsForTable = configWrapper.getTable(curTableName).getColumn(); + configWrapper.getTable(curTableName).setTypeName(curTableName);//keep configWrapper consistent with Type info + } + else{ + treatAllPKs = true;//can not find table/type, need to consider all columns as PKs + } + + if(columnsForTable != null){ + for(int ii=0; ii<columnsForTable.size(); ii++){ + Column curCol = (Column)columnsForTable.get(ii); + + if(curCol.isPrimaryKey() || curCol.getColumnName().equalsIgnoreCase("ID")){//need to compare col name + //with ID as that is the one from dbms metadata or resul set shape metadata + //but when putting in map, need to put property and if not present then column + Collection pks = (Collection) tableToPrimaryKeysMap.get(curTableName); + if(pks == null){ + pks = new HashSet(); + } + + if(curCol.getPropertyName() != null){ + pks.add(curCol.getPropertyName()); + } + else{ + pks.add(curCol.getColumnName()); + curCol.setPropertyName(curCol.getColumnName());//make config consistent + if(!((Collection)tableToPropertyMap.get(curTableName)).contains(curCol.getColumnName())){ + ((Collection)tableToPropertyMap.get(curTableName)).add(curCol.getColumnName()); + } + } + tableToPrimaryKeysMap.put(curTableName, pks); + } + } + } + else{ + treatAllPKs = true;//table present in cfg , but no cols + } + + if(treatAllPKs){ + tableToPrimaryKeysMap.put(curTableName, null);//case when all columns are considered PKs + } + } + } + + private Converter loadConverter(String converterName) { + if (converterName != null) { + + try { + Class converterClazz = Class.forName(converterName, true, + Thread.currentThread().getContextClassLoader()); + if (null != converterClazz) { + return (Converter) converterClazz.newInstance(); + } + + converterClazz = Class.forName(converterName); + if (converterClazz != null) { + return (Converter) converterClazz.newInstance(); + } + } catch (ClassNotFoundException ex) { + throw new RuntimeException(ex); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex); + } catch (InstantiationException ex) { + throw new RuntimeException(ex); + } + } + return new DefaultConverter(); + } + + public String getColumnPropertyName(int i) { + return (String) propertyNames.get(i - 1); + } + + public String getDatabaseColumnName(int i) { + return resultSetShape.getColumnName(i); + } + + public String getTableName(String columnName) { + return (String) typeNames.get(propertyNames.indexOf(columnName)); + } + + public int getTableSize(String tableName) { + return ((Collection) tableToPropertyMap.get(tableName)).size(); + } + + public Type getDataType(String columnName) { + return resultSetShape.getColumnType(propertyNames.indexOf(columnName)); + } + + public String getTablePropertyName(int i) { + return (String) typeNames.get(i - 1); + } + + public Collection getAllTablePropertyNames() { + return tableToPropertyMap.keySet(); + } + + public HashSet getAllPKsForTable(String tableName){ + if(tableToPrimaryKeysMap.containsKey(tableName)) + return (HashSet)tableToPrimaryKeysMap.get(tableName); + else{ + HashSet tmpHashSet = new HashSet(); + tmpHashSet.add("");//case when there were cols in cfg but could not find any PK in it and no ID column in cfg/result set + return tmpHashSet; + } + + } + + public String toString() { + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (Table Names: "); + Iterator i = typeNames.iterator(); + while (i.hasNext()) { + String tableName = (String) i.next(); + result.append(' '); + result.append(tableName); + result.append(','); + } + + result.append(" columnNames: "); + + i = propertyNames.iterator(); + while (i.hasNext()) { + String columnName = (String) i.next(); + result.append(' '); + result.append(columnName); + result.append(','); + } + + result.append(" mappingModel: "); + result.append(this.configWrapper.getConfig()); + + result.append(" resultSet: "); + result.append(resultSet); + + result.append(" resultSetSize: "); + result.append(resultSetShape.getColumnCount()); + result.append(')'); + return result.toString(); + + } + + /** + * @return + */ + public int getNumberOfTables() { + return tableToPropertyMap.keySet().size(); + } + + /** + * Return whether the column at the given position is part of a primary key. + * If we don't have this information, we assume every column is a primary + * key. This results in uniqueness checks using all columns in a table. + * + * @param i + * @return + */ + public boolean isPKColumn(int i) { + + Table t = configWrapper.getTableByTypeName(getTablePropertyName(i)); + if (t == null) { + return true; + } + + // If no Columns have been defined, consider every column to be part of + // the PK + if (t.getColumn().isEmpty()) { + return true; + } + + Column c = configWrapper.getColumn(t, getDatabaseColumnName(i)); + + if (c == null) { + return false; + } + + if (c.isPrimaryKey()) { + return true; + } + + return false; + } + + /** + * @param i + * @return Type + */ + public Type getDataType(int i) { + return resultSetShape.getColumnType(i); + } + + /** + * @param tableName + * @return Collection + */ + public Collection getPropertyNames(String tableName) { + return (Collection) tableToPropertyMap.get(tableName); + } + + public ResultSet getResultSet() { + return this.resultSet; + } + + public int getResultSetSize() { + return resultSetShape.getColumnCount(); + } + + public boolean isRecursive() { + return configWrapper.hasRecursiveRelationships(); + } + + public Converter getConverter(int i) { + return converters[i - 1]; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetProcessor.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetProcessor.java new file mode 100644 index 0000000000..7722c3c4fd --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetProcessor.java @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Iterator; + +import org.apache.log4j.Logger; + +import commonj.sdo.DataObject; + +/** + * + * A ResultSetProcessor is used to transform the data in a ResultSet into a set of inter-related EDataObjects. + */ +public class ResultSetProcessor { + private final Logger logger = Logger.getLogger(ResultSetProcessor.class); + + private TableRegistry registry; + + private GraphBuilderMetadata metadata; + + private final DataObjectMaker doMaker; + + public ResultSetProcessor(DataObject g, GraphBuilderMetadata gbmd) { + + this.metadata = gbmd; + if (metadata.getRelationships().size() == 0) { + registry = new SingleTableRegistry(); + } else { + registry = new MultiTableRegistry(); + } + + doMaker = new DataObjectMaker(g); + + if (this.logger.isDebugEnabled()) { + this.logger.debug(metadata); + } + + } + + /** + * Process the ResultSet. For each row in the ResultSet, a + * + * @link ResultSetRow object will be created to represent the row as a set of EDataObjects. Then, + * the relevant relationships will be constructed + * between each object in the + * @link ResultSetRow. + * + * @param start + * @param end + */ + public void processResults(int start, int end) throws SQLException { + + Iterator i = metadata.getResultMetadata().iterator(); + while (i.hasNext()) { + ResultMetadata resultMetadata = (ResultMetadata) i.next(); + ResultSet results = resultMetadata.getResultSet(); + + processResultSet(results, resultMetadata, start, end); + + // TODO These statements HAVE to be closed or we will have major problems + // results.getStatement().close(); + results.close(); + } + + } + + private void processResultSet(ResultSet rs, ResultMetadata rsMetadata, int start, int end) throws SQLException { + + if (rs.getType() == ResultSet.TYPE_FORWARD_ONLY) { + while (rs.next() && start < end) { + ResultSetRow rsr = new ResultSetRow(rs, rsMetadata); + addRowToGraph(rsr, rsMetadata); + ++start; + } + } else { + while (rs.absolute(start) && start < end) { + ResultSetRow rsr = new ResultSetRow(rs, rsMetadata); + addRowToGraph(rsr, rsMetadata); + ++start; + } + } + } + + /** + * @param row + * @param resultMetadata + */ + private void addRowToGraph(ResultSetRow row, ResultMetadata resultMetadata) { + RowObjects tableObjects = new RowObjects(metadata, registry); + Iterator tables = row.getAllTableData().iterator(); + while (tables.hasNext()) { + TableData rawDataFromRow = (TableData) tables.next(); + + if (!rawDataFromRow.hasValidPrimaryKey() || + (rawDataFromRow.hasNullPrimaryKey() && !rawDataFromRow.isTableEmpty())) {//some PK null , but other data present + //continue; - need to throw exception as anyway the result will give a wrong impression + //when any one table in result set misses PK column or has null value in PK column + throw new RuntimeException("Table "+rawDataFromRow.getTableName()+" in query does not include Primary Key "+ + "column or has null value in it, can not proceed!"); + } + + String tableName = rawDataFromRow.getTableName(); + DataObject tableObject = registry.get(tableName, rawDataFromRow.getPrimaryKeyValues()); + if (tableObject == null + && !rawDataFromRow.hasNullPrimaryKey()) {//2nd check for null data in PK, + //as TableData.addData() - hasValidPrimaryKey=false is commented for a reason + //with this, DataObjs with null PK will not be added to registry and tableObjects + tableObject = doMaker.createAndAddDataObject(rawDataFromRow, resultMetadata); + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Putting table " + tableName + " with PK " + + rawDataFromRow.getPrimaryKeyValues() + " into registry"); + } + + registry.put(tableName, rawDataFromRow.getPrimaryKeyValues(), tableObject); + } + else{ + if (this.logger.isDebugEnabled()) { + this.logger.debug("Not Null tableObject or NULL PK"); + } + } + + if(tableObject != null){ + if (this.logger.isDebugEnabled()) { + this.logger.debug("Do not allow any Null tableObject in tableObjects"); + } + tableObjects.put(tableName, tableObject); + } + } + + tableObjects.processRelationships(); + + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetRow.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetRow.java new file mode 100644 index 0000000000..a44713b677 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetRow.java @@ -0,0 +1,264 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +/** + * + * A ResultSetRow is used to transform a single row of a ResultSet into a set of EDataObjects. + */ +public class ResultSetRow { + private final Logger logger = Logger.getLogger(ResultSetRow.class); + + private final ResultMetadata metadata; + + private Map tableMap = new HashMap(); + + private List allTableData; + + /** + * Method ResultSetRow. + * + * @param rs + * A ResultSet positioned on the desired row + * @param ePackage + * The package used to create EDataObjects + */ + public ResultSetRow(ResultSet rs, ResultMetadata m) throws SQLException { + this.metadata = m; + if (m.isRecursive()) { + processRecursiveRow(rs); + } else { + processRow(rs); + } + } + + /** + * Processes a single row in the ResultSet Method processRow. + * + * @param rs + */ + private void processRow(ResultSet rs) throws SQLException { + + if (this.logger.isDebugEnabled()) { + this.logger.debug(""); + } + for (int i = 1; i <= metadata.getResultSetSize(); i++) { + Object data = getObject(rs, i); + + TableData table = getRawData(metadata.getTablePropertyName(i)); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Adding column: " + metadata.getColumnPropertyName(i) + "\tValue: " + + data + "\tTable: " + + metadata.getTablePropertyName(i)); + } + table.addData(metadata.getColumnPropertyName(i), metadata.isPKColumn(i), data); + } + + checkResultSetMissesPK(); + } + + //get all table names involved in current result set + //can not use metadata.getAllTablePropertyNames() + //as it gives table names for all tables from Config + public Collection getAllTableNamesForRS(){ + Collection allTableNamesForRS = new HashSet(); + for (int i = 1; i <= metadata.getResultSetSize(); i++) { + allTableNamesForRS.add(metadata.getTablePropertyName(i)); + } + return allTableNamesForRS; + } + + //case when result set omits PK column, take care of compound PKs too + public void checkResultSetMissesPK(){ + boolean tableRSHasPK; + Collection allTableNames = getAllTableNamesForRS(); + Iterator itr = allTableNames.iterator(); + while(itr.hasNext()){ + tableRSHasPK = false; + String currentTableName = (String)itr.next(); + HashSet pks = metadata.getAllPKsForTable(currentTableName); + HashSet pksInRS = new HashSet(); + for(int j=1; j<=metadata.getResultSetSize(); j++){ + if(currentTableName.equals(metadata.getTablePropertyName(j)) && + metadata.isPKColumn(j) ){ + pksInRS.add(metadata.getColumnPropertyName(j)); + } + } + + //if pks null, means its classic case when all cols should be PKs + if(pks == null){ + tableRSHasPK = true; + } + //case when there were cols in cfg but could not find any PK in it and no ID column in cfg + else if(pks != null && pks.size()==1 && pks.contains("")){ + tableRSHasPK = false; + } + else if(pks != null && pksInRS.size() == pks.size()){ + Iterator itr1 = pks.iterator(); + int indx=0; + while(itr1.hasNext()){ + if(!pksInRS.contains((String)itr1.next())){ + indx++; + } + } + + if(indx == 0){ + if (this.logger.isDebugEnabled()) { + this.logger.debug("has PK TRUE - matched"); + } + tableRSHasPK = true; + }else{ + if (this.logger.isDebugEnabled()) { + this.logger.debug("has PK FALSE- mismatched"); + } + tableRSHasPK = false; + } + } + else{ + if (this.logger.isDebugEnabled()) { + this.logger.debug("has PK FALSE - rest all cases"); + } + } + + //Default is TRUE(from TableData), so consider only FALSE case + if(!tableRSHasPK){ + TableData table = getRawData(currentTableName); + table.setValidPrimaryKey(tableRSHasPK); + } + } + + //for testing + if (this.logger.isDebugEnabled()) { + for (int i = 1; i <= metadata.getResultSetSize(); i++) { + TableData table = getRawData(metadata.getTablePropertyName(i)); + this.logger.debug("table "+table.getTableName()+" hasValidPK "+table.hasValidPrimaryKey()); + } + } + } + + public void processRecursiveRow(ResultSet rs) throws SQLException { + this.allTableData = new ArrayList(); + int i = 1; + + while (i <= metadata.getResultSetSize()) { + TableData table = new TableData(metadata.getTablePropertyName(i)); + this.allTableData.add(table); + + while ((i <= metadata.getResultSetSize()) && (metadata.isPKColumn(i))) { + Object data = getObject(rs, i); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Adding column: " + metadata.getColumnPropertyName(i) + + "\tValue: " + data + "\tTable: " + + metadata.getTablePropertyName(i)); + } + table.addData(metadata.getColumnPropertyName(i), true, data); + i++; + } + + while ((i <= metadata.getResultSetSize()) && (!metadata.isPKColumn(i))) { + Object data = getObject(rs, i); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Adding column: " + metadata.getColumnPropertyName(i) + + "\tValue: " + data + "\tTable: " + + metadata.getTablePropertyName(i)); + } + table.addData(metadata.getColumnPropertyName(i), false, data); + i++; + } + } + + checkResultSetMissesPK(); + } + + /** + * @param rs + * @param metadata + * @param i + * @return + */ + private Object getObject(ResultSet rs, int i) throws SQLException { + + Object data = rs.getObject(i); + + if (rs.wasNull()) { + return null; + } + + return metadata.getConverter(i).getPropertyValue(data); + + } + + /** + * Returns a HashMap that holds data for the specified table + * + * @param tableName + * The name of the table + * @return HashMap + */ + public TableData getTable(String tableName) { + return (TableData) tableMap.get(tableName); + } + + /** + * Returns a HashMap that holds data for the specified table If the HashMap + * doesn't exist, it will be created. This is used internally to build + * the ResultSetRow, whereas getTable is used externally to retrieve existing table data. + * + * @param tableName + * The name of the table + * @return HashMap + */ + private TableData getRawData(String tableName) { + + TableData table = (TableData) tableMap.get(tableName); + + if (table == null) { + table = new TableData(tableName); + tableMap.put(tableName, table); + } + + return table; + } + + public List getAllTableData() { + if (this.allTableData == null) { + this.allTableData = new ArrayList(); + this.allTableData.addAll(tableMap.values()); + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug(allTableData); + } + + return this.allTableData; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/RowObjects.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/RowObjects.java new file mode 100644 index 0000000000..c7f200cb1e --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/RowObjects.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.KeyPair; +import org.apache.tuscany.das.rdb.config.Relationship; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; + +public class RowObjects { + private final Logger logger = Logger.getLogger(RowObjects.class); + + private Map objectsByTableName; + + private List tableObjects; + + private final GraphBuilderMetadata metadata; + + private final TableRegistry registry; + + public RowObjects(GraphBuilderMetadata metadata, TableRegistry registry) { + objectsByTableName = new HashMap(); + tableObjects = new ArrayList(); + this.metadata = metadata; + this.registry = registry; + } + + public void put(String key, DataObject value) { + objectsByTableName.put(key, value); + tableObjects.add(value); + } + + public DataObject get(String tablePropertyName) { + return (DataObject) objectsByTableName.get(tablePropertyName); + } + + void processRelationships() { + MappingWrapper wrapper = metadata.getConfigWrapper(); + if (wrapper.hasRecursiveRelationships()) { + processRecursiveRelationships(wrapper); + return; + } + + Iterator i = metadata.getRelationships().iterator(); + while (i.hasNext()) { + Relationship r = (Relationship) i.next(); + + DataObject parentTable = get(wrapper.getTableTypeName(r.getPrimaryKeyTable())); + DataObject childTable = get(wrapper.getTableTypeName(r.getForeignKeyTable())); + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Parent table: " + parentTable); + this.logger.debug("Child table: " + childTable); + } + if ((parentTable == null) || (childTable == null)) { + continue; + } + + Property p = parentTable.getType().getProperty(r.getName()); + setOrAdd(parentTable, childTable, p); + + } + } + + private void processRecursiveRelationships(MappingWrapper wrapper) { + Iterator i = tableObjects.iterator(); + while (i.hasNext()) { + DataObject table = (DataObject) i.next(); + + Iterator relationships = wrapper.getRelationshipsByChildTable(table.getType().getName()).iterator(); + while (relationships.hasNext()) { + Relationship r = (Relationship) relationships.next(); + + DataObject parentTable = findParentTable(table, r, wrapper); + + if (parentTable == null) { + continue; + } + + Property p = parentTable.getType().getProperty(r.getName()); + setOrAdd(parentTable, table, p); + } + + } + } + + private void setOrAdd(DataObject parent, DataObject child, Property p) { + if (p.isMany()) { + parent.getList(p).add(child); + } else { + parent.set(p, child); + } + } + + private DataObject findParentTable(DataObject childTable, Relationship r, MappingWrapper wrapper) { + + List fkValue = new ArrayList(); + Iterator keyPairs = r.getKeyPair().iterator(); + while (keyPairs.hasNext()) { + KeyPair pair = (KeyPair) keyPairs.next(); + String childProperty = wrapper.getColumnPropertyName(r.getPrimaryKeyTable(), pair.getForeignKeyColumn()); + + Property p = childTable.getType().getProperty(childProperty); + fkValue.add(childTable.get(p)); + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Trying to find parent of " + r.getForeignKeyTable() + " with FK " + fkValue); + } + + DataObject parentTable = registry.get(r.getPrimaryKeyTable(), fkValue); + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Parent table from registry: " + parentTable); + } + + return parentTable; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/SingleTableRegistry.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/SingleTableRegistry.java new file mode 100644 index 0000000000..54474fa4b3 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/SingleTableRegistry.java @@ -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. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.util.List; + +import commonj.sdo.DataObject; + +public class SingleTableRegistry implements TableRegistry { + + + public SingleTableRegistry() { + // Empty Constructor + } + + public DataObject get(String tableName, List primaryKey) { + return null; + } + + + public void put(String tableName, List primaryKey, DataObject value) { + // do nothing + + } + + public boolean contains(String name, List list) { + return false; + } + + public void remove(String tableName, List primaryKey) { + + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableData.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableData.java new file mode 100644 index 0000000000..f74370f003 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableData.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +public class TableData { + private final Logger logger = Logger.getLogger(TableData.class); + + private Map columnData = new HashMap(); + + private List primaryKey = new ArrayList(); + + private final String name; + + private boolean hasValidPrimaryKey = true; + + private boolean hasNullPrimaryKey = false; + + public TableData(String tableName) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Creating TableData for table " + tableName); + } + + this.name = tableName; + } + + public void addData(String columnName, boolean isPrimaryKeyColumn, Object data) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Adding column " + columnName + " with value " + data); + } + + if(data != null) + columnData.put(columnName, data); + if (isPrimaryKeyColumn) { + if (data == null) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Column " + columnName + " is a primary key column and is null"); + } + //hasValidPrimaryKey = false; - if uncommented and JIRA-1464, RecursiveTests.testReadEngineParts() will fail + } + if(data != null){ + primaryKey.add(data); + } + else{ + hasNullPrimaryKey = true; + } + } + } + + public Object getColumnData(String columnName) { + return columnData.get(columnName); + } + + public String getTableName() { + return this.name; + } + + /** + * @return + */ + public List getPrimaryKeyValues() { + return primaryKey; + } + + public boolean hasValidPrimaryKey() { + return hasValidPrimaryKey; + } + + public void setValidPrimaryKey(boolean hasValidPK){ + this.hasValidPrimaryKey = hasValidPK; + } + + public boolean isTableEmpty(){ + return columnData.keySet().isEmpty(); + } + + public boolean hasNullPrimaryKey(){ + return this.hasNullPrimaryKey; + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableRegistry.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableRegistry.java new file mode 100644 index 0000000000..7a433fe240 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableRegistry.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.impl; + +import java.util.List; + +import commonj.sdo.DataObject; + +public interface TableRegistry { + /** + * Get the table with the specified name and primary key + * + * @param tableName + * @param primaryKey + * @return DataObject + */ + DataObject get(String tableName, List primaryKey); + + /** + * Add the table with the specified name and primary key + * + * @param tableName + * @param primaryKey + * @param value + */ + void put(String tableName, List primaryKey, DataObject value); + + boolean contains(String name, List list); + + void remove(String tableName, List primaryKey); +}
\ No newline at end of file diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/schema/ResultSetTypeMap.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/schema/ResultSetTypeMap.java new file mode 100644 index 0000000000..35701f88d0 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/schema/ResultSetTypeMap.java @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.graphbuilder.schema; + +import java.sql.Types; + +import org.apache.tuscany.sdo.SDOPackage; + +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; + +/** + */ +public class ResultSetTypeMap { + + public static final ResultSetTypeMap INSTANCE = new ResultSetTypeMap(); + + /** + * Constructor for ResultSetTypeMap. + */ + protected ResultSetTypeMap() { + // Empty Constructor + } + + /** + * + * @param type + * @param isNullable + * @return + */ + public Type getEDataType(int type, boolean isNullable) { + + TypeHelper helper = TypeHelper.INSTANCE; + SDOPackage.eINSTANCE.eClass(); + switch (type) { + + case Types.CHAR: + case Types.VARCHAR: + case Types.LONGVARCHAR: + return helper.getType("commonj.sdo", "String"); + + case Types.NUMERIC: + case Types.DECIMAL: + return helper.getType("commonj.sdo", "Decimal"); + + case Types.BIT: + case Types.BOOLEAN: + if (isNullable) { + return helper.getType("commonj.sdo", "Boolean"); + } + return helper.getType("commonj.sdo", "boolean"); + + + case Types.TINYINT: + case Types.SMALLINT: + case Types.INTEGER: + if (isNullable) { + return helper.getType("commonj.sdo", "IntObject"); + } + + return helper.getType("commonj.sdo", "Int"); + + + case Types.BIGINT: + if (isNullable) { + return helper.getType("commonj.sdo", "Long"); + } + return helper.getType("commonj.sdo", "long"); + + case Types.REAL: + if (isNullable) { + return helper.getType("commonj.sdo", "Float"); + } + return helper.getType("commonj.sdo", "float"); + + + case Types.FLOAT: + case Types.DOUBLE: + if (isNullable) { + return helper.getType("commonj.sdo", "Double"); + } + return helper.getType("commonj.sdo", "double"); + + + case Types.BINARY: + case Types.VARBINARY: + case Types.LONGVARBINARY: + return helper.getType("commonj.sdo", "Bytes"); + + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + return helper.getType("commonj.sdo", "Date"); + + case Types.CLOB: + return helper.getType("commonj.sdo", "Object"); + + case Types.BLOB: + return helper.getType("commonj.sdo", "Bytes"); + + case Types.ARRAY: + return helper.getType("commonj.sdo", "Object"); + + case Types.DISTINCT: + case Types.STRUCT: + case Types.REF: + case Types.DATALINK: + case Types.JAVA_OBJECT: + return helper.getType("commonj.sdo", "Object"); + + default: + return helper.getType("commonj.sdo", "Object"); + } + + } + + public Type getType(int columnType, boolean b) { + return getEDataType(columnType, b); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ApplyChangesCommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ApplyChangesCommandImpl.java new file mode 100644 index 0000000000..b19aab85e8 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ApplyChangesCommandImpl.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.sql.Connection; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; + +import commonj.sdo.DataObject; + +/** + * + */ +public class ApplyChangesCommandImpl extends BaseCommandImpl { + + private final Logger logger = Logger.getLogger(ApplyChangesCommandImpl.class); + + private ChangeSummarizer summarizer = new ChangeSummarizer(); + + public ApplyChangesCommandImpl(MappingWrapper config, Connection connection) { + this.configWrapper = config; + if (connection != null) { + setConnection(connection, config.getConfig()); + } + + } + + public void setConnection(ConnectionImpl connection) { + summarizer.setConnection(connection); + } + + public void execute(DataObject root) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Executing ApplyChangesCmd"); + } + + if (summarizer.getConnection() == null) { + throw new RuntimeException("A connection must be provided"); + } + + if (!root.equals(root.getDataGraph().getRootObject())) { + throw new RuntimeException("'root' argument must be the root of the datagraph"); + } + + summarizer.setMapping(configWrapper); + + Changes changes = summarizer.loadChanges(root); + + boolean success = false; + try { + changes.execute(); + success = true; + } finally { + if (success) { + summarizer.getConnection().cleanUp(); + } else { + summarizer.getConnection().errorCleanUp(); + } + } + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/BaseCommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/BaseCommandImpl.java new file mode 100644 index 0000000000..e6611e0a7f --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/BaseCommandImpl.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.sql.Connection; + +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; + +public abstract class BaseCommandImpl { + protected MappingWrapper configWrapper = new MappingWrapper(); + + //when no config in method params, useGetGeneratedKeys will default to True + //as DBMS metadata method is not reliable in all cases + public void setConnection(Connection connection) { + setConnection(new ConnectionImpl(connection)); + } + + public void setConnection(Connection connection, Config config) { + boolean managed = true; + String generatedKeysSupported = null; + + if (config != null){ + if(config.getConnectionInfo() != null) { + managed = config.getConnectionInfo().isManagedtx(); + } + + generatedKeysSupported = config.getGeneratedKeysSupported(); + + setConnection(connection, managed, generatedKeysSupported); + } + else{ + setConnection(connection); + } + } + + public void setConnection(Connection connection, boolean manageTransaction, String generatedKeysSupported) { + ConnectionImpl c = new ConnectionImpl(connection); + c.setManageTransactions(manageTransaction); + c.setGeneratedKeysSupported(generatedKeysSupported); + setConnection(c); + } + + public abstract void setConnection(ConnectionImpl c); + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeFactory.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeFactory.java new file mode 100644 index 0000000000..c348eae54e --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeFactory.java @@ -0,0 +1,177 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.Create; +import org.apache.tuscany.das.rdb.config.Delete; +import org.apache.tuscany.das.rdb.config.Table; +import org.apache.tuscany.das.rdb.config.Update; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.TableWrapper; +import org.apache.tuscany.das.rdb.generator.impl.DeleteGenerator; +import org.apache.tuscany.das.rdb.generator.impl.InsertGenerator; +import org.apache.tuscany.das.rdb.generator.impl.UpdateGenerator; + +import commonj.sdo.DataObject; + +public class ChangeFactory { + private final Logger logger = Logger.getLogger(ChangeFactory.class); + + private InsertCommandImpl createCommand; + + private UpdateCommandImpl updateCommand; + + private DeleteCommandImpl deleteCommand; + + private final MappingWrapper mapping; + + private final ConnectionImpl connection; + + public ChangeFactory(MappingWrapper mapping, ConnectionImpl connection) { + this.mapping = mapping; + this.connection = connection; + } + + public void setCreateCommand(InsertCommandImpl cmd) { + createCommand = cmd; + } + + public void setUpdateCommand(UpdateCommandImpl cmd) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Setting Update Command to " + cmd); + } + + updateCommand = cmd; + } + + public void setDeleteCommand(DeleteCommandImpl cmd) { + deleteCommand = cmd; + } + + ChangeOperation createUpdateOperation(DataObject changedObject, String propagatedID) { + return new UpdateOperation(getUpdateCommand(changedObject), changedObject, propagatedID); + } + + ChangeOperation createUpdateOperation(DataObject changedObject) { + return createUpdateOperation(changedObject, null); + } + + ChangeOperation createDeleteOperation(DataObject changedObject) { + return new DeleteOperation(getDeleteCommand(changedObject), changedObject); + } + + ChangeOperation createInsertOperation(DataObject changedObject, String propagatedID) { + return new CreateOperation(getCreateCommand(changedObject), changedObject, propagatedID); + } + + private InsertCommandImpl getCreateCommand(DataObject changedObject) { + + if (createCommand == null) { + Table table = mapping.getTableByTypeName(changedObject.getType().getName()); + if (table == null) { + if (changedObject.getType().getProperty("ID") != null) { + // If the table is not defined in the config, assume it has a primary key of "ID" + mapping.addPrimaryKey(changedObject.getType().getName() + ".ID"); + table = mapping.getTableByTypeName(changedObject.getType().getName()); + } else { + throw new RuntimeException("Table " + changedObject.getType().getName() + + " was changed in the DataGraph but is not present in the Config"); + } + } + + Create create = table.getCreate(); + + if (create == null) { + createCommand = InsertGenerator.INSTANCE.getInsertCommand(mapping, changedObject, table); + } else { + createCommand = new InsertCommandImpl(create); + } + createCommand.setConnection(connection); + createCommand.configWrapper = mapping; + } + return createCommand; + } + + private DeleteCommandImpl getDeleteCommand(DataObject changedObject) { + + if (deleteCommand == null) { + Table table = mapping.getTableByTypeName(changedObject.getType().getName()); + if (table == null) { + if (changedObject.getType().getProperty("ID") != null) { + // If the table is not defined in the config, assume it has a primary key of "ID" + mapping.addPrimaryKey(changedObject.getType().getName() + ".ID"); + table = mapping.getTableByTypeName(changedObject.getType().getName()); + } else { + throw new RuntimeException("Table " + changedObject.getType().getName() + + " was changed in the DataGraph but is not present in the Config"); + } + } + + Delete delete = table.getDelete(); + + if (delete == null) { + deleteCommand = DeleteGenerator.INSTANCE.getDeleteCommand(mapping, table);//JIRA-952 + } else { + deleteCommand = new DeleteCommandImpl(delete); + } + deleteCommand.setConnection(connection); + deleteCommand.configWrapper = mapping; + } + return deleteCommand; + } + + private UpdateCommandImpl getUpdateCommand(DataObject changedObject) { + + Table table = mapping.getTableByTypeName(changedObject.getType().getName()); + if (table == null) { + if (changedObject.getType().getProperty("ID") != null) { + mapping.addPrimaryKey(changedObject.getType().getName() + ".ID"); + table = mapping.getTableByTypeName(changedObject.getType().getName()); + } else { + throw new RuntimeException("Table " + changedObject.getType().getName() + + " was changed in the DataGraph but is not present in the Config"); + } + } + Update update = table.getUpdate(); + if (update == null) { + updateCommand = UpdateGenerator.INSTANCE.getUpdateCommand(mapping, changedObject, table); + } else { + TableWrapper t = new TableWrapper(table); + if (t.getCollisionColumn() != null) { + updateCommand = new OptimisticWriteCommandImpl(update); + } else { + updateCommand = new UpdateCommandImpl(update); + } + } + updateCommand.setConnection(connection); + updateCommand.configWrapper = mapping; + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Returning updateCommand: " + updateCommand); + } + + return updateCommand; + } + + public MappingWrapper getConfig() { + return this.mapping; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeOperation.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeOperation.java new file mode 100644 index 0000000000..b222c18177 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeOperation.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.Iterator; + +import org.apache.log4j.Logger; + +import commonj.sdo.DataObject; + +/** + */ +public abstract class ChangeOperation { + protected DatabaseObject dObject; + + protected String propagatedID; + + private final Logger logger = Logger.getLogger(ChangeOperation.class); + + private final WriteCommandImpl writeCommand; + + private boolean isInsert; + + + public ChangeOperation(DeleteCommandImpl command) { + writeCommand = command; + } + + public ChangeOperation(InsertCommandImpl command, DataObject changedObject) { + writeCommand = command; + dObject = new DatabaseObject(command.getMappingModel(), changedObject); + this.isInsert = true; + } + + public ChangeOperation(UpdateCommandImpl command, DataObject changedObject) { + writeCommand = command; + dObject = new DatabaseObject(command.getMappingModel(), changedObject); + } + + public void execute() { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Executing change operation"); + } + + Iterator i = writeCommand.getParameters().iterator(); + while (i.hasNext()) { + ParameterExtendedImpl parm = (ParameterExtendedImpl) i.next(); + + if (this.logger.isDebugEnabled()) { + this.logger.debug("setting " + parm.getName() + " to " + dObject.get(parm.getName())); + } + + parm.setValue(dObject.get(parm.getName())); + } + + writeCommand.basicExecute(); + + if (isInsert && (propagatedID != null)) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Propagating key " + propagatedID); + } + int id = writeCommand.getGeneratedKey(); + dObject.setPropagatedID(propagatedID, id); + } + } + + public String getTableName() { + return dObject.getTableName(); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeSummarizer.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeSummarizer.java new file mode 100644 index 0000000000..5131819b69 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeSummarizer.java @@ -0,0 +1,252 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.config.Column; +import org.apache.tuscany.das.rdb.config.Relationship; +import org.apache.tuscany.das.rdb.config.Table; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.RelationshipWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.TableWrapper; +import org.apache.tuscany.das.rdb.util.CollectionsUtil; +import org.apache.tuscany.sdo.impl.ChangeSummaryImpl; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +public class ChangeSummarizer { + + private final Logger logger = Logger.getLogger(ChangeSummarizer.class); + + private Changes changes = new Changes(); + + private FactoryRegistry registry; + + private MappingWrapper mapping = new MappingWrapper(); + + private ConnectionImpl connection; + + private Map generatedKeys = new HashMap(); + + public ChangeSummarizer() { + // Empty Constructor + } + + public Changes loadChanges(DataObject root) { + ChangeSummary changeSummary = root.getDataGraph().getChangeSummary(); + if (changeSummary.isLogging()) { + ((ChangeSummaryImpl) changeSummary).summarize(); + } + + List changedObjects = changeSummary.getChangedDataObjects(); + + if (this.logger.isDebugEnabled()) { + this.logger.debug("List of changed objects contains " + changedObjects.size() + " object(s)"); + } + + changes.setInsertOrder(mapping.getInsertOrder()); + changes.setDeleteOrder(mapping.getDeleteOrder()); + + Iterator i = changedObjects.iterator(); + while (i.hasNext()) { + DataObject o = (DataObject) i.next(); + + if (!(o.equals(root))) { + createChange(changeSummary, o); + } + } + + return changes; + } + + public void createChange(ChangeSummary changeSummary, DataObject changedObject) { + + if (changeSummary.isCreated(changedObject)) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Change is a create"); + } + if (!changeSummary.isDeleted(changedObject)) { + ChangeFactory factory = getRegistry().getFactory(changedObject.getType()); + String propagatedID = (String) generatedKeys.get(changedObject.getType().getName()); + changes.addInsert(factory.createInsertOperation(changedObject, propagatedID)); + } + } else if (changeSummary.isDeleted(changedObject)) { + ChangeFactory factory = getRegistry().getFactory(changedObject.getType()); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Change is a delete"); + } + changes.addDelete(factory.createDeleteOperation(changedObject)); + } else { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Change is a modify"); + } + List attrList = changeSummary.getOldValues(changedObject); + if (hasAttributeChange(attrList)) { + ChangeFactory factory = getRegistry().getFactory(changedObject.getType()); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Attribute Change for " + changedObject.getType().getName()); + } + String propagatedID = (String) generatedKeys.get(changedObject.getType().getName()); + changes.addUpdate(factory.createUpdateOperation(changedObject, propagatedID)); + } else { + List values = changeSummary.getOldValues(changedObject); + Iterator i = values.iterator(); + while (i.hasNext()) { + ChangeSummary.Setting setting = (ChangeSummary.Setting) i.next(); + if (!setting.getProperty().getType().isDataType()) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Reference change for " + changedObject.getType().getName()); + } + Property ref = setting.getProperty(); + if (this.logger.isDebugEnabled()) { + this.logger.debug(ref.getName()); + } + if (hasState(ref, changedObject)) { + ChangeFactory factory = getRegistry().getFactory(changedObject.getType()); + changes.addUpdate(factory.createUpdateOperation(changedObject)); + } + } + } + } + } + + } + + private boolean hasState(Property ref, DataObject changedObject) { + if (ref.getOpposite().isMany()) { + return true; + } + + MappingWrapper mw = this.mapping; + if (mw.getConfig() == null) { + mw = registry.getFactory(changedObject.getType()).getConfig(); + } + if (mw.getConfig() == null) { + return false; + } + + Relationship rel = mw.getRelationshipByReference(ref); + + if (!rel.isMany()) { + if (rel.isKeyRestricted()) { + throw new RuntimeException("Can not modify a one to one relationship that is key restricted"); + } + // This is a one-one relationship + Table t = mapping.getTableByTypeName(changedObject.getType().getName()); + TableWrapper tw = new TableWrapper(t); + RelationshipWrapper rw = new RelationshipWrapper(rel); + if ((rel.getForeignKeyTable().equals(t.getTableName())) + && (CollectionsUtil.disjoint(tw.getPrimaryKeyProperties(), rw.getForeignKeys()))) { + return true; + } + + } + + return false; + } + + private boolean hasAttributeChange(List theChanges) { + Iterator i = theChanges.iterator(); + while (i.hasNext()) { + ChangeSummary.Setting setting = (ChangeSummary.Setting) i.next(); + if (setting.getProperty().getType().isDataType()) { + return true; + } + } + return false; + } + + public void addCreateCommand(Type type, Command cmd) { + ChangeFactory cf = getRegistry().getFactory(type); + cf.setCreateCommand((InsertCommandImpl) cmd); + ((CommandImpl) cmd).setConnection(connection); + } + + public void addUpdateCommand(Type type, Command cmd) { + ChangeFactory cf = getRegistry().getFactory(type); + cf.setUpdateCommand((UpdateCommandImpl) cmd); + ((CommandImpl) cmd).setConnection(connection); + } + + public void addDeleteCommand(Type type, Command cmd) { + ChangeFactory cf = getRegistry().getFactory(type); + cf.setDeleteCommand((DeleteCommandImpl) cmd); + ((CommandImpl) cmd).setConnection(connection); + + } + + private FactoryRegistry getRegistry() { + if (this.registry == null) { + this.registry = new FactoryRegistry(mapping, connection); + } + return this.registry; + } + + public void setConnection(ConnectionImpl connection) { + this.connection = connection; + } + + public void setMapping(MappingWrapper map) { + this.mapping = map; + + if (mapping.getConfig() == null) { + return; + } + + Iterator i = mapping.getConfig().getTable().iterator(); + while (i.hasNext()) { + Table t = (Table) i.next(); + Iterator columns = t.getColumn().iterator(); + while (columns.hasNext()) { + Column c = (Column) columns.next(); + if (c.isPrimaryKey() && c.isGenerated()) { + //if SDO type, property is defined use it , else use dbms metadata + //with this static DOs will work correct for generated keys + if(t.getTypeName() != null && c.getPropertyName() != null) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("adding generated key " + t.getTypeName() + "." + c.getPropertyName()); + } + + generatedKeys.put(t.getTypeName(), c.getPropertyName()); + } else { + if (this.logger.isDebugEnabled()) { + this.logger.debug("adding generated key " + t.getTableName() + "." + c.getColumnName()); + } + + generatedKeys.put(t.getTableName(), c.getColumnName()); + } + + } + } + } + } + + public ConnectionImpl getConnection() { + return this.connection; + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Changes.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Changes.java new file mode 100644 index 0000000000..53c8c4ee04 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Changes.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.Iterator; +import java.util.List; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.XMLHelper; + +/** + * Manages a set of graph-change operations. This simple implementaiton can be + * replaced with a version that provides R/I sorting + * + */ +public class Changes { + + private InsertList inserts = new InsertList(); + + private UpdateList updates = new UpdateList(); + + private DeleteList deletes = new DeleteList(); + + public void addInsert(ChangeOperation c) { + inserts.add(c); + } + + public void addUpdate(ChangeOperation c) { + updates.add(c); + } + + public void addDelete(ChangeOperation c) { + deletes.add(c); + } + + /** + * Execute all my change + */ + public void execute() { + + Iterator i = deletes.getSortedList().iterator(); + while (i.hasNext()) { + ChangeOperation c = (ChangeOperation) i.next(); + c.execute(); + } + + i = inserts.getSortedList().iterator(); + while (i.hasNext()) { + ChangeOperation c = (ChangeOperation) i.next(); + c.execute(); + } + + i = updates.getSortedList().iterator(); + while (i.hasNext()) { + ChangeOperation c = (ChangeOperation) i.next(); + c.execute(); + } + + } + + public void setInsertOrder(List insertOrder) { + inserts.setOrder(insertOrder); + } + + public void setDeleteOrder(List deleteOrder) { + deletes.setOrder(deleteOrder); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CollisionParameter.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CollisionParameter.java new file mode 100644 index 0000000000..48ff2ab57a --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CollisionParameter.java @@ -0,0 +1,31 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.rdb.impl;
+
+public class CollisionParameter extends ParameterExtendedImpl {
+
+ private boolean isSet;
+
+ public void setValue(Object value) {
+ if (!isSet) {
+ this.value = value;
+ isSet = true;
+ }
+ }
+}
diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CommandImpl.java new file mode 100644 index 0000000000..841e0f17d6 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CommandImpl.java @@ -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. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.das.rdb.Command; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.XSDHelper; + +public abstract class CommandImpl extends BaseCommandImpl implements Command { + + protected Statement statement; + + protected ParametersExtendedImpl parameters = new ParametersExtendedImpl(); + + protected ResultSetShape resultSetShape; + + public CommandImpl(String sqlString) { + statement = new Statement(sqlString); + } + + public CommandImpl(org.apache.tuscany.das.rdb.config.Command command) { + this(command.getSQL()); + + if(command.getParameter() != null && command.getParameter().size() > 0) { + Iterator itr = command.getParameter().iterator(); + int index = 1; + while(itr.hasNext()){ + org.apache.tuscany.das.rdb.config.impl.ParameterImpl param = (org.apache.tuscany.das.rdb.config.impl.ParameterImpl)itr.next(); + if(param.getIndex() <= 0){ + param.setIndex(index); + index++; + } + ParameterExtendedImpl paramExt = new ParameterExtendedImpl(param); + addToParameters(paramExt); + } + } + } + + private void addToParameters(ParameterExtendedImpl paramExt) { + this.parameters.getParameter().add(paramExt); + if(paramExt.getDirection().equals(ParameterExtendedImpl.IN)){ + parameters.getInParameters().add(paramExt); + } + else{ + parameters.getOutParameters().add(paramExt); + } + } + + public abstract void execute(); + + public abstract DataObject executeQuery(); + + public void setParameter(int index, Object value) { + ParameterExtendedImpl param = parameters.getParameter(index); + if(param != null){ + param.setValue(value); + return; + } + + param = new ParameterExtendedImpl(); + param.setIndex(index); + param.setValue(value); + param.setDirection(ParameterExtendedImpl.IN); + parameters.getParameter().add(param); + parameters.getInParameters().add(param); + } + + public void addParameter(ParameterExtendedImpl param) { + //eliminate/replace duplicate params, index is filled, so can check it for duplicate + ParameterExtendedImpl paramExt = parameters.getParameter(param.getIndex()); + if(paramExt != null) + paramExt = new ParameterExtendedImpl(param); + + paramExt = parameters.getParameter(param.getIndex(), param.getDirection()); + if(paramExt != null){ + paramExt = new ParameterExtendedImpl(param); + return; + } + + addToParameters(param); + } + + public List getParameters() { + return parameters.getParameter(); + } + + public Object getParameter(int index) { + return parameters.getParameter(index).getValue(); + } + + public void setConnection(ConnectionImpl connection) { + statement.setConnection(connection); + } + + protected ConnectionImpl getConnection() { + return statement.getConnection(); + } + + /* + * The default impl is to throw an exception. This is overridden by InsertCommandImpl + */ + public int getGeneratedKey() { + + throw new RuntimeException("This method is only valid for insert commands"); + } + + public void close() { + statement.close(); + } + + //default direction IN assumed + public void setParameter(String name, Object value) { + ParameterExtendedImpl param = parameters.getParameter(name); + if(param != null){ + param.setValue(value); + return; + } + + param = new ParameterExtendedImpl(); + param.setIndex(parameters.getParameter().size()+1); + param.setName(name); + param.setValue(value); + param.setDirection(ParameterExtendedImpl.IN); + parameters.getParameter().add(param); + parameters.getInParameters().add(param); + } + + //default direction IN assumed + public Object getParameter(String name) { + Iterator itr = this.parameters.getInParameters().iterator(); + while(itr.hasNext()){ + ParameterExtendedImpl param = ((ParameterExtendedImpl)itr.next()); + + if(param.getName() != null && param.getName().equalsIgnoreCase(name)){ + return param.value; + } + } + return null; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ConnectionImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ConnectionImpl.java new file mode 100644 index 0000000000..5ee465027d --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ConnectionImpl.java @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import org.apache.log4j.Logger; + +public class ConnectionImpl { + + private final Logger logger = Logger.getLogger(ConnectionImpl.class); + + private Connection connection; + + private boolean managingTransaction = true; + + private String generatedKeysSupported = null; + + public ConnectionImpl(Connection connection) { + this.connection = connection; + + try { + if (connection.getAutoCommit()) { + throw new RuntimeException("AutoCommit must be off"); + } + } catch (SQLException e) { + throw new RuntimeException(e); + } + + } + + public Connection getJDBCConnection() { + return connection; + } + + public String getGeneratedKeysSupported() { + return this.generatedKeysSupported; + } + + public void setGeneratedKeysSupported(String useGetGeneratedKeys){ + this.generatedKeysSupported = useGetGeneratedKeys; + } + + public boolean isGeneratedKeysSupported() { + try{ + if(this.generatedKeysSupported == null){ + DatabaseMetaData dbmsMetadata = this.connection.getMetaData(); + boolean supportsGetGeneratedKeys = dbmsMetadata.supportsGetGeneratedKeys(); + if(supportsGetGeneratedKeys){ + this.generatedKeysSupported = "true"; + } + //currently DERBY partially supports this feature and thus returns FALSE, + //this hardcoding is needed as the partial support is enough for DAS + //we can remove this later, when DERBY change the behaviour of it's "supportsGetGeneratedKeys" + else if(dbmsMetadata.getDatabaseProductName().indexOf("Derby") > 0){ + this.generatedKeysSupported = "true"; + } + else{ + this.generatedKeysSupported = "false"; + } + } + }catch(Exception e){//can be from supportsGetGeneratedKeys or due to absense of supportsGetGeneratedKeys + if (this.logger.isDebugEnabled()) { + this.logger.debug("exception setiing useGetGeneratedKeys false"); + } + this.generatedKeysSupported = "false"; + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug("returning useGetGeneratedKeys():"+ this.generatedKeysSupported); + } + return Boolean.valueOf(this.generatedKeysSupported).booleanValue(); + } + + public void cleanUp() { + try { + if (managingTransaction) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Committing Transaction"); + } + connection.commit(); + } + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + public void errorCleanUp() { + try { + if (managingTransaction) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Rolling back Transaction"); + } + connection.rollback(); + } + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + public PreparedStatement prepareStatement(String queryString, String[] returnKeys) throws SQLException { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Preparing Statement: " + queryString); + this.logger.debug("Boolean value for use gen key: " + this.generatedKeysSupported); + } + + if (isGeneratedKeysSupported()) { + return connection.prepareStatement(queryString, Statement.RETURN_GENERATED_KEYS); + } else if (returnKeys.length > 0) { + return connection.prepareStatement(queryString, returnKeys); + } + + return connection.prepareStatement(queryString); + } + + public PreparedStatement preparePagedStatement(String queryString) throws SQLException { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Preparing Statement: " + queryString); + } + + return connection.prepareStatement(queryString, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + } + + public void setManageTransactions(boolean manageTransactions) { + managingTransaction = manageTransactions; + + } + + public CallableStatement prepareCall(String queryString) throws SQLException { + return connection.prepareCall(queryString); + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CreateOperation.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CreateOperation.java new file mode 100644 index 0000000000..0163f96686 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/CreateOperation.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import commonj.sdo.DataObject; + +public class CreateOperation extends ChangeOperation { + + public CreateOperation(InsertCommandImpl command, DataObject changedObject, String id) { + super(command, changedObject); + this.propagatedID = id; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASFactoryImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASFactoryImpl.java new file mode 100644 index 0000000000..ba80b3bcb5 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASFactoryImpl.java @@ -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. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.io.InputStream; +import java.sql.Connection; + +import org.apache.tuscany.das.rdb.DAS; +import org.apache.tuscany.das.rdb.DASFactory; +import org.apache.tuscany.das.rdb.config.Config; + +public class DASFactoryImpl implements DASFactory { + + public DAS createDAS(InputStream configStream) { + return new DASImpl(configStream); + } + + public DAS createDAS(Config config) { + return new DASImpl(config); + } + + public DAS createDAS(InputStream configStream, Connection connection) { + return new DASImpl(configStream, connection); + } + + public DAS createDAS(Config config, Connection connection) { + return new DASImpl(config, connection); + } + + public DAS createDAS(Connection connection) { + return new DASImpl(connection); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java new file mode 100644 index 0000000000..e456d65ef1 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java @@ -0,0 +1,327 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; + +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.DAS; +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.ConfigFactory; +import org.apache.tuscany.das.rdb.config.ConnectionInfo; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.exception.DataSourceInitializationException; +import org.apache.tuscany.das.rdb.util.ConfigUtil; + +import commonj.sdo.DataObject; + +/** + * An ConfiguredCommandFactory produces instances of Command and ApplyChangesCommand. This + * factory is initialized with a configuration that defines + * the commands it produces. + * + */ +public class DASImpl implements DAS { + + private MappingWrapper configWrapper; + + private Connection connection; + + private Map commands = new HashMap(); + + public DASImpl(InputStream stream) { + this(ConfigUtil.loadConfig(stream)); + + } + + public DASImpl(Config inConfig) { + Config cfg = inConfig; + if (cfg == null) { + cfg = ConfigFactory.INSTANCE.createConfig(); + } + this.configWrapper = new MappingWrapper(cfg); + + Iterator i = configWrapper.getConfig().getCommand().iterator(); + while (i.hasNext()) { + org.apache.tuscany.das.rdb.config.Command commandConfig = + (org.apache.tuscany.das.rdb.config.Command) i.next(); + String kind = commandConfig.getKind(); + if (kind.equalsIgnoreCase("select")) { + commands.put(commandConfig.getName(), new ReadCommandImpl(commandConfig, configWrapper, commandConfig.getResultDescriptor())); + } else if (kind.equalsIgnoreCase("update")) { + commands.put(commandConfig.getName(), new UpdateCommandImpl(commandConfig)); + } else if (kind.equalsIgnoreCase("insert")) { + commands.put(commandConfig.getName(), new InsertCommandImpl(commandConfig, new String[0])); + } else if (kind.equalsIgnoreCase("delete")) { + commands.put(commandConfig.getName(), new DeleteCommandImpl(commandConfig)); + } else if (kind.equalsIgnoreCase("procedure")) { + commands.put(commandConfig.getName(), new SPCommandImpl(commandConfig.getSQL(), configWrapper, commandConfig.getParameter())); + } else { + throw new RuntimeException("Invalid kind of command: " + kind); + } + + } + + } + + public DASImpl(Config inConfig, Connection inConnection) { + this(inConfig); + setConnection(inConnection); + } + + public DASImpl(InputStream configStream, Connection inConnection) { + this(ConfigUtil.loadConfig(configStream), inConnection); + } + + public DASImpl(Connection inConnection) { + this(ConfigFactory.INSTANCE.createConfig()); + setConnection(inConnection); + } + + /* + * (non-Javadoc) + * + * @see org.apache.tuscany.das.rdb.CommandGroup#getApplyChangesCommand() + */ + public ApplyChangesCommandImpl getApplyChangesCommand() { + ApplyChangesCommandImpl cmd = new ApplyChangesCommandImpl(configWrapper, getConnection()); + return cmd; + } + + /* + * (non-Javadoc) + * + * @see org.apache.tuscany.das.rdb.CommandGroup#getCommand(java.lang.String) + */ + public Command getCommand(String name) { + if (!commands.containsKey(name)) { + throw new RuntimeException("CommandGroup has no command named: " + name); + } + CommandImpl cmd = (CommandImpl) commands.get(name); + cmd.setConnection(getConnection(), configWrapper.getConfig()); + return cmd; + } + + public void setConnection(Connection connection) { + this.connection = connection; + } + + public Connection getConnection() { + if (connection == null) { + initializeConnection(); + } + return connection; + } + + private void initializeConnection() { + Config config = configWrapper.getConfig(); + if (config == null || config.getConnectionInfo() == null || + (config.getConnectionInfo().getDataSource() == null && + (config.getConnectionInfo().getConnectionProperties() == null || config.getConnectionInfo().getConnectionProperties().getDatabaseURL() == null + || config.getConnectionInfo().getConnectionProperties().getDriverClass() == null)) ) { + throw new RuntimeException("No connection has been provided and no data source has been specified"); + } + + if(config.getConnectionInfo().getDataSource() != null && + (config.getConnectionInfo().getConnectionProperties() != null && config.getConnectionInfo().getConnectionProperties().getDatabaseURL() != null) ){ + throw new RuntimeException("Use either dataSource or databaseURL. Can't use both !"); + } + + ConnectionInfo connectionInfo = configWrapper.getConfig().getConnectionInfo(); + if(config.getConnectionInfo().getDataSource() != null){ + initializeDatasourceConnection(connectionInfo); + }else{ + initializeDriverManagerConnection(connectionInfo); + } + + } + + /** + * Initializes a DB connection on a managed environmet (e.g inside Tomcat) + */ + private void initializeDatasourceConnection(ConnectionInfo connectionInfo){ + Connection connection = null; + + InitialContext ctx; + try { + ctx = new InitialContext(); + } catch (NamingException e) { + throw new RuntimeException(e); + } + try { + DataSource ds = (DataSource) ctx.lookup(connectionInfo.getDataSource()); + try { + try { + if(connectionInfo.getConnectionProperties() != null && + connectionInfo.getConnectionProperties().getUserName() != null && + connectionInfo.getConnectionProperties().getPassword() != null ) { + connection = ds.getConnection(connectionInfo.getConnectionProperties().getUserName(), connectionInfo.getConnectionProperties().getPassword()); + } else { + connection = ds.getConnection(); + } + }catch(Exception e) { + connection = ds.getConnection(); + } + + if (connection == null) { + throw new RuntimeException("Could not obtain a Connection from DataSource"); + } + connection.setAutoCommit(false); + setConnection(connection); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + /** + * Initialize a DB connection on a J2SE environment + * For more info, see http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/drivermanager.html + */ + private void initializeDriverManagerConnection(ConnectionInfo connectionInfo) { + + Connection connection = null; + + if (connectionInfo.getConnectionProperties() == null) { + throw new DataSourceInitializationException("No existing context and no connection properties"); + } + + if (connectionInfo.getConnectionProperties().getDriverClass() == null) { + throw new DataSourceInitializationException("No jdbc driver class specified!"); + } + + try { + //initialize driver and register it with DriverManager + Class.forName(connectionInfo.getConnectionProperties().getDriverClass()); + + //prepare to initialize connection + String databaseUrl = connectionInfo.getConnectionProperties().getDatabaseURL(); + String userName = connectionInfo.getConnectionProperties().getUserName(); + String userPassword = connectionInfo.getConnectionProperties().getPassword(); + int loginTimeout = connectionInfo.getConnectionProperties().getLoginTimeout(); + + DriverManager.setLoginTimeout(loginTimeout); + if( (userName == null || userName.length() ==0) && (userPassword == null || userPassword.length()==0) ){ + //no username or password suplied + connection = DriverManager.getConnection(databaseUrl); + }else{ + connection = DriverManager.getConnection(databaseUrl, userName, userPassword); + } + + if(connection == null){ + throw new DataSourceInitializationException("Error initializing connection : null"); + } + + connection.setAutoCommit(false); + setConnection(connection); + + + }catch(ClassNotFoundException cnf){ + throw new DataSourceInitializationException("JDBC Driver '" + connectionInfo.getConnectionProperties().getDriverClass() + "' not found", cnf); + }catch(SQLException sqle){ + throw new DataSourceInitializationException(sqle.getMessage(), sqle); + } + + } + + public void releaseResources() { + + if (managingConnections()) { + closeConnection(); + } + } + + private void closeConnection() { + if (connection != null) { + try { + connection.close(); + connection = null; + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + } + + /** + * If the config has connection properties then we are "managing" the connection via DataSource + */ + private boolean managingConnections() { + + if (configWrapper.getConfig().getConnectionInfo().getDataSource() == null) { + return false; + } + + return true; + + } + + public Command createCommand(String sql) { + return baseCreateCommand(sql, this.configWrapper); + } + + public Command createCommand(String sql, Config config) { + return baseCreateCommand(sql, new MappingWrapper(config)); + } + + private Command baseCreateCommand(String inSql, MappingWrapper config) { + CommandImpl returnCmd = null; + String sql = inSql.trim(); // Remove leading white space + char firstChar = Character.toUpperCase(sql.charAt(0)); + switch (firstChar) { + case 'S': + returnCmd = new ReadCommandImpl(sql, config, null); + break; + case 'I': + returnCmd = new InsertCommandImpl(sql, new String[0]); + break; + case 'U': + returnCmd = new UpdateCommandImpl(sql); + break; + case 'D': + returnCmd = new DeleteCommandImpl(sql); + break; + case '{': + returnCmd = new SPCommandImpl(sql, config, Collections.EMPTY_LIST); + break; + default: + throw new RuntimeException("SQL => " + sql + " is not valid"); + } + + returnCmd.setConnection(getConnection(), config.getConfig()); + return returnCmd; + } + + public void applyChanges(DataObject root) { + getApplyChangesCommand().execute(root); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DatabaseObject.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DatabaseObject.java new file mode 100644 index 0000000000..18a6d8d193 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DatabaseObject.java @@ -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. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.Column; +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.KeyPair; +import org.apache.tuscany.das.rdb.config.Relationship; +import org.apache.tuscany.das.rdb.config.Table; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.TableWrapper; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; + +/** + * DatabaseObject wraps DataObject. If a field is an FK field, it will return the value from the parent. + * + * + */ +public class DatabaseObject { + + private final Logger logger = Logger.getLogger(DatabaseObject.class); + + private final MappingWrapper mappingWrapper; + + private final DataObject dataObject; + + private Property parentReference; + + private Map keyMappings = new HashMap(); + + public DatabaseObject(Config model, DataObject changedObject) { + this.mappingWrapper = new MappingWrapper(model); + this.dataObject = changedObject; + initialize(); + } + + // Initialize Key Mappings + private void initialize() { + if (mappingWrapper.getConfig() != null) { + List relationships = mappingWrapper.getConfig().getRelationship(); + Iterator i = relationships.iterator(); + while (i.hasNext()) { + Relationship r = (Relationship) i.next(); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Initializing relationship: " + r.getName()); + this.logger.debug("r.getForeignKeyTable():"+r.getForeignKeyTable()); + this.logger.debug("getTypeName():"+getTypeName()); + } + + Table fkTable = mappingWrapper.getTableByTypeName(getTypeName()); + String fkTableName = null; + if(fkTable != null) { + if(mappingWrapper.getConfig().isDatabaseSchemaNameSupported()) { + fkTableName = fkTable.getSchemaName()+"."+fkTable.getTableName(); + } else { + fkTableName = fkTable.getTableName(); + } + } else {//this can happen when no <Table> in Config and Query based Dynamic Types are used during query + fkTableName = getTypeName(); + } + + if (r.getForeignKeyTable().equals(fkTableName)) { + List pairs = r.getKeyPair(); + Iterator iter = pairs.iterator(); + while (iter.hasNext()) { + KeyPair pair = (KeyPair) iter.next(); + keyMappings.put(pair.getForeignKeyColumn(), r); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Putting key pair: " + pair.getPrimaryKeyColumn()+","+pair.getForeignKeyColumn()); + } + } + } + } + } + } + + public Object get(String parameter) { + if (isPartOfPrimaryKey(parameter)) { + return dataObject.get(parameter); + } + + Relationship r = (Relationship) keyMappings.get(parameter); + if (r == null) { + return dataObject.get(parameter); + } + + //JIRA-952 + Table tbl = this.mappingWrapper.getTable(r.getPrimaryKeyTable()); + Property parentRef = null; + if(tbl == null){ + //this is case when config file is not present and + //ConfigHelper helper = new ConfigHelper(); is used + parentRef = getParentReference(r.getPrimaryKeyTable()); + } + else{ + //other cases, its better to use typeName as r.getPrimaryKeyTable() + //gives tableName and tableName and typeName can be different + //and SDO looks for typeName and not tableName. + parentRef = getParentReference((new TableWrapper(tbl)).getTypeName()); + } + + DataObject parent = dataObject.getDataObject(parentRef); + + if (parent == null) { + return null; + } + String parentKey = getParentKey(r, parameter);//parentKey is db column name + + String parentTableName = null; + //as parentKey is qualified column name and not SDO property name, do conversion, when possible, thru <Config><Table> + tbl = mappingWrapper.getTableByTypeName(parent.getType().getName()); + if(tbl != null) { + if(mappingWrapper.getConfig().isDatabaseSchemaNameSupported()) { + parentTableName = tbl.getSchemaName()+"."+tbl.getTableName(); + } else { + parentTableName = tbl.getTableName(); + } + String parentKeyProp = mappingWrapper.getColumnPropertyName(parentTableName, parentKey); + + return parent.get(parentKeyProp); + } else { + return parent.get(parentKey); + } + } + + /*This returns table column name*/ + private String getParentKey(Relationship r, String parameter) { + List keyPairs = r.getKeyPair(); + Iterator i = keyPairs.iterator(); + while (i.hasNext()) { + KeyPair pair = (KeyPair) i.next(); + if (pair.getForeignKeyColumn().equals(parameter)) { + return pair.getPrimaryKeyColumn(); + } + } + return null; + } + + public Property getParentReference(String parentName) { + if (this.parentReference == null) { + Iterator i = dataObject.getType().getProperties().iterator(); + while (i.hasNext()) { + Property ref = (Property) i.next(); + if ((!ref.getType().isDataType()) && (ref.getType().getName().equals(parentName))) { + this.parentReference = ref; + } + } + } + return this.parentReference; + } + + //JIRA-952 + public String getTableName() { + if (mappingWrapper.getConfig() != null) { + + if(mappingWrapper.getConfig().isDatabaseSchemaNameSupported()){ + if (this.logger.isDebugEnabled()) { + this.logger.debug("DatabaseObject.getTableName:(schemaName.tableName) " + + mappingWrapper.getTableByTypeName(getTypeName()).getSchemaName()+"."+ + mappingWrapper.getTableByTypeName(getTypeName()).getTableName()); + } + + return (mappingWrapper.getTableByTypeName(getTypeName()).getSchemaName()+"."+ + mappingWrapper.getTableByTypeName(getTypeName()).getTableName()); + } + else{ + if (this.logger.isDebugEnabled()) { + this.logger.debug("DatabaseObject.getTableName: " + mappingWrapper.getTableByTypeName(getTypeName()).getTableName()); + } + + return mappingWrapper.getTableByTypeName(getTypeName()).getTableName(); + } + } + return null; + } + + public String getTypeName() { + if (this.logger.isDebugEnabled()) { + this.logger.debug("DatabaseObject.getTypeName: " + dataObject.getType().getName()); + } + return dataObject.getType().getName(); + } + + public void setPropagatedID(String propagatedID, int id) { + dataObject.setInt(propagatedID, id); + } + + private boolean isPartOfPrimaryKey(String parameter) { + if (mappingWrapper.getConfig() == null) { + return false; + } + + Table t = mappingWrapper.getTable(getTableName()); + if (t == null) { + return false; + } + Column c = mappingWrapper.getColumnByPropertyName(t, parameter); + if (c == null) { + return false; + } + + return c.isPrimaryKey(); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DeleteCommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DeleteCommandImpl.java new file mode 100644 index 0000000000..ca85569272 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DeleteCommandImpl.java @@ -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. + */ +package org.apache.tuscany.das.rdb.impl; + +import org.apache.tuscany.das.rdb.config.Delete; + +public class DeleteCommandImpl extends WriteCommandImpl { + public DeleteCommandImpl(org.apache.tuscany.das.rdb.config.Command command) { + super(command); + } + + public DeleteCommandImpl(String sqlString) { + super(sqlString); + } + + public DeleteCommandImpl(Delete delete) { + super(delete.getSql()); + this.addParameters(delete.getParameters()); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DeleteList.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DeleteList.java new file mode 100644 index 0000000000..feb7e31411 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DeleteList.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * DeleteList will sort delete operations so that child objects are deleted before their parents + * + * + */ +public class DeleteList { + + private Map opsByTableName = new HashMap(); + + private List order; + + private List deleteOperations = new ArrayList(); + + public DeleteList() { + super(); + } + + public void add(ChangeOperation op) { + if ((order.size() == 0) || (op.getTableName() == null)) { + deleteOperations.add(op); + } else { + String name = op.getTableName(); + List ops = (List) opsByTableName.get(name); + if (ops == null) { + ops = new ArrayList(); + } + ops.add(op); + opsByTableName.put(name, ops); + } + } + + public Collection getSortedList() { + if ((order.size() > 0) && (opsByTableName.keySet().size() > 0)) { + Iterator i = this.order.iterator(); + while (i.hasNext()) { + String name = (String) i.next(); + if (opsByTableName.get(name) != null) { + deleteOperations.addAll((Collection) opsByTableName.get(name)); + } + } + } + + return deleteOperations; + } + + public void setOrder(List deleteOrder) { + this.order = deleteOrder; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DeleteOperation.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DeleteOperation.java new file mode 100644 index 0000000000..52935599c1 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DeleteOperation.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import org.apache.tuscany.das.rdb.util.DataObjectUtil; + +import commonj.sdo.DataObject; + +public class DeleteOperation extends ChangeOperation { + + /** + * @param command + * @param changedObject + * Objects deleted from the graph have lost their "settings" and must be restored + */ + public DeleteOperation(DeleteCommandImpl command, DataObject changedObject) { + super(command); + this.dObject = new DatabaseObject(command.getMappingModel(), DataObjectUtil.getRestoredCopy(changedObject)); + + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/FactoryRegistry.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/FactoryRegistry.java new file mode 100644 index 0000000000..bb148635c8 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/FactoryRegistry.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; + +import commonj.sdo.Type; + +public class FactoryRegistry { + + private final Logger logger = Logger.getLogger(FactoryRegistry.class); + + private Map registry = new HashMap(); + + private final MappingWrapper mapping; + + private final ConnectionImpl connection; + + public FactoryRegistry(MappingWrapper mapping, ConnectionImpl connection) { + this.mapping = mapping; + this.connection = connection; + } + + public ChangeFactory getFactory(Type type) { + ChangeFactory factory = (ChangeFactory) registry.get(type); + if (factory == null) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Creating new ChangeFactory for type " + type.getName()); + } + + factory = new ChangeFactory(mapping, connection); + registry.put(type, factory); + } + return factory; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/InsertCommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/InsertCommandImpl.java new file mode 100644 index 0000000000..61967475bd --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/InsertCommandImpl.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.sql.SQLException; + +import org.apache.tuscany.das.rdb.config.Create; + +public class InsertCommandImpl extends WriteCommandImpl { + + private String[] keys; + + public InsertCommandImpl(org.apache.tuscany.das.rdb.config.Command command, String[] generatedKeys) { + super(command); + keys = generatedKeys; + } + + public InsertCommandImpl(String sqlString, String[] generatedKeys) { + super(sqlString); + keys = generatedKeys; + } + + public InsertCommandImpl(Create create) { + super(create.getSql()); + this.addParameters(create.getParameters()); + this.keys = new String[0]; + } + + public void execute() { + + boolean success = false; + try { + statement.executeUpdate(parameters, keys); + success = true; + } catch (SQLException e) { + throw new RuntimeException(e); + } finally { + if (success) { + statement.getConnection().cleanUp(); + } else { + statement.getConnection().errorCleanUp(); + } + } + + } + + public int getGeneratedKey() { + try { + Integer key = statement.getGeneratedKey(); + if(key != null) + return key.intValue(); + else + throw new RuntimeException("Could not obtain generated key!"); + } catch (SQLException ex) { + throw new RuntimeException(ex); + } + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/InsertList.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/InsertList.java new file mode 100644 index 0000000000..e61ccfe21e --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/InsertList.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +/** + * InsertList will sort ChangeOperation objects so that parents are inserted before children + * + * + */ +public class InsertList { + private final Logger logger = Logger.getLogger(InsertList.class); + + private Map opsByTableName = new HashMap(); + + private List insertOperations = new ArrayList(); + + private List order; + + public void add(ChangeOperation op) { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Adding insert operation "); + } + + // If nothing has been added yet, or this is no ordering, simply + // add the operation to the list + if ((order.size() == 0) || (op.getTableName() == null)) { + insertOperations.add(op); + } else { + String name = op.getTableName(); + List ops = (List) opsByTableName.get(name); + if (ops == null) { + ops = new ArrayList(); + } + + ops.add(op); + opsByTableName.put(name, ops); + } + } + + public Collection getSortedList() { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Getting sorted insert list"); + } + + if ((order.size() > 0) && opsByTableName.keySet().size() > 0) { + Iterator i = this.order.iterator(); + while (i.hasNext()) { + String name = (String) i.next(); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Adding operations for table " + name); + } + + // A null here means a table is in the config but hasn't been changed here + if (opsByTableName.get(name) != null) { + insertOperations.addAll((Collection) opsByTableName.get(name)); + } + } + } + if (this.logger.isDebugEnabled()) { + this.logger.debug("Returning " + insertOperations.size() + " insert operations"); + } + + return insertOperations; + } + + public void setOrder(List insertOrder) { + this.order = insertOrder; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ManagedParameterImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ManagedParameterImpl.java new file mode 100644 index 0000000000..f2f3ccdd79 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ManagedParameterImpl.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.math.BigDecimal; + +public class ManagedParameterImpl extends ParameterExtendedImpl { + + public void setValue(Object oldValue) { + this.value = updateValue(oldValue); + } + + private Object updateValue(Object oldValue) { + if (oldValue instanceof Integer) { + return new Integer(((Integer) oldValue).intValue() + 1); + } else if (oldValue instanceof BigDecimal) { + return ((BigDecimal) oldValue).add(new BigDecimal(1)); + } else { + throw new RuntimeException("Unsupported type for managed column: " + oldValue.getClass().getName()); + } + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/OptimisticWriteCommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/OptimisticWriteCommandImpl.java new file mode 100644 index 0000000000..0a5f6951e9 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/OptimisticWriteCommandImpl.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.sql.SQLException; + +import org.apache.tuscany.das.rdb.config.Update; +import org.apache.tuscany.das.rdb.exception.OptimisticConcurrencyException; + +public class OptimisticWriteCommandImpl extends UpdateCommandImpl { + + public OptimisticWriteCommandImpl(String sqlString) { + super(sqlString); + } + + public OptimisticWriteCommandImpl(Update update) { + super(update); + addParameters(update.getParameters()); + } + + public void basicExecute() { + try { + int rowsAffected = statement.executeUpdate(parameters); + if (rowsAffected == 0) { + throw new OptimisticConcurrencyException("An update collision occurred"); + } + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/PagerImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/PagerImpl.java new file mode 100644 index 0000000000..27b653763b --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/PagerImpl.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.Pager; + +import commonj.sdo.DataObject; + +public class PagerImpl implements Pager { + + private final ReadCommandImpl command; + + private final int size; + + private int idx = 1; + + public PagerImpl(Command command, int size) { + this.command = (ReadCommandImpl) command; + this.command.enablePaging(); + this.size = size; + } + + public DataObject next() { + int start = idx; + int end = idx + size; + idx += size; + command.setStartRow(start); + command.setEndRow(end); + return command.executeQuery(); + } + + public DataObject getPage(int page) { + int end = (page * size) + 1; + int start = end - size; + idx = end; + command.setStartRow(start); + command.setEndRow(end); + return command.executeQuery(); + } + + public DataObject previous() { + int start = idx - (2 * size); + if (start < 1) { + start = 1; + } + int end = start + size; + idx = end; + command.setStartRow(start); + command.setEndRow(end); + return command.executeQuery(); + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ParameterExtendedImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ParameterExtendedImpl.java new file mode 100644 index 0000000000..ccb42edc78 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ParameterExtendedImpl.java @@ -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. + */ +package org.apache.tuscany.das.rdb.impl; + +import org.apache.tuscany.das.rdb.Converter; +import org.apache.tuscany.das.rdb.config.impl.ParameterImpl; +import commonj.sdo.Type; + +public class ParameterExtendedImpl extends ParameterImpl{ + /** + * Value for "Direction" that indicates that a parameter is soley for input. + */ + static final String IN = "IN"; + + /** + * Value for "Direction" that indicates that a parameter is soley for output. + * Out parameters only apply to Stored Procedures + */ + static final String OUT = "OUT"; + + /** + * Value for "Direction" that indicates that a parameter is for both input and output. + * In-out parameters only apply to stored procedures + */ + static final String IN_OUT = "IN_OUT"; + + private Type type; + + protected Object value; + + private Converter converter; + + public ParameterExtendedImpl() { + super(); + this.direction = IN; + } + + public ParameterExtendedImpl(org.apache.tuscany.das.rdb.config.impl.ParameterImpl parameterImpl) { + this.columnType = parameterImpl.getColumnType(); + this.direction = parameterImpl.getDirection(); + this.index = parameterImpl.getIndex(); + this.name = parameterImpl.getName(); + } + + public void setType(Type type) { + this.type = type; + } + + public Type getType() { + return this.type; + } + + public void setColumnType(String newColumnType) { + super.setColumnType(newColumnType); + if(newColumnType != null){ + String arg0 = newColumnType.substring(0, newColumnType.lastIndexOf(".")); + String arg1 = newColumnType.substring(newColumnType.lastIndexOf(".")+1); + this.type = SDODataTypes.TYPE_HELPER.getType(arg0, arg1); + } + } + + public void setValue(Object value) { + this.value = value; + } + + public Object getValue() { + if (getConverter() != null) { + return getConverter().getColumnValue(this.value); + } + + return this.value; + } + + public void setConverter(Converter converter) { + this.converter = converter; + } + + public Converter getConverter() { + return this.converter; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ParameterImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ParameterImpl.java new file mode 100644 index 0000000000..3e23faf069 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ParameterImpl.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import org.apache.tuscany.das.rdb.Converter; + +import commonj.sdo.Type; + +public class ParameterImpl { + + /** + * Value for "Direction" that indicates that a parameter is soley for input. + */ + static final int IN = 1; + + /** + * Value for "Direction" that indicates that a parameter is soley for output. + * Out parameters only apply to Stored Procedures + */ + static final int OUT = 2; + + /** + * Value for "Direction" that indicates that a parameter is for both input and output. + * In-out parameters only apply to stored procedures + */ + static final int IN_OUT = 3; + + protected Object value; + + private int index; + + private Type type; + + private String name; + + private int direction = IN; + + private Converter converter; + + + public ParameterImpl() { + super(); + } + + public ParameterImpl(int index) { + this.index = index; + } + + public void setType(Type type) { + this.type = type; + } + + public void setIndex(int index) { + if (index == 0) { + throw new RuntimeException("Index of zero not allowed"); + } + this.index = index; + } + + public void setName(String name) { + this.name = name; + } + + public void setValue(Object value) { + this.value = value; + } + + public void setDirection(int direction) { + this.direction = direction; + } + + public Type getType() { + return this.type; + } + + public int getIndex() { + return this.index; + } + + public String getName() { + return this.name; + } + + public Object getValue() { + if (getConverter() != null) { + return getConverter().getColumnValue(this.value); + } + + return this.value; + } + + public int getDirection() { + return this.direction; + } + + public void setConverter(Converter converter) { + this.converter = converter; + } + + public Converter getConverter() { + return this.converter; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Parameters.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Parameters.java new file mode 100644 index 0000000000..bebfba9ce9 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Parameters.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.log4j.Logger; + +import commonj.sdo.Type; + +public class Parameters { + private final Logger logger = Logger.getLogger(Parameters.class); + + private List parameters = new ArrayList(); + + private List inParams = new ArrayList(); + + private List outParams = new ArrayList(); + + public Parameters() { + super(); + } + + public ParameterImpl get(int index) { + return (ParameterImpl) parameters.get(index); + } + + public List outParams() { + return outParams; + } + + public List inParams() { + return inParams; + } + + private void addParameter(ParameterImpl param) { + if (param.getDirection() == ParameterImpl.IN) { + inParams.add(param); + } else if ((param.getDirection() == ParameterImpl.OUT) || (param.getDirection() == ParameterImpl.IN_OUT)) { + outParams.add(param); + } + + this.parameters.add(param); + } + + public void add(ParameterImpl param) { + addParameter(param); + } + + public ParameterImpl findOrCreateParameterWithIndex(int index, int direction, Type sdoType) { + Iterator i = parameters.iterator(); + while (i.hasNext()) { + ParameterImpl param = (ParameterImpl) i.next(); + + if (param.getIndex() == index) { + return param; + } + } + if (this.logger.isDebugEnabled()) { + this.logger.debug("Creating new parameter with index " + index); + } + + ParameterImpl newParam = new ParameterImpl(index); + newParam.setDirection(direction); + newParam.setType(sdoType); + addParameter(newParam); + return newParam; + } + + public List parameterList() { + return parameters; + } + + public ParameterImpl findOrCreateParameterWithIndex(int index) { + return findOrCreateParameterWithIndex(index, ParameterImpl.IN, null); + } + + public void setParameter(int index, Object value) { + ParameterImpl param = findOrCreateParameterWithIndex(index); + param.setValue(value); + } + + public ParameterImpl parameterWithIndex(int index) { + Iterator i = parameters.iterator(); + while (i.hasNext()) { + ParameterImpl param = (ParameterImpl) i.next(); + + if (param.getIndex() == index) { + return param; + } + } + return null; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ParametersExtendedImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ParametersExtendedImpl.java new file mode 100644 index 0000000000..190695ae14 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ParametersExtendedImpl.java @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.Parameters; +import org.apache.tuscany.das.rdb.config.impl.ParameterImpl; +import org.apache.tuscany.das.rdb.config.impl.ParametersImpl; + +import commonj.sdo.Type; + +public class ParametersExtendedImpl extends ParametersImpl{ + private final Logger logger = Logger.getLogger(ParametersExtendedImpl.class); + private List inParams = new ArrayList(); + + private List outParams = new ArrayList(); + + public ParametersExtendedImpl(){ + + } + + public ParametersExtendedImpl(List paramsList) { + if(this.parameter == null){ + this.parameter = new ArrayList(); + } + if(paramsList != null){ + for(int i=0; i<paramsList.size(); i++){ + ParameterImpl paramImpl = (ParameterImpl)paramsList.get(i); + ParameterExtendedImpl paramExtImpl = new ParameterExtendedImpl(); + paramExtImpl.setColumnType(paramImpl.getColumnType()); + paramExtImpl.setIndex(paramImpl.getIndex()); + paramExtImpl.setName(paramImpl.getName()); + paramExtImpl.setDirection(paramImpl.getDirection()); + this.parameter.add(paramExtImpl); + } + } + } + + public ParametersExtendedImpl(Parameters params) { + this(params.getParameter()); + } + + public List getOutParameters() { + return outParams; + } + + public List getInParameters() { + return inParams; + } + + public ParameterExtendedImpl getParameter(int index) { + if(this.getParameter() == null || this.getParameter().isEmpty()) + return null; + + Iterator itr = this.getParameter().iterator(); + while(itr.hasNext()){ + ParameterExtendedImpl curParam = (ParameterExtendedImpl)itr.next(); + if(curParam.getIndex() == index){ + return curParam; + } + } + return null; + } + + public ParameterExtendedImpl getParameter(int index, String direction) { + if(direction.equals(ParameterExtendedImpl.IN)) { + Iterator itr = this.inParams.iterator(); + while(itr.hasNext()){ + ParameterExtendedImpl curParam = (ParameterExtendedImpl)itr.next(); + if(curParam.getIndex() == index){ + return curParam; + } + } + } + else { + Iterator itr = this.outParams.iterator(); + while(itr.hasNext()){ + ParameterExtendedImpl curParam = (ParameterExtendedImpl)itr.next(); + if(curParam.getIndex() == index){ + return curParam; + } + } + } + return null; + } + + private ParameterExtendedImpl getNamedParameter(List params, String name){ + if(params == null) + return null; + for(int i=0; i<params.size(); i++){ + if( ((ParameterExtendedImpl)params.get(i)).getName().equals(name)){ + return (ParameterExtendedImpl)params.get(i); + } + } + return null; + } + + public ParameterExtendedImpl getParameter(String name) { + return getNamedParameter(this.getParameter(), name); + } + + public ParameterExtendedImpl getParameter(String name, String direction) { + if(direction.equals(ParameterExtendedImpl.IN)) + return getNamedParameter(this.inParams, name); + else + return getNamedParameter(this.outParams, name); + } + + public ParameterExtendedImpl findOrCreateParameterWithIndex(int index, String direction, Type sdoType) { + if(this.parameter == null){ + this.parameter = new ArrayList(); + } + Iterator i = this.parameter.iterator(); + while (i.hasNext()) { + ParameterExtendedImpl param = (ParameterExtendedImpl) i.next(); + + if (param.getIndex() == index) { + return param; + } + } + if (this.logger.isDebugEnabled()) { + this.logger.debug("Creating new parameter with index " + index); + } + + ParameterExtendedImpl newParam = new ParameterExtendedImpl(); + newParam.setIndex(index); + newParam.setDirection(direction); + newParam.setType(sdoType); + newParam.setColumnType(SDODataTypeHelper.columnTypeForSDOType(sdoType)); + this.getParameter().add(newParam); + if(!direction.equals(ParameterExtendedImpl.IN)){ + this.getOutParameters().add(newParam); + } + else{ + this.getInParameters().add(newParam); + } + return newParam; + } + + /**maintain compatibility with parameters="name1 name2 " from config + * + * @param parameters + */ + public static ArrayList getParameters(String parameters) { + StringTokenizer tokenizer = new StringTokenizer(parameters); + ArrayList paramExtList = new ArrayList(); + for (int idx = 1; tokenizer.hasMoreTokens(); idx++) { + ParameterExtendedImpl p = new ParameterExtendedImpl(); + p.setName(tokenizer.nextToken()); + p.setIndex(idx); + p.setDirection(ParameterExtendedImpl.IN); + paramExtList.add(p); + } + return paramExtList; + } + + public void addParameters(List paramExtList){ + for(int i=0; i<paramExtList.size(); i++){ + ParameterExtendedImpl curParam = (ParameterExtendedImpl)paramExtList.get(i); + this.getParameter().add(curParam); + if(curParam.getDirection().equals(ParameterExtendedImpl.IN)) + this.getInParameters().add(paramExtList.get(i)); + else + this.getOutParameters().add(paramExtList.get(i)); + } + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java new file mode 100644 index 0000000000..608ed6122a --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java @@ -0,0 +1,338 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.io.IOException; +import java.io.OutputStream; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Iterator; + +import org.apache.tuscany.das.rdb.config.ResultDescriptor; +import org.apache.tuscany.das.rdb.config.impl.ResultDescriptorImpl; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.graphbuilder.impl.GraphBuilderMetadata; +import org.apache.tuscany.das.rdb.graphbuilder.impl.ResultSetProcessor; +import org.apache.tuscany.sdo.api.SDOUtil; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; + +public class ReadCommandImpl extends CommandImpl { + + private int startRow = 1; + + private int endRow = Integer.MAX_VALUE; + + private List resultDescriptors = null; + + public ReadCommandImpl(org.apache.tuscany.das.rdb.config.Command command, MappingWrapper mapping, List resultDescriptor) { + super(command); + this.configWrapper = mapping; + + if (resultDescriptor != null && !resultDescriptor.isEmpty()) { + this.resultSetShape = new ResultSetShape(resultDescriptor, configWrapper.getConfig());//JIRA-952 + } + } + + public ReadCommandImpl(String sqlString, MappingWrapper mapping, List resultDescriptor) { + super(sqlString); + this.configWrapper = mapping; + + if (resultDescriptor != null && !resultDescriptor.isEmpty()) { + this.resultSetShape = new ResultSetShape(resultDescriptor, configWrapper.getConfig());//JIRA-952 + } + } + + private void refreshResultSetShape(){ + //sort descriptor and use in ResultSetShape + sortResultDescriptors(); + this.resultSetShape = new ResultSetShape(this.resultDescriptors, configWrapper.getConfig()); + } + + private void sortResultDescriptors(){ + if(this.resultDescriptors == null) { + return; + } + + if( this.resultDescriptors.size()==0) { + return; + } + + //when any index is found not set, do not sort + for(Iterator it = this.resultDescriptors.iterator() ; it.hasNext();){ + ResultDescriptor resultDescriptor = (ResultDescriptor) it.next(); + if(resultDescriptor.getColumnIndex() <= -1){ + return; + } + } + + //now is time to sort + Object[] resultDescAry = this.resultDescriptors.toArray(); + for(int i=0; i<resultDescAry.length; i++){ + for(int j=i+1; j<resultDescAry.length; j++){ + if( ((ResultDescriptor)resultDescAry[j]).getColumnIndex() + < ((ResultDescriptor)resultDescAry[i]).getColumnIndex()){ + ResultDescriptor tmpResDesc = (ResultDescriptor)resultDescAry[i]; + resultDescAry[i] = resultDescAry[j]; + resultDescAry[j] = tmpResDesc; + } + + if( ((ResultDescriptor)resultDescAry[j]).getColumnIndex() + == ((ResultDescriptor)resultDescAry[i]).getColumnIndex()){ + throw new RuntimeException("Two columns in Result Descriptor can not have same index"); + } + } + } + + this.resultDescriptors.clear(); + for(int i=0; i<resultDescAry.length; i++){ + this.resultDescriptors.add(resultDescAry[i]); + } + + return; + } + + private ResultDescriptor deepCopyResultDescriptor(ResultDescriptor inObj){ + ResultDescriptorImpl outObj = new ResultDescriptorImpl(); + outObj.setColumnIndex(inObj.getColumnIndex()); + outObj.setColumnName(inObj.getColumnName()); + outObj.setColumnType(inObj.getColumnType()); + outObj.setTableName(inObj.getTableName()); + outObj.setSchemaName(inObj.getSchemaName()); + return outObj; + } + + private List deepCopyResultDescriptors(List resultDescriptors){ + if(resultDescriptors == null || resultDescriptors.size() == 0) + return null; + + ArrayList copyList = new ArrayList(); + + for(Iterator it = resultDescriptors.iterator() ; it.hasNext();){ + copyList.add( deepCopyResultDescriptor( (ResultDescriptorImpl) it.next())); + } + return copyList; + } + + /** + * When any columnIndex == -ve, sorting will not happen in ResultShapeSorter (old way) + * When null is passed, set this.resultSetShape to null, this will later trigger, dbms metadata + * based shaping of result + */ + public void setResultDescriptors(List resultDescriptors){ + this.resultDescriptors = deepCopyResultDescriptors(resultDescriptors); + if(this.resultDescriptors == null || this.resultDescriptors.size()==0){ + this.resultSetShape = null; + } + else{ + //below will go away with List<> JDK5 + for(Iterator it = this.resultDescriptors.iterator() ; it.hasNext();){ + + if(!(it.next() instanceof ResultDescriptor)){ + throw new RuntimeException("Elements in List not of type ResultDescriptor!"); + } + + } + refreshResultSetShape(); + } + } + + public List getResultDescriptors(){ + return this.resultDescriptors; + } + + public void addResultDescriptor(ResultDescriptor resultDescriptor){ + //if >= 0 columnIndex, add/replace for given index + //if < 0 columnIndex, add at end of current list + if(resultDescriptor == null) { + return; + } + + if(this.resultDescriptors == null){ + this.resultDescriptors = new ArrayList(); + } + + if(resultDescriptor.getColumnIndex() <0){ + this.resultDescriptors.add(deepCopyResultDescriptor(resultDescriptor));//dont care about columnIndex,add at end, old way + } + else{ + ResultDescriptor existing = getResultDescriptor(resultDescriptor.getColumnIndex()); + if(existing != null){ + removeResultDescriptor(resultDescriptor.getColumnIndex()); + } + this.resultDescriptors.add(deepCopyResultDescriptor(resultDescriptor));//add at end, sorting will happen below + } + + refreshResultSetShape(); + } + + + public ResultDescriptor removeResultDescriptor(int columnIndex){ + //if < 0 index return null + //if >=0 index and available at given index, remove and return same + //if >=0 index and not available at given index, return null + ResultDescriptor existing = null; + if(columnIndex >=0 && ((existing = getResultDescriptor(columnIndex)) != null) ){ + this.resultDescriptors.remove(existing); + refreshResultSetShape(); + return existing; + } + return null; + } + + public ResultDescriptor removeResultDescriptor(ResultDescriptor resultDescriptor){ + //remove and return only if matched for index, name, type, table name, schema name + //else return null + if(resultDescriptor != null){ + ResultDescriptor existing = getResultDescriptor(resultDescriptor.getColumnIndex()); + if(existing != null && + existing.getColumnName().equals(resultDescriptor.getColumnName()) && + existing.getColumnType().equals(resultDescriptor.getColumnType()) && + existing.getTableName().equals(resultDescriptor.getTableName()) ) { + if(this.configWrapper.getConfig().isDatabaseSchemaNameSupported()){//multi schema support + if(resultDescriptor.getSchemaName() != null && existing.getSchemaName() != null + && resultDescriptor.getSchemaName().equals(existing.getSchemaName())){ + this.resultDescriptors.remove(existing); + refreshResultSetShape(); + return existing; + } + return null; + } + else{ + this.resultDescriptors.remove(existing); + refreshResultSetShape(); + return existing; + } + } + } + return null; + } + + public ResultDescriptor getResultDescriptor(int columnIndex){ + //if <0 index return null + //if >=0 index and available at given index, return same + //if >=0 index and not available at given index, return null + if(columnIndex >=0 && this.resultDescriptors != null){ + + for(Iterator it = this.resultDescriptors.iterator() ; it.hasNext();){ + ResultDescriptor rs = (ResultDescriptor) it.next(); + + if( rs.getColumnIndex() == columnIndex){ + return rs; + } + + } + } + + return null; + } + + //Utility method + public void printResultDescriptors(OutputStream ostrm) throws IOException{ + if(this.resultDescriptors != null && this.resultDescriptors.size() != 0){ + + for(Iterator it = this.resultDescriptors.iterator() ; it.hasNext();){ + ostrm.write( it.next().toString().getBytes() ); + ostrm.write('\n'); + + } + ostrm.flush(); + + } + } + + public void execute() { + throw new UnsupportedOperationException(); + } + + public DataObject executeQuery() { + + if (statement.getConnection() == null) { + throw new RuntimeException("A DASConnection object must be specified before executing the query."); + } + + boolean success = false; + try { + List results = statement.executeQuery(parameters); + success = true; + return buildGraph(results); + } catch (SQLException e) { + throw new RuntimeException(e); + } finally { + if (success) { + statement.getConnection().cleanUp(); + } else { + statement.getConnection().errorCleanUp(); + } + } + } + + protected DataObject buildGraph(List results) throws SQLException { + + // Before we use the mappingModel, do some checking/updating. If + // inferrable information + // isn't specified, add it in. + + GraphBuilderMetadata gbmd = new GraphBuilderMetadata(results, configWrapper.getConfig(), + resultSetShape); + + // Create the DataGraph + DataGraph g = SDOUtil.createDataGraph(); + + // Create the root object + g.createRootObject(gbmd.getRootType()); + + SDOUtil.registerDataGraphTypes(g, gbmd.getDefinedTypes()); + + ChangeSummary summary = g.getChangeSummary(); + + ResultSetProcessor rsp = new ResultSetProcessor(g.getRootObject(), gbmd); + rsp.processResults(getStartRow(), getEndRow()); + + summary.beginLogging(); + + return g.getRootObject(); + } + + + protected int getStartRow() { + return startRow; + } + + protected int getEndRow() { + return endRow; + } + + protected void setStartRow(int startRow) { + this.startRow = startRow; + } + + protected void setEndRow(int endRow) { + this.endRow = endRow; + } + + + protected void enablePaging() { + statement.enablePaging(); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ResultSetShape.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ResultSetShape.java new file mode 100644 index 0000000000..a9744d42b9 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ResultSetShape.java @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.List; + +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.ResultDescriptor; +import org.apache.tuscany.das.rdb.graphbuilder.schema.ResultSetTypeMap; + +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; + +/** + * Describes the structure of the result set returned from + * execution of a SELECT statement. This description is typcially + * not required since the shape can be retreived from the JDBC + * ResultSetMetadata. However, some platforms such as Oracle do not + * support fully suport ResultSetMedata. + * <p> + * There may also be a performance boost when using this interface. + * + * + */ +public class ResultSetShape { + + private final String[] columns; + + private final String[] tables; + + private final Type[] types; + + private final String[] schema;//JIRA-952 + //JIRA-952 + public ResultSetShape(ResultSetMetaData metadata, Config model) throws SQLException { + columns = new String[metadata.getColumnCount()]; + tables = new String[metadata.getColumnCount()]; + types = new Type[metadata.getColumnCount()]; + schema = new String[metadata.getColumnCount()]; + + ResultSetTypeMap typeMap = ResultSetTypeMap.INSTANCE; + for (int i = 1; i <= metadata.getColumnCount(); i++) { + if(model.isDatabaseSchemaNameSupported()){ + if(metadata.getSchemaName(i) != null && !metadata.getSchemaName(i).equals("")){ + //tables[i - 1] = metadata.getSchemaName(i)+"."+metadata.getTableName(i); + tables[i - 1] = metadata.getTableName(i); + schema[i - 1] = metadata.getSchemaName(i); + } + else{ + tables[i - 1] = metadata.getTableName(i); + schema[i - 1] = ""; + } + } + else{ + tables[i - 1] = metadata.getTableName(i); + schema[i - 1] = ""; + } + columns[i - 1] = metadata.getColumnName(i); + types[i - 1] = typeMap.getType(metadata.getColumnType(i), true); + } + } + + //JIRA-952 + protected ResultSetShape(List resultDescriptor, Config model) { + TypeHelper helper = TypeHelper.INSTANCE; + int size = resultDescriptor.size(); + columns = new String[size]; + tables = new String[size]; + types = new Type[size]; + schema = new String[size]; + + for (int i = 0; i < size; i++) { + ResultDescriptor desc = (ResultDescriptor) resultDescriptor.get(i); + if(model.isDatabaseSchemaNameSupported()){ + if(desc.getSchemaName() != null && !desc.getSchemaName().equals("")){ + tables[i] = desc.getTableName(); + schema[i] = desc.getSchemaName(); + }else{ + tables[i] = desc.getTableName(); + schema[i] = ""; + } + + }else{ + tables[i] = desc.getTableName(); + schema[i] = ""; + } + columns[i] = desc.getColumnName(); + + int idx = desc.getColumnType().lastIndexOf('.'); + String uri = desc.getColumnType().substring(0, idx); + String typeName = desc.getColumnType().substring(idx + 1); + + types[i] = helper.getType(uri, typeName); + if (types[i] == null) { + throw new RuntimeException("Could not find type " + desc.getColumnType() + + " for column " + desc.getColumnName()); + } + } + + } + + public int getColumnCount() { + return columns.length; + } + + public String getTableName(int i) { + return tables[i - 1]; + } + + //JIRA-952 + public String getSchemaName(int i) { + return schema[i - 1]; + } + public String getColumnName(int i) { + return columns[i - 1]; + } + + public Type getColumnType(int i) { + return types[i - 1]; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + result.append(" column/table/schema/type: "); + for (int i = 0; i < columns.length; i++) { + result.append(columns[i]); + result.append('\t'); + result.append(tables[i]); + result.append('\t'); + result.append(schema[i]); + result.append('\t'); + if (types[i] == null) { + result.append("null"); + } else { + result.append(types[i].getName()); + } + result.append('\n'); + } + + return result.toString(); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SDODataTypeHelper.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SDODataTypeHelper.java new file mode 100644 index 0000000000..5f24099743 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SDODataTypeHelper.java @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.sql.Types; + +import commonj.sdo.Type; + +public final class SDODataTypeHelper { + + private SDODataTypeHelper() { + + } + + public static String columnTypeForSDOType(Type sdoType){ + if(sdoType == null) { + throw new RuntimeException("Null SDO Data Type!"); + } + + if(!sdoType.isDataType()) { + throw new RuntimeException("Invalid SDO Data Type! "+sdoType.getName()); + } + + if (sdoType == SDODataTypes.BOOLEAN) { + return SDODataTypes.BOOLEAN_STR; + } else if (sdoType == SDODataTypes.BOOLEANOBJECT) { + return SDODataTypes.BOOLEANOBJECT_STR; + } else if (sdoType == SDODataTypes.BYTE) { + return SDODataTypes.BYTE_STR; + } else if (sdoType == SDODataTypes.BYTEOBJECT) { + return SDODataTypes.BYTEOBJECT_STR; + } else if (sdoType == SDODataTypes.BYTES) { + return SDODataTypes.BYTES_STR; + } else if (sdoType == SDODataTypes.CHARACTER) { + return SDODataTypes.CHARACTER_STR; + } else if (sdoType == SDODataTypes.CHARACTEROBJECT) { + return SDODataTypes.CHARACTEROBJECT_STR; + } else if (sdoType == SDODataTypes.DATE) { + return SDODataTypes.DATE_STR; + } else if (sdoType == SDODataTypes.DATETIME) { + return SDODataTypes.DATETIME_STR; + } else if (sdoType == SDODataTypes.DAY) { + return SDODataTypes.DAY_STR; + } else if (sdoType == SDODataTypes.DECIMAL) { + return SDODataTypes.DECIMAL_STR; + } else if (sdoType == SDODataTypes.STRING) { + return SDODataTypes.STRING_STR; + } else if (sdoType == SDODataTypes.DOUBLE) { + return SDODataTypes.DOUBLE_STR; + } else if (sdoType == SDODataTypes.DOUBLEOBJECT) { + return SDODataTypes.DOUBLEOBJECT_STR; + } else if (sdoType == SDODataTypes.DURATION) { + return SDODataTypes.DURATION_STR; + } else if (sdoType == SDODataTypes.FLOAT) { + return SDODataTypes.FLOAT_STR; + } else if (sdoType == SDODataTypes.FLOATOBJECT) { + return SDODataTypes.FLOATOBJECT_STR; + } else if (sdoType == SDODataTypes.INT) { + return SDODataTypes.INT_STR; + } else if (sdoType == SDODataTypes.INTEGER) { + return SDODataTypes.INTEGER_STR; + } else if (sdoType == SDODataTypes.INTOBJECT) { + return SDODataTypes.INTOBJECT_STR; + } else if (sdoType == SDODataTypes.LONG) { + return SDODataTypes.LONG_STR; + } else if (sdoType == SDODataTypes.LONGOBJECT) { + return SDODataTypes.LONGOBJECT_STR; + } else if (sdoType == SDODataTypes.MONTH) { + return SDODataTypes.MONTH_STR; + } else if (sdoType == SDODataTypes.MONTHDAY) { + return SDODataTypes.MONTHDAY_STR; + } else if (sdoType == SDODataTypes.OBJECT) { + return SDODataTypes.OBJECT_STR; + } else if (sdoType == SDODataTypes.SHORT) { + return SDODataTypes.SHORT_STR; + } else if (sdoType == SDODataTypes.SHORTOBJECT) { + return SDODataTypes.SHORTOBJECT_STR; + } else if (sdoType == SDODataTypes.STRING) { + return SDODataTypes.STRING_STR; + } else if (sdoType == SDODataTypes.STRINGS) { + return SDODataTypes.STRINGS_STR; + } else if (sdoType == SDODataTypes.TIME) { + return SDODataTypes.TIME_STR; + } else if (sdoType == SDODataTypes.URI) { + return SDODataTypes.URI_STR; + } else if (sdoType == SDODataTypes.YEAR) { + return SDODataTypes.YEAR_STR; + } else if (sdoType == SDODataTypes.YEARMONTH) { + return SDODataTypes.YEARMONTH_STR; + } else if (sdoType == SDODataTypes.YEARMONTHDAY) { + return SDODataTypes.YEARMONTHDAY_STR; + } else { + throw new RuntimeException("Invalid SDO Data Type " + sdoType.getName()); + } + } + + public static int sqlTypeFor(Type sdoType) { + if (sdoType == null) { + return Types.OTHER; + } + + if (sdoType == SDODataTypes.BOOLEAN) { + return Types.BOOLEAN; + } else if (sdoType == SDODataTypes.STRING) { + return Types.VARCHAR; + } else if (sdoType == SDODataTypes.BYTE) { + return Types.TINYINT; + } else if (sdoType == SDODataTypes.BYTES) { + return Types.BINARY; + } else if (sdoType == SDODataTypes.CHARACTER) { + return Types.CHAR; + } else if (sdoType == SDODataTypes.DATE) { + return Types.DATE; + } else if (sdoType == SDODataTypes.DATETIME) { + return Types.DATE; + } else if (sdoType == SDODataTypes.DAY) { + return java.sql.Types.VARCHAR; + } else if (sdoType == SDODataTypes.DECIMAL) { + return java.sql.Types.DECIMAL; + } else if (sdoType == SDODataTypes.DOUBLE) { + return java.sql.Types.DOUBLE; + } else if (sdoType == SDODataTypes.DURATION) { + return java.sql.Types.VARCHAR; + } else if (sdoType == SDODataTypes.FLOAT) { + return java.sql.Types.REAL; + } else if (sdoType == SDODataTypes.INT) { + return java.sql.Types.INTEGER; + } else if (sdoType == SDODataTypes.INTEGER) { + return java.sql.Types.INTEGER; + } else if (sdoType == SDODataTypes.LONG) { + return java.sql.Types.BIGINT; + } else if (sdoType == SDODataTypes.MONTH) { + return java.sql.Types.VARCHAR; + } else if (sdoType == SDODataTypes.MONTHDAY) { + return java.sql.Types.VARCHAR; + } else if (sdoType == SDODataTypes.OBJECT) { + return java.sql.Types.JAVA_OBJECT; + } else if (sdoType == SDODataTypes.SHORT) { + return java.sql.Types.SMALLINT; + } else if (sdoType == SDODataTypes.STRINGS) { + return java.sql.Types.OTHER; + } else if (sdoType == SDODataTypes.TIME) { + return java.sql.Types.VARCHAR; + } else if (sdoType == SDODataTypes.URI) { + return java.sql.Types.VARCHAR; + } else if (sdoType == SDODataTypes.YEAR) { + return java.sql.Types.VARCHAR; + } else if (sdoType == SDODataTypes.YEARMONTH) { + return java.sql.Types.VARCHAR; + } else if (sdoType == SDODataTypes.YEARMONTHDAY) { + return java.sql.Types.VARCHAR; + } else if (sdoType == SDODataTypes.BOOLEANOBJECT) { + return java.sql.Types.BOOLEAN; + } else if (sdoType == SDODataTypes.BYTEOBJECT) { + return java.sql.Types.TINYINT; + } else if (sdoType == SDODataTypes.CHARACTEROBJECT) { + return java.sql.Types.CHAR; + } else if (sdoType == SDODataTypes.DOUBLEOBJECT) { + return java.sql.Types.DOUBLE; + } else if (sdoType == SDODataTypes.FLOATOBJECT) { + return java.sql.Types.REAL; + } else if (sdoType == SDODataTypes.INTOBJECT) { + return java.sql.Types.INTEGER; + } else if (sdoType == SDODataTypes.LONGOBJECT) { + return java.sql.Types.BIGINT; + } else if (sdoType == SDODataTypes.SHORTOBJECT) { + return java.sql.Types.SMALLINT; + } else { + throw new RuntimeException("Invalid SDO Data Type " + sdoType.getName()); + } + + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SDODataTypes.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SDODataTypes.java new file mode 100644 index 0000000000..db520b249f --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SDODataTypes.java @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; + +/** + * Defines SDO data types. This is used primalirly to type stored procedure OUT parameters. + * and due to final consts reduce number of string creation + */ +public class SDODataTypes { + + public static final TypeHelper TYPE_HELPER = TypeHelper.INSTANCE; + + public static final Type BOOLEAN = TYPE_HELPER.getType("commonj.sdo", "Boolean"); + public static final String BOOLEAN_STR = "commonj.sdo.Boolean"; + + public static final Type BOOLEANOBJECT = TYPE_HELPER.getType("commonj.sdo", "BooleanObject"); + public static final String BOOLEANOBJECT_STR = "commonj.sdo.BooleanObject"; + + public static final Type BYTE = TYPE_HELPER.getType("commonj.sdo", "Byte"); + public static final String BYTE_STR = "commonj.sdo.Byte"; + + public static final Type BYTEOBJECT = TYPE_HELPER.getType("commonj.sdo", "ByteObject"); + public static final String BYTEOBJECT_STR = "commonj.sdo.ByteObject"; + + public static final Type BYTES = TYPE_HELPER.getType("commonj.sdo", "Bytes"); + public static final String BYTES_STR = "commonj.sdo.Bytes"; + + public static final Type CHARACTER = TYPE_HELPER.getType("commonj.sdo", "Character"); + public static final String CHARACTER_STR = "commonj.sdo.Character"; + + public static final Type CHARACTEROBJECT = TYPE_HELPER.getType("commonj.sdo", "CharacterObject"); + public static final String CHARACTEROBJECT_STR = "commonj.sdo.CharacterObject"; + + public static final Type DATE = TYPE_HELPER.getType("commonj.sdo", "Date"); + public static final String DATE_STR = "commonj.sdo.Date"; + + public static final Type DATETIME = TYPE_HELPER.getType("commonj.sdo", "DateTime"); + public static final String DATETIME_STR = "commonj.sdo.DateTime"; + + public static final Type DAY = TYPE_HELPER.getType("commonj.sdo", "Day"); + public static final String DAY_STR = "commonj.sdo.Day"; + + public static final Type DECIMAL = TYPE_HELPER.getType("commonj.sdo", "Decimal"); + public static final String DECIMAL_STR = "commonj.sdo.Decimal"; + + public static final Type DOUBLE = TYPE_HELPER.getType("commonj.sdo", "Double"); + public static final String DOUBLE_STR = "commonj.sdo.Double"; + + public static final Type DOUBLEOBJECT = TYPE_HELPER.getType("commonj.sdo", "DoubleObject"); + public static final String DOUBLEOBJECT_STR = "commonj.sdo.DoubleObject"; + + public static final Type DURATION = TYPE_HELPER.getType("commonj.sdo", "Duration"); + public static final String DURATION_STR = "commonj.sdo.Duration"; + + public static final Type FLOAT = TYPE_HELPER.getType("commonj.sdo", "Float"); + public static final String FLOAT_STR = "commonj.sdo.Float"; + + public static final Type FLOATOBJECT = TYPE_HELPER.getType("commonj.sdo", "FloatObject"); + public static final String FLOATOBJECT_STR = "commonj.sdo.FloatObject"; + + public static final Type INT = TYPE_HELPER.getType("commonj.sdo", "Int"); + public static final String INT_STR = "commonj.sdo.Int"; + + public static final Type INTEGER = TYPE_HELPER.getType("commonj.sdo", "Integer"); + public static final String INTEGER_STR = "commonj.sdo.Integer"; + + public static final Type INTOBJECT = TYPE_HELPER.getType("commonj.sdo", "IntObject"); + public static final String INTOBJECT_STR = "commonj.sdo.IntObject"; + + public static final Type LONG = TYPE_HELPER.getType("commonj.sdo", "Long"); + public static final String LONG_STR = "commonj.sdo.Long"; + + public static final Type LONGOBJECT = TYPE_HELPER.getType("commonj.sdo", "LongObject"); + public static final String LONGOBJECT_STR = "commonj.sdo.LongObject"; + + public static final Type MONTH = TYPE_HELPER.getType("commonj.sdo", "Month"); + public static final String MONTH_STR = "commonj.sdo.Month"; + + public static final Type MONTHDAY = TYPE_HELPER.getType("commonj.sdo", "MonthDay"); + public static final String MONTHDAY_STR = "commonj.sdo.MonthDay"; + + public static final Type OBJECT = TYPE_HELPER.getType("commonj.sdo", "Object"); + public static final String OBJECT_STR = "commonj.sdo.Object"; + + public static final Type SHORT = TYPE_HELPER.getType("commonj.sdo", "Short"); + public static final String SHORT_STR = "commonj.sdo.Short"; + + public static final Type SHORTOBJECT = TYPE_HELPER.getType("commonj.sdo", "ShortObject"); + public static final String SHORTOBJECT_STR = "commonj.sdo.ShortObject"; + + public static final Type STRING = TYPE_HELPER.getType("commonj.sdo", "String"); + public static final String STRING_STR = "commonj.sdo.String"; + + public static final Type STRINGS = TYPE_HELPER.getType("commonj.sdo", "Strings"); + public static final String STRINGS_STR = "commonj.sdo.Strings"; + + public static final Type TIME = TYPE_HELPER.getType("commonj.sdo", "Time"); + public static final String TIME_STR = "commonj.sdo.Time"; + + public static final Type URI = TYPE_HELPER.getType("commonj.sdo", "URI"); + public static final String URI_STR = "commonj.sdo.URI"; + + public static final Type YEAR = TYPE_HELPER.getType("commonj.sdo", "Year"); + public static final String YEAR_STR = "commonj.sdo.Year"; + + public static final Type YEARMONTH = TYPE_HELPER.getType("commonj.sdo", "YearMonth"); + public static final String YEARMONTH_STR = "commonj.sdo.YearMonth"; + + public static final Type YEARMONTHDAY = TYPE_HELPER.getType("commonj.sdo", "YearMonthDay"); + public static final String YEARMONTHDAY_STR = "commonj.sdo.YearMonthDay"; +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SPCommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SPCommandImpl.java new file mode 100644 index 0000000000..c1822c3e07 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/SPCommandImpl.java @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.sql.SQLException; +import java.util.Iterator; +import java.util.List; + +import org.apache.log4j.Logger; +import org.apache.tuscany.das.rdb.config.Parameter; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; + +public class SPCommandImpl extends ReadCommandImpl { + private final Logger logger = Logger.getLogger(SPCommandImpl.class); + + public SPCommandImpl(String sqlString, MappingWrapper config, List params) { + super(sqlString, config, null); + Iterator i = params.iterator(); + while (i.hasNext()) { + Parameter p = (Parameter) i.next(); + + int index = p.getColumnType().lastIndexOf('.'); + String pkg = p.getColumnType().substring(0, index); + String typeName = p.getColumnType().substring(index + 1); + + Type sdoType = TypeHelper.INSTANCE.getType(pkg, typeName); + + String direction = ParameterExtendedImpl.IN; + if (ParameterExtendedImpl.OUT.equalsIgnoreCase(p.getDirection())) { + direction = ParameterExtendedImpl.OUT; + } else if (ParameterExtendedImpl.IN_OUT.equalsIgnoreCase(p.getDirection())) { + direction = ParameterExtendedImpl.IN_OUT; + } + parameters.findOrCreateParameterWithIndex(p.getIndex(), direction, sdoType); + } + + } + + public DataObject executeQuery() { + + boolean success = false; + try { + List results = statement.executeCall(parameters); + success = true; + + return buildGraph(results); + } catch (SQLException e) { + if (this.logger.isDebugEnabled()) { + this.logger.debug(e); + } + + throw new RuntimeException(e); + } finally { + if (success) { + statement.getConnection().cleanUp(); + } else { + statement.getConnection().errorCleanUp(); + } + } + } + + public void execute() { + + boolean success = false; + try { + statement.executeUpdateCall(parameters); + success = true; + } catch (SQLException e) { + throw new RuntimeException(e); + } finally { + if (success) { + statement.getConnection().cleanUp(); + } else { + statement.getConnection().errorCleanUp(); + } + } + + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Statement.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Statement.java new file mode 100644 index 0000000000..bae802a2bc --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/Statement.java @@ -0,0 +1,233 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.sql.CallableStatement; +import java.sql.ParameterMetaData; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.apache.log4j.Logger; + +// TODO - Can use some refactoring. Much code is duplicated in "execute" methods +public class Statement { + + protected final String queryString; + + protected ConnectionImpl jdbcConnection; + + private final Logger logger = Logger.getLogger(Statement.class); + + private PreparedStatement preparedStatement; + + private boolean isPaging; + + public Statement(String sqlString) { + this.queryString = sqlString; + } + + public List executeQuery(ParametersExtendedImpl parameters) throws SQLException { + + PreparedStatement ps = getPreparedStatement(new String[0]); + ps = setParameters(ps, parameters); + ResultSet rs = ps.executeQuery(); + + return Collections.singletonList(rs); + } + + public List executeCall(ParametersExtendedImpl parameters) throws SQLException { + + CallableStatement cs = jdbcConnection.prepareCall(queryString); + + Iterator inParams = parameters.getInParameters().iterator(); + while (inParams.hasNext()) { + ParameterExtendedImpl param = (ParameterExtendedImpl) inParams.next(); + cs.setObject(param.getIndex(), param.getValue()); + } + + // register out parameters + Iterator outParams = parameters.getOutParameters().iterator(); + while (outParams.hasNext()) { + ParameterExtendedImpl param = (ParameterExtendedImpl) outParams.next(); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Registering parameter " + param.getName()); + } + + cs.registerOutParameter(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType())); + } + + // Using execute because Derby does not currenlty support + // executeQuery + // for SP + cs.execute(); + List results = new ArrayList(); + results.add(cs.getResultSet()); + while (cs.getMoreResults(java.sql.Statement.KEEP_CURRENT_RESULT)) { + results.add(cs.getResultSet()); + } + + Iterator i = parameters.getOutParameters().iterator(); + while (i.hasNext()) { + ParameterExtendedImpl param = (ParameterExtendedImpl) i.next(); + param.setValue(cs.getObject(param.getIndex())); + } + + return results; + + } + + public void executeUpdateCall(ParametersExtendedImpl parameters) throws SQLException { + CallableStatement cs = jdbcConnection.prepareCall(queryString); + + Iterator inParams = parameters.getInParameters().iterator(); + while (inParams.hasNext()) { + ParameterExtendedImpl param = (ParameterExtendedImpl) inParams.next(); + cs.setObject(param.getIndex(), param.getValue()); + } + + // register out parameters + Iterator outParams = parameters.getOutParameters().iterator(); + while (outParams.hasNext()) { + ParameterExtendedImpl param = (ParameterExtendedImpl) outParams.next(); + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Registering parameter " + param.getName()); + } + + cs.registerOutParameter(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType())); + } + + cs.execute(); + + Iterator out = parameters.getOutParameters().iterator(); + while (out.hasNext()) { + ParameterExtendedImpl param = (ParameterExtendedImpl) out.next(); + param.setValue(cs.getObject(param.getIndex())); + } + + } + + public int executeUpdate(ParametersExtendedImpl parameters, String[] generatedKeys) throws SQLException { + return executeUpdate(getPreparedStatement(generatedKeys), parameters); + } + + public int executeUpdate(ParametersExtendedImpl parameters) throws SQLException { + return executeUpdate(parameters, new String[0]); + } + + /** + * TODO - We need to look at using specific ps.setXXX methods when a type + * has been specified and try setObject otherwise. + */ + private int executeUpdate(PreparedStatement ps, ParametersExtendedImpl parameters) throws SQLException { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Executing statement " + queryString); + } + + Iterator i = parameters.getInParameters().iterator(); + while (i.hasNext()) { + ParameterExtendedImpl param = (ParameterExtendedImpl) i.next(); + + Object value = param.getValue(); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Setting parameter " + param.getIndex() + " to " + value); + } + + if (value == null) { + if (param.getType() == null) { + try { + ParameterMetaData pmd = ps.getParameterMetaData(); + ps.setNull(param.getIndex(), pmd.getParameterType(param.getIndex())); + } catch (SQLException ex) { + ps.setNull(param.getIndex(), SDODataTypeHelper.sqlTypeFor(null)); + } + } else { + ps.setNull(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType())); + } + } else { + ps.setObject(param.getIndex(), value); + } + } + return ps.executeUpdate(); + } + + protected PreparedStatement setParameters(PreparedStatement ps, ParametersExtendedImpl parameters) throws SQLException { + Iterator i = parameters.getInParameters().iterator(); + while (i.hasNext()) { + ParameterExtendedImpl param = (ParameterExtendedImpl) i.next(); + ps.setObject(param.getIndex(), param.getValue()); + } + return ps; + } + + public void setConnection(ConnectionImpl jdbcConnection) { + this.jdbcConnection = jdbcConnection; + } + + public ConnectionImpl getConnection() { + return this.jdbcConnection; + } + + private PreparedStatement getPreparedStatement(String[] returnKeys) throws SQLException { + + if (preparedStatement == null) { + if (isPaging) { + preparedStatement = jdbcConnection.preparePagedStatement(queryString); + } else { + preparedStatement = jdbcConnection.prepareStatement(queryString, returnKeys); + } + } + + return preparedStatement; + } + + public Integer getGeneratedKey() throws SQLException { + + if (getConnection().isGeneratedKeysSupported()) { + ResultSet rs = preparedStatement.getGeneratedKeys(); + if (rs.next()) { + return new Integer(rs.getInt(1)); + } + } + + return null; + } + + protected void enablePaging() { + isPaging = true; + } + + public void close() { + + if (this.preparedStatement != null) { + try { + preparedStatement.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateCommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateCommandImpl.java new file mode 100644 index 0000000000..4155360341 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateCommandImpl.java @@ -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. + */ +package org.apache.tuscany.das.rdb.impl; + +import org.apache.tuscany.das.rdb.config.Update; + +public class UpdateCommandImpl extends WriteCommandImpl { + public UpdateCommandImpl(org.apache.tuscany.das.rdb.config.Command command) { + super(command); + } + + public UpdateCommandImpl(String sqlString) { + super(sqlString); + } + + public UpdateCommandImpl(Update update) { + super(update.getSql()); + this.addParameters(update.getParameters()); + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateList.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateList.java new file mode 100644 index 0000000000..e7bb58698c --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateList.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Updates don't have to be sorted, so this class is a simple wrapper of ArrayList. + * + */ +public class UpdateList { + + private List updates = new ArrayList(); + + public UpdateList() { + super(); + } + + public void add(ChangeOperation c) { + updates.add(c); + } + + public Collection getSortedList() { + return updates; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateOperation.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateOperation.java new file mode 100644 index 0000000000..1bcf3441b6 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/UpdateOperation.java @@ -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. + */ +package org.apache.tuscany.das.rdb.impl; + + +import commonj.sdo.DataObject; + + +public class UpdateOperation extends ChangeOperation { + + public UpdateOperation(UpdateCommandImpl command, DataObject changedObject, String id) { + super(command, changedObject); + this.propagatedID = id; + } + +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/WriteCommandImpl.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/WriteCommandImpl.java new file mode 100644 index 0000000000..5ce2ed6992 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/WriteCommandImpl.java @@ -0,0 +1,165 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.impl; + +import java.io.IOException; +import java.io.OutputStream; +import java.sql.SQLException; +import java.util.List; +import java.util.TreeMap; + +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.ResultDescriptor; +import org.apache.tuscany.das.rdb.config.impl.ParameterImpl; +import org.apache.tuscany.das.rdb.config.Parameters; + +import commonj.sdo.DataObject; + +public abstract class WriteCommandImpl extends CommandImpl { + + public WriteCommandImpl(org.apache.tuscany.das.rdb.config.Command command) { + super(command); + } + + public WriteCommandImpl(String sqlString) { + super(sqlString); + } + + public void setResultDescriptors(List resultDescriptorList){ + //ignore , applicable for ReadCommand only + } + + public List getResultDescriptors(){ + //ignore, applicable for ReadCommand only + return null; + } + + public void addResultDescriptor(ResultDescriptor resultDescriptor){ + //ignore + } + + + public ResultDescriptor removeResultDescriptor(int index){ + return null; + } + + public ResultDescriptor removeResultDescriptor(ResultDescriptor resultDescriptor){ + return null; + } + + public ResultDescriptor getResultDescriptor(int index){ + return null; + } + + public void printResultDescriptors(OutputStream ostrm) throws IOException{ + //ignore + } + + public void execute() { + + boolean success = false; + try { + basicExecute(); + success = true; + } finally { + if (success) { + statement.getConnection().cleanUp(); + } else { + statement.getConnection().errorCleanUp(); + } + } + + } + + public void basicExecute() { + try { + statement.executeUpdate(parameters); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + public DataObject executeQuery() { + throw new UnsupportedOperationException(); + } + + public Config getMappingModel() { + return configWrapper.getConfig(); + } + + public String toString() { + + StringBuffer buffer = new StringBuffer(); + buffer.append("\nSQL: " + statement.queryString); + + return buffer.toString(); + } + + public int getGeneratedKey() { + throw new RuntimeException("No generated key is available"); + } + + //it is acceptable if params having index set by caller are listed in any order in Parameters + //but, if index is not set by caller, the order of parameters in Parameters should be in sync + //with the Command string parameters + protected void addParameters(Parameters parameters) { + List params = parameters.getParameter(); + if(params == null) + return; + + boolean paramsIndexed = true; + TreeMap sortedParams = null; + for(int i=0; i<params.size(); i++){ + if(((ParameterImpl)params.get(i)).getIndex() <= 0){ + paramsIndexed=false; //any index not set, ignore all externally set indexes and do auto indexing + break; + } + } + + //auto-indexing + if(!paramsIndexed) { + for(int i=0; i<params.size(); i++){ + ParameterExtendedImpl param = new ParameterExtendedImpl((ParameterImpl)params.get(i)); + param.setIndex(i+1); + this.addParameter(param); + } + return; + } + else {//dont allow duplicates and check indexing with +1 increment from 1st to last param + sortedParams = new TreeMap(); + for(int i=0; i<params.size(); i++){ + ParameterImpl existingParam = (ParameterImpl)sortedParams.put( new Integer(((ParameterImpl)params.get(i)).getIndex()), ((ParameterImpl)params.get(i))); + if(existingParam != null) { + throw new RuntimeException("Parameters with duplicate indexes!"); + } + } + + if( ((Integer)sortedParams.firstKey()).intValue() + sortedParams.size() -1 != + ((Integer)sortedParams.lastKey()).intValue()) { + throw new RuntimeException("Parameters with improper indexes!"); + } + } + + for(int i=0; i<params.size(); i++) { + ParameterExtendedImpl param = new ParameterExtendedImpl((ParameterImpl)params.get(i)); + param.setIndex(((ParameterImpl)params.get(i)).getIndex()); + this.addParameter(param); + } + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/merge/impl/GraphMerger.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/merge/impl/GraphMerger.java new file mode 100644 index 0000000000..b3e29ee854 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/merge/impl/GraphMerger.java @@ -0,0 +1,391 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.merge.impl; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.apache.log4j.Logger; + +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper; +import org.apache.tuscany.das.rdb.config.wrapper.QualifiedColumn; +import org.apache.tuscany.das.rdb.graphbuilder.impl.MultiTableRegistry; +import org.apache.tuscany.das.rdb.graphbuilder.impl.TableRegistry; +import org.apache.tuscany.sdo.api.SDOUtil; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.impl.HelperProvider; + +public class GraphMerger { + + private static Logger logger = Logger.getLogger("GraphMerger"); + + private Map keys = new HashMap(); + + private TableRegistry registry = new MultiTableRegistry(); + + private Config config = null;//JIRA-962 for any new tests with schema , we need this + + // TODO lots of cleanup/design + public GraphMerger() { + // Empty Constructor + } + + //JIRA-952 + public GraphMerger(Config cfg) { + this.config = cfg; + } + + public DataObject emptyGraph() { + if(this.config != null) + return emptyGraph(this.config); + else + return null; + } + + // TODO Replace EMF reference with SDOUtil function when available + // (Tuscany-583) + public DataObject emptyGraph(Config config) { + + if (config.getDataObjectModel() == null) { + throw new RuntimeException("DataObjectModel must be specified in the Config"); + } + + Type rootType = createDataGraphRoot(); + + List types = SDOUtil.getTypes(HelperProvider.getDefaultContext(), config.getDataObjectModel()); + if (types == null) { + throw new RuntimeException("SDO Types have not been registered for URI " + config.getDataObjectModel()); + } + + Iterator i = types.iterator(); + while (i.hasNext()) { + Type type = (Type) i.next(); + Property property = getOrCreateProperty(rootType, type); + } + + // Create the DataGraph + DataGraph g = SDOUtil.createDataGraph(); + + // Create the root object + g.createRootObject(rootType); + + ChangeSummary summary = g.getChangeSummary(); + summary.beginLogging(); + + return g.getRootObject(); + } + + private Type createDataGraphRoot() { + String uri = "http:///org.apache.tuscany.das.rdb/das"; + TypeHelper typeHelper = HelperProvider.getDefaultContext().getTypeHelper(); + Type rootType = null; + rootType = typeHelper.getType(uri+ "/DataGraphRoot", "DataGraphRoot"); + if(rootType == null){ + rootType = SDOUtil.createType(HelperProvider.getDefaultContext(), uri+ "/DataGraphRoot", "DataGraphRoot", false); + if (logger.isDebugEnabled()) { + logger.debug("GraphMerger.createDataGraphRoot():creating type for "+uri); + } + } + return rootType; + } + + private Property getOrCreateProperty(Type rootType, Type type) { + Property property = rootType.getProperty(type.getName()); + if( !(property != null && + (property.getType().isDataType()== type.isDataType()) && + (property.isContainment() == true) && + (property.isMany() == true)) ){ + property = SDOUtil.createProperty(rootType, type.getName(), type); + SDOUtil.setContainment(property, true); + SDOUtil.setMany(property, true); + property = rootType.getProperty(type.getName()); + } + return property; + } + + private boolean isContainedWithChangeSummary(DataObject object) { + if(!object.getType().getName().equals("DataGraphRoot") || object.getChangeSummary() == null) { + return false; + } + return true; + } + + private DataObject containWithChangeSummary(Type rootType, DataObject object) { + Property property = rootType.getProperty(object.getType().getName()); + + if( property == null) { + property = SDOUtil.createProperty(rootType, object.getType().getName(), object.getType()); + SDOUtil.setContainment(property, true); + SDOUtil.setMany(property, true); + property = rootType.getProperty(object.getType().getName()); + } + + DataGraph dataGraph = SDOUtil.createDataGraph(); + DataObject root = dataGraph.createRootObject(rootType); + root.getDataGraph().getChangeSummary().beginLogging(); + createObjectWithSubtree(root, property, object); + + if(root.getDataGraph().getChangeSummary().getChangedDataObjects() != null) { + List cos = root.getDataGraph().getChangeSummary().getChangedDataObjects(); + for(int i=0; i<cos.size(); i++) { + DataObject changedDO = (DataObject)cos.get(i); + } + } + //as we are just wrapping individual DOs in DataGraphRoot, and later during merge we will merge all such DOs, no need to have registry entry + //right now. + registry.remove(object.getType().getName(), Collections.singletonList(getPrimaryKey(object))); + return root; + } + + /** + * If list contains at least one with DG and CS, select it, if none, return -1, if more than one, select the first one matching condition + * @param graphs + * @return + */ + private int getPrimaryFromList(List graphs) { + //select primary + Iterator itr = graphs.iterator(); + int index = -1; + int primaryIndex = -1; + while(itr.hasNext()) { + index++; + DataObject currentGraph = (DataObject)itr.next(); + if(isContainedWithChangeSummary(currentGraph) && currentGraph.getChangeSummary() != null) { + primaryIndex = index; + } + } + return primaryIndex; + } + + //JIRA-1815 + //preservePrimaryChangeSummary - default true - primary CS is preserved, secondary DOs are added without alteration to CS of primary - old behavior + //preservePrimaryChangeSummary - false - secondaries are treated as CREATE and primary CS is altered for merges - way to INSERT with adhoc SDOs. + public DataObject merge(List graphs, boolean preservePrimaryChangeSummary) { + DataObject primaryGraph = null; + int primaryIndex = getPrimaryFromList(graphs); + + if(primaryIndex > -1) { + primaryGraph = (DataObject)graphs.remove(primaryIndex); + } + + Iterator i = graphs.iterator(); + if(primaryGraph == null) { + if (i.hasNext()) { + primaryGraph = (DataObject)i.next(); + } + } + + while (i.hasNext()) { + primaryGraph = merge(primaryGraph, (DataObject) i.next(), preservePrimaryChangeSummary); + } + + return primaryGraph; + } + + public DataObject merge(List graphs) { + return merge(graphs, true); + } + + public DataObject merge(DataObject primary, DataObject secondary, boolean preservePrimaryChangeSummary) { + Type rootType = createDataGraphRoot(); + DataObject root1 = null; + DataObject root2 = null; + + if(!isContainedWithChangeSummary(primary) && isContainedWithChangeSummary(secondary)) { + //swap as secondary has change history + DataObject temp = primary; + primary = secondary; + secondary = temp; + } + + //if primary top type name is not DataGraphRoot , add it + if(!isContainedWithChangeSummary(primary)) { + root1 = containWithChangeSummary(rootType, primary); + } else { + root1 = primary; + } + + //if secondary top type name is not DataGraphRoot , add it + if(!isContainedWithChangeSummary(secondary)) { + root2 = containWithChangeSummary(rootType, secondary); + } else { + root2 = secondary; + } + + return mergeContained(root1, root2, preservePrimaryChangeSummary); + } + + public DataObject merge(DataObject primary, DataObject secondary) { + return merge(primary, secondary, true); + } + + public DataObject mergeContained(DataObject primary, DataObject secondary, boolean preservePrimaryChangeSummary) { + addGraphToRegistry(primary); + + Iterator i = secondary.getType().getProperties().iterator(); + ChangeSummary summary = primary.getDataGraph().getChangeSummary(); + + if(preservePrimaryChangeSummary && summary.isLogging()) { + summary.endLogging(); + } + + while (i.hasNext()) { + Property p = (Property) i.next(); + + Iterator objects = secondary.getList(p.getName()).iterator(); + while (objects.hasNext()) { + DataObject object = (DataObject) objects.next(); + createObjectWithSubtree(primary, p, object); + } + } + + if(preservePrimaryChangeSummary && !summary.isLogging()) { + summary.beginLogging(); + } + + return primary; + } + + private void createObjectWithSubtree(DataObject root, Property p, DataObject object) { + Object pk = getPrimaryKey(object); + + if (!registry.contains(object.getType().getName(), Collections.singletonList(pk))) { + Iterator attrs = object.getType().getProperties().iterator(); + DataObject newObject = root.createDataObject(p.getName()); + + createDataProperties(attrs, newObject, object); + registry.put(object.getType().getName(), Collections.singletonList(pk), newObject); + createReferenceProperties(root, newObject, object); + } + + } + + private void createDataProperties(Iterator attrs, DataObject newObject, DataObject object) { + while (attrs.hasNext()) { + Property attr = (Property) attrs.next(); + if (attr.getType().isDataType()) { + try { + newObject.set(attr.getName(), object.get(attr)); + } catch(Exception e) { + throw new RuntimeException("Graph structures do not match, can not merge! " + attr.getName()); + } + } + } + } + + private void createReferenceProperties(DataObject root, DataObject newObject, DataObject object) { + Iterator refs = object.getType().getProperties().iterator(); + while (refs.hasNext()) { + Property ref = (Property) refs.next(); + if (!ref.getType().isDataType()) { + List refObjects; + if (!ref.isMany()) { + refObjects = Collections.singletonList(object.get(ref)); + } else { + refObjects = (List) object.get(ref); + } + Iterator iter = refObjects.iterator(); + while (iter.hasNext()) { + DataObject refObject = (DataObject) iter.next(); + createObjectWithSubtree(root, refObject.getContainmentProperty(), refObject); + refObject = registry.get(refObject.getType().getName(), + Collections.singletonList(getPrimaryKey(refObject))); + if (ref.isMany()) { + newObject.getList(newObject.getType().getProperty(ref.getName())).add(refObject); + } else { + newObject.set(newObject.getType().getProperty(ref.getName()), refObject); + } + } + } + } + } + + private void addGraphToRegistry(DataObject graph1) { + Iterator i = graph1.getType().getProperties().iterator(); + while (i.hasNext()) { + Property p = (Property) i.next(); + Iterator objects = graph1.getList(p).iterator(); + while (objects.hasNext()) { + DataObject object = (DataObject) objects.next(); + Object pk = object.get(getPrimaryKeyName(object)); + if (logger.isDebugEnabled()) { + logger.debug("Adding object with pk " + pk + " to registry"); + } + registry.put(object.getType().getName(), Collections.singletonList(pk), object); + } + } + } + + private Object getPrimaryKey(DataObject object) { + String pkName = getPrimaryKeyName(object); + return object.get(pkName); + } + + private String getPrimaryKeyName(DataObject object) { + return (String) keys.get(object.getType().getName()); + } + + //JIRA-952 + //if the table and column have SDO type name and property name use it else use database table and column name + public void addPrimaryKey(String key) { + QualifiedColumn column = null; + if(this.config != null && this.config.isDatabaseSchemaNameSupported()){ + column = new QualifiedColumn(key, this.config.isDatabaseSchemaNameSupported()); + } + else{ + column = new QualifiedColumn(key); + } + + String tableName = column.getTableName(); + String columnName = column.getColumnName(); + String schemaName = column.getSchemaName(); + String qualifiedTableName = null; + + if(this.config != null && this.config.isDatabaseSchemaNameSupported()) { + qualifiedTableName = schemaName+"."+tableName; + } else { + qualifiedTableName = tableName; + } + MappingWrapper configWrapper = new MappingWrapper(this.config); + + String typeName = configWrapper.getTableTypeName(qualifiedTableName); + String propertyName = configWrapper.getColumnPropertyName(qualifiedTableName, columnName); + + if(typeName != null && propertyName != null) { + if (logger.isDebugEnabled()) { + logger.debug("Adding " + typeName + " " + propertyName + " to keys"); + } + keys.put(typeName, propertyName); + } else { + if (logger.isDebugEnabled()) { + logger.debug("Adding " + column.getTableName() + " " + column.getColumnName() + " to keys"); + } + keys.put(column.getTableName(), column.getColumnName()); + } + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/CollectionsUtil.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/CollectionsUtil.java new file mode 100644 index 0000000000..64e8826f76 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/CollectionsUtil.java @@ -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.
+ */
+package org.apache.tuscany.das.rdb.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ */
+public final class CollectionsUtil {
+
+ private CollectionsUtil() {
+
+ }
+
+ // Utilities
+ public static boolean disjoint(Collection c1, Collection c2) {
+
+ if (c1.size() > c2.size()) {
+ Collection c = c1;
+ c1 = c2;
+ c2 = c;
+ }
+ for (Iterator iterator = c2.iterator(); iterator.hasNext();) {
+ Object o = (Object)iterator.next();
+ if (c1.contains(o)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/ConfigUtil.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/ConfigUtil.java new file mode 100644 index 0000000000..c5c7a38aab --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/ConfigUtil.java @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.util; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.das.rdb.config.Command; +import org.apache.tuscany.das.rdb.config.Config; +import org.apache.tuscany.das.rdb.config.ConfigFactory; +import org.apache.tuscany.das.rdb.config.Create; +import org.apache.tuscany.das.rdb.config.Delete; +import org.apache.tuscany.das.rdb.config.Parameter; +import org.apache.tuscany.das.rdb.config.Update; + +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.impl.HelperProvider; + +/** + * Config util provides config-related utilities such as loading a Config + * instance from an InputStream + * + */ +public final class ConfigUtil { + + private ConfigUtil() { + + } + + public static Config loadConfig(InputStream configStream) { + + if (configStream == null) { + throw new RuntimeException("Cannot load configuration from a null InputStream. " + + "Possibly caused by an incorrect config xml file name"); + } + + HelperContext context = HelperProvider.getDefaultContext(); + ConfigFactory.INSTANCE.register(context); + XMLHelper helper = context.getXMLHelper(); + + try { + return (Config) helper.load(configStream).getRootObject(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public static String getParameters(Create createCommand) { + List parameters = createCommand.getParameters().getParameter(); + if(parameters != null) { + Iterator itr = parameters.iterator(); + StringBuffer serializedParameters = new StringBuffer(); + + while(itr.hasNext()) { + serializedParameters.append(((Parameter)itr.next()).getName()+" "); + } + return serializedParameters.toString().trim(); + } + else { + return null; + } + } + + public static String getParameters(Update updateCommand) { + List parameters = updateCommand.getParameters().getParameter(); + if(parameters != null) { + Iterator itr = parameters.iterator(); + StringBuffer serializedParameters = new StringBuffer(); + + while(itr.hasNext()) { + serializedParameters.append(((Parameter)itr.next()).getName()+" "); + } + return serializedParameters.toString().trim(); + } + else { + return null; + } + } + + public static String getParameters(Delete deleteCommand) { + List parameters = deleteCommand.getParameters().getParameter(); + if(parameters != null) { + Iterator itr = parameters.iterator(); + StringBuffer serializedParameters = new StringBuffer(); + + while(itr.hasNext()) { + serializedParameters.append(((Parameter)itr.next()).getName()+" "); + } + return serializedParameters.toString().trim(); + } + else { + return null; + } + } + + public static String getParameters(Command command) { + List parameters = command.getParameter(); + if(parameters != null) { + Iterator itr = parameters.iterator(); + StringBuffer serializedParameters = new StringBuffer(); + + while(itr.hasNext()) { + serializedParameters.append(((Parameter)itr.next()).getName()+" "); + } + return serializedParameters.toString().trim(); + } + else { + return null; + } + } +} diff --git a/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/DataObjectUtil.java b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/DataObjectUtil.java new file mode 100644 index 0000000000..b9649669e5 --- /dev/null +++ b/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/util/DataObjectUtil.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.rdb.util; + +import java.util.Iterator; +import java.util.List; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.ChangeSummary.Setting; +import commonj.sdo.helper.DataFactory; + +/** + */ +public final class DataObjectUtil { + + private DataObjectUtil() { + + } + + // Utilities + public static DataObject getRestoredCopy(DataObject changedDO) { + DataObject changedCopy = getCopy(changedDO); + restoreAttributeValues(changedCopy, changedDO); + return changedCopy; + } + + public static DataObject getCopy(DataObject original) { + + DataObject copy = DataFactory.INSTANCE.create(original.getType()); + + // Fill in values + Iterator i = original.getType().getProperties().iterator(); + while (i.hasNext()) { + Property feature = (Property) i.next(); + copy.set(feature, original.get(feature)); + } + return copy; + } + + /** + * @param changedCopy + * @return + */ + private static void restoreAttributeValues(DataObject changedCopy, DataObject changedDO) { + + ChangeSummary changeSummary = changedDO.getDataGraph().getChangeSummary(); + List changes = changeSummary.getOldValues(changedDO); + if (changes == null) { + return; + } + + Iterator i = changes.iterator(); + while (i.hasNext()) { + Setting s = (Setting) i.next(); + if (s.getProperty().getType().isDataType()) { + changedCopy.set(s.getProperty(), s.getValue()); + } + } + } + +} diff --git a/java/das/rdb/src/main/resources/META-INF/DISCLAIMER b/java/das/rdb/src/main/resources/META-INF/DISCLAIMER new file mode 100644 index 0000000000..a65af91c5a --- /dev/null +++ b/java/das/rdb/src/main/resources/META-INF/DISCLAIMER @@ -0,0 +1,7 @@ +Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
\ No newline at end of file diff --git a/java/das/rdb/src/main/resources/META-INF/LICENSE b/java/das/rdb/src/main/resources/META-INF/LICENSE new file mode 100644 index 0000000000..9597d92eb3 --- /dev/null +++ b/java/das/rdb/src/main/resources/META-INF/LICENSE @@ -0,0 +1,353 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + +=============================================================================================================== + +Other components and dependencies under Apache Software License 2.0 : + + log4j-1.2.14.jar - Apache Logging Services + derby 10.2.2.0.jar - Apache Derby + stax-api-1.0.1.jar - The Streaming API for XML (StAX) + wstx-asl-3.2.0.jar - WoodStox StAX implementation + standard-1.1.1.jar - The Apache Jackarta Taglibs + jstl-1.1.2.jar - The Apache Jackarta Taglibs + *.tld - The Apache Jackarta Taglibs + +=============================================================================================================== + + +Apache Tuscany SDO for Java Subcomponents +=========================================: + +The Tuscany SDO for Java release includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +License for the Service Data Objects JavaDoc and Interface Definition files. (tuscany-sdo-api-r2.1-1.0-incubating.jar) + +Permission to copy, make derivative works of, and distribute the Service Data Objects +JavaDoc and Interface Definition Files files in any medium without fee or royalty as part +of a compliant implementation of the Service Data Objects Specification is hereby granted. +The Service Data Objects Specification may be found at any of the following locations: + +http://dev2dev.bea.com/technologies/commonj/index.jsp +http://www.ibm.com/developerworks/library/specification/ws-sdo/ +http://oracle.com/technology/webservices/sca +https://www.sdn.sap.com/ +http://www.xcalia/xdn/specs/sdo + +THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES +ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS +SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS, +INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, +NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, +INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE +SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES. + +The name and trademarks of the Authors may NOT be used in any manner, including advertising or +publicity pertaining to the Service Component Architecture Specification or its contents without specific, +written prior permission. Title to copyright in the Service Data Objects Specification and the +JavaDoc and Interface Definition Files will at all times remain with the Authors. + +No other rights are granted by implication, estoppel or otherwise. + +================================================================================================================= + +For the Eclipse EMF components +(codegen-2.2.3.jar +codegen-ecore-2.2.3.jar +common-2.2.3.jar +ecore-2.2.3.jar +ecore-change-2.2.3.jar +ecore-xmi-2.2.3.jar +xsd-2.2.3.jar) + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the Program. + +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. + +=================================================================================================== diff --git a/java/das/rdb/src/main/resources/META-INF/NOTICE b/java/das/rdb/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..e9d98fc7f5 --- /dev/null +++ b/java/das/rdb/src/main/resources/META-INF/NOTICE @@ -0,0 +1,32 @@ +Apache Tuscany SDO for Java +Copyright 2006, 2007 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF), +sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted +projects until a further review indicates that the infrastructure, communications, +and decision making process have stabilized in a manner consistent with other successful +ASF projects. While incubation status is not necessarily a reflection of the completeness +or stability of the code, it does indicate that the project has yet to be fully endorsed +by the ASF. + +Unless otherwise indicated, all distribution made available by the Apache Software Foundation +is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL"). +A copy of the AL is provided with this distribution as the LICENSE.txt file present in the +root directory, and is also available at http://www.apache.org/licenses/. + +The terms and conditions governing the distribution may refer to the AL or other license +agreements, notices or terms and conditions. Some of these other license agreements may +include (but are not limited to): + + . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html) + +It is your obligation to read and accept all such terms and conditions prior to use of the +distribution. If term or condition is provided, please contact the Apache Software Foundation +to determine what terms and conditions govern that particular distribution. + +This product also includes software developed by the Open Service Oriented Architecture organisation +(http://osoa.org). The license for this software may be found in the LICENSE.txt file contained in this +distribution. diff --git a/java/das/rdb/src/main/resources/META-INF/README b/java/das/rdb/src/main/resources/META-INF/README new file mode 100644 index 0000000000..853d9546db --- /dev/null +++ b/java/das/rdb/src/main/resources/META-INF/README @@ -0,0 +1,35 @@ +Apache Tuscany DAS beta1 build (June, 2006) +=================+++++++========+========== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/java/das/rdb/src/main/resources/config.xsd b/java/das/rdb/src/main/resources/config.xsd new file mode 100644 index 0000000000..e48d01ed2a --- /dev/null +++ b/java/das/rdb/src/main/resources/config.xsd @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> +<xsd:schema + xmlns:config="http:///org.apache.tuscany.das.rdb/config.xsd" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http:///org.apache.tuscany.das.rdb/config.xsd" + elementFormDefault="qualified"> + + <xsd:element name="Config" type="config:Config"/> + + <xsd:complexType name="Config"> + <xsd:sequence> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="Command" + type="config:Command"/> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="Table" type="config:Table"/> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="Relationship" + type="config:Relationship"/> + <xsd:element maxOccurs="1" minOccurs="0" name="ConnectionInfo" + type="config:ConnectionInfo"/> + </xsd:sequence> + <xsd:attribute name="uri" type="xsd:string"/> + <xsd:attribute name="dataObjectModel" type="xsd:string"/> + <xsd:attribute name="databaseSchemaNameSupported" type="xsd:boolean" default="false"/> + <xsd:attribute name="generatedKeysSupported"> + <xsd:simpleType> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="true"/> + <xsd:enumeration value="false"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> + </xsd:complexType> + + <xsd:complexType name="ConnectionProperties"> + <xsd:attribute name="driverClass" type="xsd:string"/> + <xsd:attribute name="databaseURL" type="xsd:string"/> + <xsd:attribute name="userName" type="xsd:string" default=""/> + <xsd:attribute name="password" type="xsd:string" default=""/> + <xsd:attribute name="loginTimeout" type="xsd:int" default="0"/> + </xsd:complexType> + + <xsd:complexType name="ConnectionInfo"> + <xsd:sequence> + <xsd:element maxOccurs="1" minOccurs="0" name="ConnectionProperties" type="config:ConnectionProperties"/> + </xsd:sequence> + <xsd:attribute name="dataSource" type="xsd:string"/> + <xsd:attribute name="managedtx" type="xsd:boolean" default="true"/> + </xsd:complexType> + + + <xsd:complexType name="Command"> + <xsd:sequence> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="Parameter" + type="config:Parameter"/> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="ResultDescriptor" + type="config:ResultDescriptor"/> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string"/> + <xsd:attribute name="SQL" type="xsd:string"/> + <xsd:attribute name="kind" type="xsd:string"/> + </xsd:complexType> + <xsd:complexType name="Parameter"> + <xsd:attribute name="name" type="xsd:string"/> + <xsd:attribute name="columnType" type="xsd:string"/> + <xsd:attribute name="direction" type="xsd:string" default="IN"/> + <xsd:attribute name="index" type="xsd:int"/> + </xsd:complexType> + <xsd:complexType name="Parameters"> + <xsd:sequence> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="Parameter" type="config:Parameter"/> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="Relationship"> + <xsd:sequence> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="KeyPair" + type="config:KeyPair"/> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string"/> + <xsd:attribute name="primaryKeyTable" type="xsd:string"/> + <xsd:attribute name="foreignKeyTable" type="xsd:string"/> + <xsd:attribute name="many" type="xsd:boolean"/> + <xsd:attribute name="keyRestricted" type="xsd:boolean"/> + </xsd:complexType> + <xsd:complexType name="Table"> + <xsd:sequence> + <xsd:element maxOccurs="unbounded" minOccurs="0" name="Column" + type="config:Column"/> + <xsd:element maxOccurs="1" minOccurs="0" name="create" type="config:Create"/> + <xsd:element maxOccurs="1" minOccurs="0" name="update" type="config:Update"/> + <xsd:element maxOccurs="1" minOccurs="0" name="delete" type="config:Delete"/> + </xsd:sequence> + <xsd:attribute name="tableName" type="xsd:string"/> + <xsd:attribute name="typeName" type="xsd:string"/> + <xsd:attribute name="schemaName" type="xsd:string" default=""/> + </xsd:complexType> + <xsd:complexType name="Create"> + <xsd:sequence> + <xsd:element maxOccurs="1" minOccurs="0" name="Parameters" type="config:Parameters"/> + </xsd:sequence> + <xsd:attribute name="sql" type="xsd:string"/> + </xsd:complexType> + <xsd:complexType name="Update"> + <xsd:sequence> + <xsd:element maxOccurs="1" minOccurs="0" name="Parameters" type="config:Parameters"/> + </xsd:sequence> + <xsd:attribute name="sql" type="xsd:string"/> + </xsd:complexType> + <xsd:complexType name="Delete"> + <xsd:sequence> + <xsd:element maxOccurs="1" minOccurs="0" name="Parameters" type="config:Parameters"/> + </xsd:sequence> + <xsd:attribute name="sql" type="xsd:string"/> + </xsd:complexType> + <xsd:complexType name="KeyPair"> + <xsd:attribute name="primaryKeyColumn" type="xsd:string"/> + <xsd:attribute name="foreignKeyColumn" type="xsd:string"/> + </xsd:complexType> + <xsd:complexType name="Column"> + <xsd:attribute name="columnName" type="xsd:string"/> + <xsd:attribute name="propertyName" type="xsd:string"/> + <xsd:attribute name="converterClassName" type="xsd:string"/> + <xsd:attribute name="primaryKey" type="xsd:boolean"/> + <xsd:attribute name="generated" type="xsd:boolean"/> + <xsd:attribute name="collision" type="xsd:boolean"/> + <xsd:attribute name="managed" type="xsd:boolean" default="true"/> + </xsd:complexType> + <xsd:complexType name="ResultDescriptor"> + <xsd:attribute name="columnIndex" type="xsd:int" default="-1"/> + <xsd:attribute name="columnName" type="xsd:string"/> + <xsd:attribute name="tableName" type="xsd:string"/> + <xsd:attribute name="schemaName" type="xsd:string"/> + <xsd:attribute name="columnType" type="xsd:string"/> + </xsd:complexType> + +</xsd:schema> diff --git a/java/das/rdb/src/main/resources/dasmodel4.mdl b/java/das/rdb/src/main/resources/dasmodel4.mdl new file mode 100644 index 0000000000..476974975b --- /dev/null +++ b/java/das/rdb/src/main/resources/dasmodel4.mdl @@ -0,0 +1,4622 @@ +
+(object Petal
+ version 42
+ _written "Rose 4.5.8163.3"
+ charSet 0)
+
+(object Design "Logical View"
+ is_unit TRUE
+ is_loaded TRUE
+ defaults (object defaults
+ rightMargin 0.250000
+ leftMargin 0.250000
+ topMargin 0.250000
+ bottomMargin 0.500000
+ pageOverlap 0.250000
+ clipIconLabels TRUE
+ autoResize TRUE
+ snapToGrid TRUE
+ gridX 31
+ gridY 31
+ defaultFont (object Font
+ size 10
+ face "Arial"
+ bold FALSE
+ italics FALSE
+ underline FALSE
+ strike FALSE
+ color 0
+ default_color TRUE)
+ showMessageNum 3
+ showClassOfObject TRUE
+ notation "Unified")
+ root_usecase_package (object Class_Category "Use Case View"
+ quid "4362A29901BA"
+ exportControl "Public"
+ global TRUE
+ logical_models (list unit_reference_list)
+ logical_presentations (list unit_reference_list
+ (object UseCaseDiagram "Main"
+ quid "4362A2990259"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ root_category (object Class_Category "Logical View"
+ quid "4362A29901B9"
+ exportControl "Public"
+ global TRUE
+ subsystem "Component View"
+ quidu "4362A29901BB"
+ logical_models (list unit_reference_list
+ (object Class_Category "config"
+ attributes (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "nsURI"
+ value "http:///org.apache.tuscany.das.rdb/config.xsd")
+ (object Attribute
+ tool "Ecore"
+ name "basePackage"
+ value "org.apache.tuscany.das.rdb"))
+ quid "4362A2A10169"
+ exportControl "Public"
+ logical_models (list unit_reference_list
+ (object Class "Config"
+ quid "4362A2DE0045"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "uri"
+ quid "4362A337006B"
+ type "String")
+ (object ClassAttribute "dataSource"
+ quid "4485DF600233"
+ type "String")
+ (object ClassAttribute "dataObjectModel"
+ quid "449AB6CD0132"
+ type "String")))
+ (object Class "Command"
+ quid "4362A2EC01FE"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "name"
+ quid "4362A3EC02EC"
+ type "String")
+ (object ClassAttribute "SQL"
+ quid "4362A3EF0246"
+ type "String")
+ (object ClassAttribute "kind"
+ quid "437903E60321"
+ type "String")))
+ (object Class "Parameter"
+ quid "4362A3C902BA"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "name"
+ quid "4362A40600D7"
+ type "String")
+ (object ClassAttribute "columnType"
+ quid "4362A4090280"
+ type "String")))
+ (object Class "Relationship"
+ quid "4362A42E03A5"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "name"
+ quid "4362A73A0216"
+ type "String")
+ (object ClassAttribute "primaryKeyTable"
+ quid "4362A73D0329"
+ type "String")
+ (object ClassAttribute "foreignKeyTable"
+ quid "4362A74002FB"
+ type "String")
+ (object ClassAttribute "many"
+ quid "4362A7430241"
+ type "boolean")))
+ (object Class "Table"
+ quid "4362A43C0002"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "tableName"
+ quid "4362A7B2031D"
+ type "String")
+ (object ClassAttribute "typeName"
+ quid "4362A7C203A2"
+ type "String")
+ (object ClassAttribute "create"
+ quid "4362A7D0024E"
+ type "String")
+ (object ClassAttribute "update"
+ quid "4362A7D30220"
+ type "String")
+ (object ClassAttribute "delete"
+ quid "4362A7E1031B"
+ type "String")))
+ (object Class "KeyPair"
+ quid "4362A72E0010"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "primaryKeyColumn"
+ quid "4362A8E702A9"
+ type "String")
+ (object ClassAttribute "foreignKeyColumn"
+ quid "4362A8ED01AE"
+ type "String")))
+ (object Class "Column"
+ quid "4362A75C016B"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "columnName"
+ quid "4362A8BD02E5"
+ type "String")
+ (object ClassAttribute "propertyName"
+ quid "4362A8C001C7"
+ type "String")
+ (object ClassAttribute "converterClassName"
+ quid "4362A8C303A2"
+ type "String")
+ (object ClassAttribute "columnType"
+ quid "4362A8C903A0"
+ type "String")
+ (object ClassAttribute "primaryKey"
+ quid "437907F200F9"
+ type "boolean")
+ (object ClassAttribute "generated"
+ quid "4379083900BF"
+ type "boolean")
+ (object ClassAttribute "collision"
+ quid "437908E5012B"
+ type "boolean")))
+ (object Class "ResultDescriptor"
+ quid "437B57EF0008"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "columnName"
+ quid "437B5A6503BB"
+ type "String")
+ (object ClassAttribute "tableName"
+ quid "437B5A6B016B"
+ type "String")
+ (object ClassAttribute "columnType"
+ quid "437B5A6D033A"
+ type "String")
+ (object ClassAttribute "name"
+ quid "449AB74D03DF"
+ type "type"
+ initv "initval"))
+ language "Java")
+ (object Association "$UNNAMED$0"
+ quid "4362A3030323"
+ roles (list role_list
+ (object Role "$UNNAMED$1"
+ quid "4362A3040108"
+ supplier "Logical View::config::Config"
+ quidu "4362A2DE0045"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$2"
+ quid "4362A3040109"
+ supplier "Logical View::config::Command"
+ quidu "4362A2EC01FE"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$3"
+ quid "4362A3D302FA"
+ roles (list role_list
+ (object Role "$UNNAMED$4"
+ quid "4362A3D40143"
+ supplier "Logical View::config::Command"
+ quidu "4362A2EC01FE"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$5"
+ quid "4362A3D40144"
+ supplier "Logical View::config::Parameter"
+ quidu "4362A3C902BA"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$6"
+ quid "4362A448026C"
+ roles (list role_list
+ (object Role "$UNNAMED$7"
+ quid "4362A4490105"
+ supplier "Logical View::config::Config"
+ quidu "4362A2DE0045"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$8"
+ quid "4362A4490106"
+ supplier "Logical View::config::Table"
+ quidu "4362A43C0002"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$9"
+ quid "4362A44B0298"
+ roles (list role_list
+ (object Role "$UNNAMED$10"
+ quid "4362A44C01AA"
+ supplier "Logical View::config::Config"
+ quidu "4362A2DE0045"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$11"
+ quid "4362A44C01AB"
+ supplier "Logical View::config::Relationship"
+ quidu "4362A42E03A5"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$12"
+ quid "4362A76302A1"
+ roles (list role_list
+ (object Role "$UNNAMED$13"
+ quid "4362A7640090"
+ supplier "Logical View::config::Table"
+ quidu "4362A43C0002"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$14"
+ quid "4362A7640091"
+ supplier "Logical View::config::Column"
+ quidu "4362A75C016B"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$15"
+ quid "4362A771032E"
+ roles (list role_list
+ (object Role "$UNNAMED$16"
+ quid "4362A7720108"
+ supplier "Logical View::config::Relationship"
+ quidu "4362A42E03A5"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$17"
+ quid "4362A7720109"
+ supplier "Logical View::config::KeyPair"
+ quidu "4362A72E0010"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$18"
+ quid "437B59A10066"
+ roles (list role_list
+ (object Role "$UNNAMED$19"
+ quid "437B59A30145"
+ supplier "Logical View::config::Command"
+ quidu "4362A2EC01FE"
+ Containment "By Value"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$20"
+ quid "437B59A30146"
+ supplier "Logical View::config::ResultDescriptor"
+ quidu "437B57EF0008"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE))))
+ logical_presentations (list unit_reference_list
+ (object ClassDiagram "Main"
+ quid "4362A2A900AD"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list
+ (object ClassView "Class" "Logical View::config::KeyPair" @1
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1054, 1333)
+ label (object ItemLabel
+ Parent_View @1
+ location (809, 1227)
+ fill_color 13434879
+ nlines 1
+ max_width 490
+ justify 0
+ label "KeyPair")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4362A72E0010"
+ compartment (object Compartment
+ Parent_View @1
+ location (809, 1287)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 3
+ max_width 496)
+ width 508
+ height 236
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::config::Column" @2
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2015, 1519)
+ label (object ItemLabel
+ Parent_View @2
+ location (1756, 1288)
+ fill_color 13434879
+ nlines 1
+ max_width 518
+ justify 0
+ label "Column")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4362A75C016B"
+ compartment (object Compartment
+ Parent_View @2
+ location (1756, 1348)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 8
+ max_width 525)
+ width 536
+ height 486
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::config::Relationship" @3
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1054, 744)
+ label (object ItemLabel
+ Parent_View @3
+ location (829, 588)
+ fill_color 13434879
+ nlines 1
+ max_width 450
+ justify 0
+ label "Relationship")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4362A42E03A5"
+ compartment (object Compartment
+ Parent_View @3
+ location (829, 648)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 5
+ max_width 456)
+ width 468
+ height 336
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$15" @4
+ location (1081, 1063)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A771032E"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$16" @5
+ Parent_View @4
+ location (-97, -84)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A7720108"
+ client @4
+ supplier @3
+ line_style 3
+ origin_attachment (1080, 1063)
+ terminal_attachment (1080, 912))
+ (object RoleView "$UNNAMED$17" @6
+ Parent_View @4
+ location (-97, -84)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A7720109"
+ client @4
+ supplier @1
+ line_style 3
+ origin_attachment (1080, 1063)
+ terminal_attachment (1080, 1215)
+ label (object SegLabel @7
+ Parent_View @6
+ location (1135, 1112)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.327273
+ height 55
+ orientation 0))))
+ (object ClassView "Class" "Logical View::config::Table" @8
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1984, 837)
+ label (object ItemLabel
+ Parent_View @8
+ location (1814, 656)
+ fill_color 13434879
+ nlines 1
+ max_width 340
+ justify 0
+ label "Table")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4362A43C0002"
+ compartment (object Compartment
+ Parent_View @8
+ location (1814, 716)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 6
+ max_width 346)
+ width 358
+ height 386
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$12" @9
+ location (1807, 1153)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A76302A1"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$13" @10
+ Parent_View @9
+ location (1032, 6)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A7640090"
+ client @9
+ supplier @8
+ line_style 3
+ origin_attachment (1807, 1153)
+ terminal_attachment (1807, 1030))
+ (object RoleView "$UNNAMED$14" @11
+ Parent_View @9
+ location (1032, 6)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A7640091"
+ client @9
+ supplier @2
+ line_style 3
+ origin_attachment (1807, 1153)
+ terminal_attachment (1807, 1276)
+ label (object SegLabel @12
+ Parent_View @11
+ location (1861, 1166)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.109091
+ height 54
+ orientation 0))))
+ (object ClassView "Class" "Logical View::config::Parameter" @13
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (186, 806)
+ label (object ItemLabel
+ Parent_View @13
+ location (4, 700)
+ fill_color 13434879
+ nlines 1
+ max_width 364
+ justify 0
+ label "Parameter")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4362A3C902BA"
+ compartment (object Compartment
+ Parent_View @13
+ location (4, 760)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 3
+ max_width 371)
+ width 382
+ height 236
+ autoResize TRUE)
+ (object ClassView "Class" "Logical View::config::Config" @14
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1054, 186)
+ label (object ItemLabel
+ Parent_View @14
+ location (828, 55)
+ fill_color 13434879
+ nlines 1
+ max_width 452
+ justify 0
+ label "Config")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4362A2DE0045"
+ compartment (object Compartment
+ Parent_View @14
+ location (828, 115)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 4
+ max_width 450)
+ width 470
+ height 286
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$9" @15
+ location (1054, 452)
+ label (object SegLabel @16
+ Parent_View @15
+ location (1054, 393)
+ font (object Font
+ italics TRUE)
+ hidden TRUE
+ anchor 1
+ anchor_loc 1
+ nlines 1
+ max_width 600
+ justify 0
+ label ""
+ pctDist 0.500000
+ height 60
+ orientation 0)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A44B0298"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$10" @17
+ Parent_View @15
+ location (-93, -354)
+ label (object SegLabel @18
+ Parent_View @17
+ location (1013, 354)
+ hidden TRUE
+ anchor 1
+ anchor_loc 1
+ nlines 1
+ max_width 252
+ justify 0
+ label ""
+ pctDist 0.800000
+ height 42
+ orientation 0)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A44C01AA"
+ client @15
+ supplier @14
+ line_style 0)
+ (object RoleView "$UNNAMED$11" @19
+ Parent_View @15
+ location (-93, -354)
+ label (object SegLabel @20
+ Parent_View @19
+ location (1013, 526)
+ hidden TRUE
+ anchor 1
+ anchor_loc 1
+ nlines 1
+ max_width 252
+ justify 0
+ label ""
+ pctDist 0.597561
+ height 42
+ orientation 1)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A44C01AB"
+ client @15
+ supplier @3
+ line_style 0
+ label (object SegLabel @21
+ Parent_View @19
+ location (1011, 562)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.899471
+ height 44
+ orientation 1))))
+ (object AssociationViewNew "$UNNAMED$6" @22
+ location (1829, 247)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A448026C"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$7" @23
+ Parent_View @22
+ location (1023, -559)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A4490105"
+ client @22
+ supplier @14
+ line_style 3
+ origin_attachment (1829, 247)
+ terminal_attachment (1289, 247))
+ (object RoleView "$UNNAMED$8" @24
+ Parent_View @22
+ location (1023, -559)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A4490106"
+ client @22
+ supplier @8
+ vertices (list Points
+ (1829, 247)
+ (1972, 247)
+ (1972, 644))
+ line_style 3
+ origin_attachment (1829, 247)
+ terminal_attachment (1972, 644)
+ label (object SegLabel @25
+ Parent_View @24
+ location (2031, 441)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.625538
+ height 59
+ orientation 0))))
+ (object ClassView "Class" "Logical View::config::Command" @26
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (186, 217)
+ label (object ItemLabel
+ Parent_View @26
+ location (63, 86)
+ fill_color 13434879
+ nlines 1
+ max_width 246
+ justify 0
+ label "Command")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4362A2EC01FE"
+ compartment (object Compartment
+ Parent_View @26
+ location (63, 146)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 4
+ max_width 253)
+ width 264
+ height 286
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$3" @27
+ location (186, 523)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A3D302FA"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$4" @28
+ Parent_View @27
+ location (-279, -500)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A3D40143"
+ client @27
+ supplier @26
+ line_style 0)
+ (object RoleView "$UNNAMED$5" @29
+ Parent_View @27
+ location (-279, -500)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A3D40144"
+ client @27
+ supplier @13
+ line_style 0
+ label (object SegLabel @30
+ Parent_View @29
+ location (241, 600)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.473684
+ height 55
+ orientation 0))))
+ (object AssociationViewNew "$UNNAMED$0" @31
+ location (568, 213)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A3030323"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$1" @32
+ Parent_View @31
+ location (134, -469)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A3040108"
+ client @31
+ supplier @14
+ line_style 3
+ origin_attachment (568, 213)
+ terminal_attachment (819, 213))
+ (object RoleView "$UNNAMED$2" @33
+ Parent_View @31
+ location (134, -469)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4362A3040109"
+ client @31
+ supplier @26
+ line_style 3
+ origin_attachment (568, 213)
+ terminal_attachment (318, 213)
+ label (object SegLabel @34
+ Parent_View @33
+ location (360, 261)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.831858
+ height 48
+ orientation 0))))
+ (object ClassView "Class" "Logical View::config::ResultDescriptor" @35
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (465, 1240)
+ label (object ItemLabel
+ Parent_View @35
+ location (248, 1084)
+ fill_color 13434879
+ nlines 1
+ max_width 434
+ justify 0
+ label "ResultDescriptor")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "437B57EF0008"
+ compartment (object Compartment
+ Parent_View @35
+ location (248, 1144)
+ icon_style "Icon"
+ fill_color 16777215
+ anchor 2
+ nlines 5
+ max_width 431)
+ width 452
+ height 336
+ annotation 8
+ autoResize TRUE)
+ (object AssociationViewNew "$UNNAMED$18" @36
+ location (484, 626)
+ stereotype TRUE
+ line_color 3342489
+ quidu "437B59A10066"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$19" @37
+ Parent_View @36
+ location (50, -614)
+ stereotype TRUE
+ line_color 3342489
+ quidu "437B59A30145"
+ client @36
+ supplier @26
+ vertices (list Points
+ (484, 626)
+ (484, 347)
+ (318, 347))
+ line_style 3
+ origin_attachment (484, 626)
+ terminal_attachment (318, 347))
+ (object RoleView "$UNNAMED$20" @38
+ Parent_View @36
+ location (50, -614)
+ stereotype TRUE
+ line_color 3342489
+ quidu "437B59A30146"
+ client @36
+ supplier @35
+ line_style 3
+ origin_attachment (484, 626)
+ terminal_attachment (484, 1072)
+ label (object SegLabel @39
+ Parent_View @38
+ location (538, 1027)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.900000
+ height 54
+ orientation 0)))))))))
+ logical_presentations (list unit_reference_list
+ (object ClassDiagram "Main"
+ quid "4362A299025A"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list
+ (object CategoryView "Logical View::config" @40
+ location (682, 589)
+ label (object ItemLabel
+ Parent_View @40
+ location (538, 505)
+ fill_color 13434879
+ nlines 2
+ max_width 288
+ justify 0
+ label "config")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4362A2A10169"
+ width 300
+ height 180)))))
+ root_subsystem (object SubSystem "Component View"
+ quid "4362A29901BB"
+ physical_models (list unit_reference_list)
+ physical_presentations (list unit_reference_list
+ (object Module_Diagram "Main"
+ quid "4362A2990258"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ process_structure (object Processes
+ quid "4362A29901BC"
+ ProcsNDevs (list
+ (object Process_Diagram "Deployment View"
+ quid "4362A29901BE"
+ title "Deployment View"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ properties (object Properties
+ attributes (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "propertyId"
+ value "809135969")
+ (object Attribute
+ tool "Ecore"
+ name "default__Category"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "packageName"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "nsPrefix"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "nsURI"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "basePackage"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "prefix"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "annotation"
+ value "")))
+ (object Attribute
+ tool "Ecore"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "classifierName"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "constraints"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "xmlName"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "xmlContentKind"
+ value ("ContentKind" 0))
+ (object Attribute
+ tool "Ecore"
+ name "ContentKind"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "Unspecified"
+ value 0)
+ (object Attribute
+ tool "Ecore"
+ name "Empty"
+ value 1)
+ (object Attribute
+ tool "Ecore"
+ name "Simple"
+ value 2)
+ (object Attribute
+ tool "Ecore"
+ name "Mixed"
+ value 3)
+ (object Attribute
+ tool "Ecore"
+ name "ElementOnly"
+ value 4)))
+ (object Attribute
+ tool "Ecore"
+ name "annotation"
+ value "")))
+ (object Attribute
+ tool "Ecore"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "operationName"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "isUnique"
+ value TRUE)
+ (object Attribute
+ tool "Ecore"
+ name "annotation"
+ value "")))
+ (object Attribute
+ tool "Ecore"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "attributeName"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "isTransient"
+ value FALSE)
+ (object Attribute
+ tool "Ecore"
+ name "isVolatile"
+ value FALSE)
+ (object Attribute
+ tool "Ecore"
+ name "isChangeable"
+ value TRUE)
+ (object Attribute
+ tool "Ecore"
+ name "isUnsettable"
+ value FALSE)
+ (object Attribute
+ tool "Ecore"
+ name "isUnique"
+ value TRUE)
+ (object Attribute
+ tool "Ecore"
+ name "isID"
+ value FALSE)
+ (object Attribute
+ tool "Ecore"
+ name "visibility"
+ value ("VisibilityKind" 0))
+ (object Attribute
+ tool "Ecore"
+ name "VisibilityKind"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "Unspecified"
+ value 0)
+ (object Attribute
+ tool "Ecore"
+ name "None"
+ value 1)
+ (object Attribute
+ tool "Ecore"
+ name "Read-only"
+ value 2)
+ (object Attribute
+ tool "Ecore"
+ name "Read-write"
+ value 3)
+ (object Attribute
+ tool "Ecore"
+ name "Read-only unsettable"
+ value 4)
+ (object Attribute
+ tool "Ecore"
+ name "Read-write unsettable"
+ value 5)))
+ (object Attribute
+ tool "Ecore"
+ name "xmlName"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "xmlNamespace"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "xmlFeatureKind"
+ value ("FeatureKind" 0))
+ (object Attribute
+ tool "Ecore"
+ name "FeatureKind"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "Unspecified"
+ value 0)
+ (object Attribute
+ tool "Ecore"
+ name "Simple"
+ value 1)
+ (object Attribute
+ tool "Ecore"
+ name "Attribute"
+ value 2)
+ (object Attribute
+ tool "Ecore"
+ name "Element"
+ value 4)))
+ (object Attribute
+ tool "Ecore"
+ name "annotation"
+ value "")))
+ (object Attribute
+ tool "Ecore"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "referenceName"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "isTransient"
+ value FALSE)
+ (object Attribute
+ tool "Ecore"
+ name "isVolatile"
+ value FALSE)
+ (object Attribute
+ tool "Ecore"
+ name "isChangeable"
+ value TRUE)
+ (object Attribute
+ tool "Ecore"
+ name "isUnsettable"
+ value FALSE)
+ (object Attribute
+ tool "Ecore"
+ name "isResolveProxies"
+ value TRUE)
+ (object Attribute
+ tool "Ecore"
+ name "visibility"
+ value ("VisibilityKind" 0))
+ (object Attribute
+ tool "Ecore"
+ name "VisibilityKind"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "Unspecified"
+ value 0)
+ (object Attribute
+ tool "Ecore"
+ name "None"
+ value 1)
+ (object Attribute
+ tool "Ecore"
+ name "Read-only"
+ value 2)
+ (object Attribute
+ tool "Ecore"
+ name "Read-write"
+ value 3)
+ (object Attribute
+ tool "Ecore"
+ name "Read-only unsettable"
+ value 4)
+ (object Attribute
+ tool "Ecore"
+ name "Read-write unsettable"
+ value 5)))
+ (object Attribute
+ tool "Ecore"
+ name "xmlName"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "xmlNamespace"
+ value "")
+ (object Attribute
+ tool "Ecore"
+ name "xmlFeatureKind"
+ value ("FeatureKind" 0))
+ (object Attribute
+ tool "Ecore"
+ name "FeatureKind"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Ecore"
+ name "Unspecified"
+ value 0)
+ (object Attribute
+ tool "Ecore"
+ name "Simple"
+ value 1)
+ (object Attribute
+ tool "Ecore"
+ name "Attribute"
+ value 2)
+ (object Attribute
+ tool "Ecore"
+ name "Element"
+ value 4)))
+ (object Attribute
+ tool "Ecore"
+ name "annotation"
+ value "")))
+ (object Attribute
+ tool "DDL"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "DDL"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "DDL"
+ name "DataBase"
+ value ("DataBaseSet" 800))
+ (object Attribute
+ tool "DDL"
+ name "DataBaseSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "ANSI"
+ value 800)
+ (object Attribute
+ tool "DDL"
+ name "Oracle"
+ value 801)
+ (object Attribute
+ tool "DDL"
+ name "SQLServer"
+ value 802)
+ (object Attribute
+ tool "DDL"
+ name "Sybase"
+ value 803)
+ (object Attribute
+ tool "DDL"
+ name "Watcom"
+ value 804)))
+ (object Attribute
+ tool "DDL"
+ name "PrimaryKeyColumnName"
+ value "Id")
+ (object Attribute
+ tool "DDL"
+ name "PrimaryKeyColumnType"
+ value "NUMBER(5)")
+ (object Attribute
+ tool "DDL"
+ name "ViewName"
+ value "V_")
+ (object Attribute
+ tool "DDL"
+ name "TableName"
+ value "T_")
+ (object Attribute
+ tool "DDL"
+ name "InheritSuffix"
+ value "_V")
+ (object Attribute
+ tool "DDL"
+ name "DropClause"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "BaseViews"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "DDLScriptFilename"
+ value "DDL1.SQL")))
+ (object Attribute
+ tool "DDL"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "ColumnType"
+ value "VARCHAR")
+ (object Attribute
+ tool "DDL"
+ name "Length"
+ value "")
+ (object Attribute
+ tool "DDL"
+ name "NullsOK"
+ value TRUE)
+ (object Attribute
+ tool "DDL"
+ name "PrimaryKey"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "Unique"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "CompositeUnique"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "CheckConstraint"
+ value "")))
+ (object Attribute
+ tool "DDL"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "framework"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "IDL"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "CreateMissingDirectories"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "StopOnError"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "GeneratePreserveRegions"
+ value TRUE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "ImplementationType"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "ConstValue"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDefaultSpecifier"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "DefaultSpecifier"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "IDLElement"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "IDLSpecificationType"
+ value ("IDLSpecSet" 22))
+ (object Attribute
+ tool "IDL"
+ name "IDLSpecSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Interface"
+ value 22)
+ (object Attribute
+ tool "IDL"
+ name "Typedef"
+ value 54)
+ (object Attribute
+ tool "IDL"
+ name "Enumeration"
+ value 8)
+ (object Attribute
+ tool "IDL"
+ name "Const"
+ value 71)
+ (object Attribute
+ tool "IDL"
+ name "Exception"
+ value 61)
+ (object Attribute
+ tool "IDL"
+ name "Struct"
+ value 51)
+ (object Attribute
+ tool "IDL"
+ name "Union"
+ value 81)))))
+ (object Attribute
+ tool "IDL"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "IDL"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "GenerateIDLModule"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "InclusionProtectionSymbol"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "IncludeBySimpleName"
+ value FALSE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "IDL"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "IncludeBySimpleName"
+ value FALSE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "OperationIsOneWay"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "Context"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "Raises"
+ value "")))
+ (object Attribute
+ tool "IDL"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "CaseSpecifier"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "IDL"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "IsConst"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "ConstValue"
+ value "")))
+ (object Attribute
+ tool "IDL"
+ name "default__Has"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "NameIfUnlabeled"
+ value "the_$supplier")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "IDL"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "BoundedHasRelType"
+ value ("HasRelTypeSet" 47))
+ (object Attribute
+ tool "IDL"
+ name "HasRelTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "IDL"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "IDL"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "NameIfUnlabeled"
+ value "the_$supplier")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "IDL"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "BoundedRoleType"
+ value ("AssocTypeSet" 47))
+ (object Attribute
+ tool "IDL"
+ name "AssocTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "IDL"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "IDL"
+ name "default__Uses"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "GenerateForwardReference"
+ value FALSE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Subsystem"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Directory"
+ value "AUTO GENERATE")))
+ (object Attribute
+ tool "IDL"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "Java"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "CreateMissingDirectories"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "StopOnError"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "Java"
+ name "UsePrefixes"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "InstanceVariablePrefix"
+ value "m_")
+ (object Attribute
+ tool "Java"
+ name "ClassVariablePrefix"
+ value "s_")
+ (object Attribute
+ tool "Java"
+ name "DefaultAttributeDataType"
+ value "int")
+ (object Attribute
+ tool "Java"
+ name "DefaultOperationReturnType"
+ value "void")))
+ (object Attribute
+ tool "Java"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "GenerateDefaultConstructor"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "ConstructorIs"
+ value ("Ctor_Set" 62))
+ (object Attribute
+ tool "Java"
+ name "Ctor_Set"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Public"
+ value 62)
+ (object Attribute
+ tool "Java"
+ name "Protected"
+ value 63)
+ (object Attribute
+ tool "Java"
+ name "Private"
+ value 64)))
+ (object Attribute
+ tool "Java"
+ name "GenerateFinalizer"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "GenerateStaticInitializer"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "GenerateInstanceInitializer"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "CmIdentification"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "AdditionalImports"
+ value (value Text ""))))
+ (object Attribute
+ tool "Java"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "CmIdentification"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "AdditionalImports"
+ value (value Text ""))))
+ (object Attribute
+ tool "Java"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Abstract"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Static"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Native"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Synchronized"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Transient"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Volatile"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "ContainerClass"
+ value "")
+ (object Attribute
+ tool "Java"
+ name "InitialValue"
+ value "")
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Transient"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Volatile"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "propertyId"
+ value "360000002")
+ (object Attribute
+ tool "Oracle8"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "DDLScriptFilename"
+ value "DDL1.SQL")
+ (object Attribute
+ tool "Oracle8"
+ name "DropClause"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "PrimaryKeyColumnName"
+ value "_ID")
+ (object Attribute
+ tool "Oracle8"
+ name "PrimaryKeyColumnType"
+ value "NUMBER(5,0)")
+ (object Attribute
+ tool "Oracle8"
+ name "SchemaNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "SchemaNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TableNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TableNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TypeNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TypeNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "ViewNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "ViewNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "VarrayNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "VarrayNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "NestedTableNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "NestedTableNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "ObjectTableNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "ObjectTableNameSuffix"
+ value "")))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "IsSchema"
+ value FALSE)))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "OID"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "WhereClause"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CheckConstraint"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CollectionTypeLength"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CollectionTypePrecision"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CollectionTypeScale"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CollectionOfREFS"
+ value FALSE)))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "MethodKind"
+ value ("MethodKindSet" 1903))
+ (object Attribute
+ tool "Oracle8"
+ name "OverloadID"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "OrderNumber"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "IsReadNoDataState"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsReadNoProcessState"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsWriteNoDataState"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsWriteNoProcessState"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsSelfish"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerType"
+ value ("TriggerTypeSet" 1801))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerEvent"
+ value ("TriggerEventSet" 1601))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerText"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerReferencingNames"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerForEach"
+ value ("TriggerForEachSet" 1701))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerWhenClause"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "MethodKindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "MapMethod"
+ value 1901)
+ (object Attribute
+ tool "Oracle8"
+ name "OrderMethod"
+ value 1902)
+ (object Attribute
+ tool "Oracle8"
+ name "Function"
+ value 1903)
+ (object Attribute
+ tool "Oracle8"
+ name "Procedure"
+ value 1904)
+ (object Attribute
+ tool "Oracle8"
+ name "Operator"
+ value 1905)
+ (object Attribute
+ tool "Oracle8"
+ name "Constructor"
+ value 1906)
+ (object Attribute
+ tool "Oracle8"
+ name "Destructor"
+ value 1907)
+ (object Attribute
+ tool "Oracle8"
+ name "Trigger"
+ value 1908)
+ (object Attribute
+ tool "Oracle8"
+ name "Calculated"
+ value 1909)))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "AFTER"
+ value 1801)
+ (object Attribute
+ tool "Oracle8"
+ name "BEFORE"
+ value 1802)
+ (object Attribute
+ tool "Oracle8"
+ name "INSTEAD OF"
+ value 1803)))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerForEachSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "ROW"
+ value 1701)
+ (object Attribute
+ tool "Oracle8"
+ name "STATEMENT"
+ value 1702)))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerEventSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "INSERT"
+ value 1601)
+ (object Attribute
+ tool "Oracle8"
+ name "UPDATE"
+ value 1602)
+ (object Attribute
+ tool "Oracle8"
+ name "DELETE"
+ value 1603)
+ (object Attribute
+ tool "Oracle8"
+ name "INSERT OR UPDATE"
+ value 1604)
+ (object Attribute
+ tool "Oracle8"
+ name "INSERT OR DELETE"
+ value 1605)
+ (object Attribute
+ tool "Oracle8"
+ name "UPDATE OR DELETE"
+ value 1606)
+ (object Attribute
+ tool "Oracle8"
+ name "INSERT OR UPDATE OR DELETE"
+ value 1607)))))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "OrderNumber"
+ value "")))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "OrderNumber"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "IsUnique"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "NullsAllowed"
+ value TRUE)
+ (object Attribute
+ tool "Oracle8"
+ name "Length"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "Precision"
+ value "2")
+ (object Attribute
+ tool "Oracle8"
+ name "Scale"
+ value "6")
+ (object Attribute
+ tool "Oracle8"
+ name "IsIndex"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsPrimaryKey"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "CompositeUnique"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "CheckConstraint"
+ value "")))
+ (object Attribute
+ tool "Oracle8"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "Repository"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "cg"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "UseMSVC"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "HeaderFileExtension"
+ value "h")
+ (object Attribute
+ tool "cg"
+ name "HeaderFileBackupExtension"
+ value "h~")
+ (object Attribute
+ tool "cg"
+ name "HeaderFileTemporaryExtension"
+ value "h#")
+ (object Attribute
+ tool "cg"
+ name "CodeFileExtension"
+ value "cpp")
+ (object Attribute
+ tool "cg"
+ name "CodeFileBackupExtension"
+ value "cp~")
+ (object Attribute
+ tool "cg"
+ name "CodeFileTemporaryExtension"
+ value "cp#")
+ (object Attribute
+ tool "cg"
+ name "CreateMissingDirectories"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "StopOnError"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "ErrorLimit"
+ value 30)
+ (object Attribute
+ tool "cg"
+ name "Directory"
+ value "$ROSECPP_SOURCE")
+ (object Attribute
+ tool "cg"
+ name "PathSeparator"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "FileNameFormat"
+ value "128vx_b")
+ (object Attribute
+ tool "cg"
+ name "BooleanType"
+ value "int")
+ (object Attribute
+ tool "cg"
+ name "AllowTemplates"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AllowExplicitInstantiations"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AllowProtectedInheritance"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "CommentWidth"
+ value 60)
+ (object Attribute
+ tool "cg"
+ name "OneByValueContainer"
+ value "$targetClass")
+ (object Attribute
+ tool "cg"
+ name "OneByReferenceContainer"
+ value "$targetClass *")
+ (object Attribute
+ tool "cg"
+ name "OptionalByValueContainer"
+ value "OptionalByValue<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "OptionalByReferenceContainer"
+ value "$targetClass *")
+ (object Attribute
+ tool "cg"
+ name "FixedByValueContainer"
+ value "$targetClass[$limit]")
+ (object Attribute
+ tool "cg"
+ name "UnorderedFixedByValueContainer"
+ value "$targetClass[$limit]")
+ (object Attribute
+ tool "cg"
+ name "FixedByReferenceContainer"
+ value "$targetClass *[$limit]")
+ (object Attribute
+ tool "cg"
+ name "UnorderedFixedByReferenceContainer"
+ value "$targetClass *[$limit]")
+ (object Attribute
+ tool "cg"
+ name "BoundedByValueContainer"
+ value "BoundedListByValue<$targetClass,$limit>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedBoundedByValueContainer"
+ value "BoundedSetByValue<$targetClass,$limit>")
+ (object Attribute
+ tool "cg"
+ name "BoundedByReferenceContainer"
+ value "BoundedListByReference<$targetClass,$limit>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedBoundedByReferenceContainer"
+ value "BoundedSetByReference<$targetClass,$limit>")
+ (object Attribute
+ tool "cg"
+ name "UnboundedByValueContainer"
+ value "UnboundedListByValue<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedUnboundedByValueContainer"
+ value "UnboundedSetByValue<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "UnboundedByReferenceContainer"
+ value "UnboundedListByReference<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedUnboundedByReferenceContainer"
+ value "UnboundedSetByReference<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "QualifiedByValueContainer"
+ value "AssociationByValue<$qualtype, $qualcont>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedQualifiedByValueContainer"
+ value "DictionaryByValue<$qualtype, $qualcont>")
+ (object Attribute
+ tool "cg"
+ name "QualifiedByReferenceContainer"
+ value "AssociationByReference<$qualtype, $qualcont>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedQualifiedByReferenceContainer"
+ value "DictionaryByReference<$qualtype, $qualcont>")
+ (object Attribute
+ tool "cg"
+ name "GeneratePreserveRegions"
+ value TRUE)))
+ (object Attribute
+ tool "cg"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "ImplementationType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "ClassKey"
+ value "class")
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))
+ (object Attribute
+ tool "cg"
+ name "PutBodiesInSpec"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateDefaultConstructor"
+ value ("GenerateSet" 199))
+ (object Attribute
+ tool "cg"
+ name "DefaultConstructorVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "InlineDefaultConstructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "ExplicitDefaultConstructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateCopyConstructor"
+ value ("GenerateSet" 199))
+ (object Attribute
+ tool "cg"
+ name "CopyConstructorVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "InlineCopyConstructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "ExplicitCopyConstructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateDestructor"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "DestructorVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "DestructorKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "InlineDestructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateAssignmentOperation"
+ value ("GenerateSet" 199))
+ (object Attribute
+ tool "cg"
+ name "AssignmentVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "AssignmentKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "InlineAssignmentOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateEqualityOperations"
+ value ("GenerateSet" 199))
+ (object Attribute
+ tool "cg"
+ name "EqualityVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "EqualityKind"
+ value ("FriendKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "InlineEqualityOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateRelationalOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "RelationalVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "RelationalKind"
+ value ("FriendKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "InlineRelationalOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateStorageMgmtOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "StorageMgmtVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "InlineStorageMgmtOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateSubscriptOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "SubscriptVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "SubscriptKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "SubscriptResultType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InlineSubscriptOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateDereferenceOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DereferenceVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "DereferenceKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "DereferenceResultType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InlineDereferenceOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateIndirectionOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IndirectionVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "IndirectionKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "IndirectionResultType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InlineIndirectionOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateStreamOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "StreamVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "InlineStreamOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "ThreeKindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)))
+ (object Attribute
+ tool "cg"
+ name "KindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)))
+ (object Attribute
+ tool "cg"
+ name "FriendKindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "GenerateSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "DeclareAndDefine"
+ value 199)
+ (object Attribute
+ tool "cg"
+ name "DeclareOnly"
+ value 205)
+ (object Attribute
+ tool "cg"
+ name "DoNotDeclare"
+ value 206)))
+ (object Attribute
+ tool "cg"
+ name "VisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)))
+ (object Attribute
+ tool "cg"
+ name "ConstValue"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GenerateDefaultSpecifier"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DefaultSpecifier"
+ value "")))
+ (object Attribute
+ tool "cg"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))
+ (object Attribute
+ tool "cg"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "cg"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "cg"
+ name "AllowExtensionlessFileName"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InclusionProtectionSymbol"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "cg"
+ name "IncludeFormat"
+ value (value Text
+|// $package
+|#include "$file"
+|
+ ))
+ (object Attribute
+ tool "cg"
+ name "IncludeBySimpleName"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IncludePrecompiledHeader"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IncludeOrder"
+ value "AMIR")
+ (object Attribute
+ tool "cg"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "InliningStyle"
+ value ("InliningStyleSet" 207))
+ (object Attribute
+ tool "cg"
+ name "InliningStyleSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "InClassDeclaration"
+ value 208)
+ (object Attribute
+ tool "cg"
+ name "FollowingClassDeclaration"
+ value 207)))
+ (object Attribute
+ tool "cg"
+ name "TypesDefined"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "IncludeClosure"
+ value (value Text ""))))
+ (object Attribute
+ tool "cg"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))
+ (object Attribute
+ tool "cg"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "cg"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "cg"
+ name "AllowExtensionlessFileName"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IncludeFormat"
+ value (value Text
+|// $package
+|#include "$file"
+|
+ ))
+ (object Attribute
+ tool "cg"
+ name "IncludeBySimpleName"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IncludePrecompiledHeader"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "IncludeOrder"
+ value "AMIR")
+ (object Attribute
+ tool "cg"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "InliningStyle"
+ value ("InliningStyleSet" 207))
+ (object Attribute
+ tool "cg"
+ name "InliningStyleSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "InClassDeclaration"
+ value 208)
+ (object Attribute
+ tool "cg"
+ name "FollowingClassDeclaration"
+ value 207)))
+ (object Attribute
+ tool "cg"
+ name "TypesDefined"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "IncludeClosure"
+ value (value Text ""))))
+ (object Attribute
+ tool "cg"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "OperationKind"
+ value ("OperationKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "OperationKindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "OperationIsConst"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "OperationIsExplicit"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "Inline"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "EntryCode"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "ExitCode"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))
+ (object Attribute
+ tool "cg"
+ name "BodyAnnotations"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "OperationIsOneWay"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "Context"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "Raises"
+ value "")))
+ (object Attribute
+ tool "cg"
+ name "default__Has"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "Ordered"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "NameIfUnlabeled"
+ value "the_$supplier")
+ (object Attribute
+ tool "cg"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibility"
+ value ("DataMemberVisibilitySet" 14))
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)
+ (object Attribute
+ tool "cg"
+ name "AtRelationshipVisibility"
+ value 210)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutability"
+ value ("DataMemberMutabilitySet" 0))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutabilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Unrestricted"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Mutable"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Const"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberIsVolatile"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberFieldSize"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InitialValue"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "GenerateGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetName"
+ value "get_$relationship")
+ (object Attribute
+ tool "cg"
+ name "SetName"
+ value "set_$relationship")
+ (object Attribute
+ tool "cg"
+ name "GetSetKinds"
+ value ("GetSetKindsSet" 200))
+ (object Attribute
+ tool "cg"
+ name "GetSetKindsSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "ContainerClass"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "SelectorName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "SelectorType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConstSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "False"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "True"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Same_As_Function"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "GetSetByReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "SetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "ForwardReferenceOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "BoundedHasRelType"
+ value ("HasRelTypeSet" 47))
+ (object Attribute
+ tool "cg"
+ name "HasRelTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "cg"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "cg"
+ name "default__Association"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "NameIfUnlabeled"
+ value "the_$targetClass")))
+ (object Attribute
+ tool "cg"
+ name "default__Inherit"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "InstanceArguments"
+ value "")))
+ (object Attribute
+ tool "cg"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "ForwardReferenceOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "NameIfUnlabeled"
+ value "the_$targetClass")
+ (object Attribute
+ tool "cg"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberName"
+ value "$target")
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibility"
+ value ("DataMemberVisibilitySet" 14))
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)
+ (object Attribute
+ tool "cg"
+ name "AtRelationshipVisibility"
+ value 210)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutability"
+ value ("DataMemberMutabilitySet" 0))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutabilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Unrestricted"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Mutable"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Const"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberIsVolatile"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberFieldSize"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InitialValue"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "ContainerClass"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "ContainerGet"
+ value "$data.get($keys)")
+ (object Attribute
+ tool "cg"
+ name "ContainerSet"
+ value "$data.set($keys,$value)")
+ (object Attribute
+ tool "cg"
+ name "QualifiedContainer"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "AssocClassContainer"
+ value "$supplier *")
+ (object Attribute
+ tool "cg"
+ name "AssocClassInitialValue"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "GetSetKinds"
+ value ("GetSetKindsSet" 200))
+ (object Attribute
+ tool "cg"
+ name "GetSetKindsSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "GetSetByReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetName"
+ value "get_$target")
+ (object Attribute
+ tool "cg"
+ name "GetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConstSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "False"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "True"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Same_As_Function"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "InlineGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "SetName"
+ value "set_$target")
+ (object Attribute
+ tool "cg"
+ name "SetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetSetByReference"
+ value ("QualifiedGetSetByReferenceSet" 2))
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetSetByReferenceSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "False"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "True"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Same_As_GetSetByReference"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "GenerateQualifiedGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetName"
+ value "get_$target")
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "InlineQualifiedGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateQualifiedSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "QualifiedSetName"
+ value "set_$target")
+ (object Attribute
+ tool "cg"
+ name "QualifiedSetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineQualifiedSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateAssocClassDataMember"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassDataMemberName"
+ value "$target")
+ (object Attribute
+ tool "cg"
+ name "AssocClassDataMemberVisibility"
+ value ("DataMemberVisibilitySet" 14))
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)
+ (object Attribute
+ tool "cg"
+ name "AtRelationshipVisibility"
+ value 210)))
+ (object Attribute
+ tool "cg"
+ name "AssocClassDataMemberMutability"
+ value ("DataMemberMutabilitySet" 0))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutabilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Unrestricted"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Mutable"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Const"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "AssocClassDataMemberIsVolatile"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassGetSetKinds"
+ value ("GetSetKindsSet" 200))
+ (object Attribute
+ tool "cg"
+ name "GenerateAssocClassGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassGetName"
+ value "get_$target")
+ (object Attribute
+ tool "cg"
+ name "AssocClassGetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassGetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "InlineAssocClassGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateAssocClassSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassSetName"
+ value "set_$target")
+ (object Attribute
+ tool "cg"
+ name "AssocClassSetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineAssocClassSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassForwardReferenceOnly"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "BoundedRoleType"
+ value ("AssocTypeSet" 47))
+ (object Attribute
+ tool "cg"
+ name "AssocTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "cg"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "cg"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberName"
+ value "$attribute")
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibility"
+ value ("DataMemberVisibilitySet" 14))
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)
+ (object Attribute
+ tool "cg"
+ name "AtAttributeVisibility"
+ value 211)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutability"
+ value ("DataMemberMutabilitySet" 0))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutabilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Unrestricted"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Mutable"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Const"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberIsVolatile"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberFieldSize"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GenerateGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetName"
+ value "get_$attribute")
+ (object Attribute
+ tool "cg"
+ name "SetName"
+ value "set_$attribute")
+ (object Attribute
+ tool "cg"
+ name "GetSetKinds"
+ value ("GetSetKindsSet" 200))
+ (object Attribute
+ tool "cg"
+ name "GetSetKindsSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "GetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConstSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "False"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "True"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Same_As_Function"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "GetSetByReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "SetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "CaseSpecifier"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "IsReadOnly"
+ value FALSE)))
+ (object Attribute
+ tool "cg"
+ name "default__Uses"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "ForwardReferenceOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "BodyReferenceOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateForwardReference"
+ value FALSE)))
+ (object Attribute
+ tool "cg"
+ name "default__Subsystem"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "cg"
+ name "DirectoryIsOnSearchList"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "PrecompiledHeader"
+ value "")))
+ (object Attribute
+ tool "cg"
+ name "default__Category"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "IsNamespace"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "Indent"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))))
+ (object Attribute
+ tool "MSVC"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "MSVC"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Version"
+ value "5.0")))
+ (object Attribute
+ tool "MSVC"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCClassTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCClassTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Interface_Part"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Connection_Part"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Class_Factory"
+ value 3)))
+ (object Attribute
+ tool "MSVC"
+ name "CObjectFunctionality"
+ value ("CObjectFunctionalitySet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "CObjectFunctionalitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Dynamic"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Dyncreate"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Serial"
+ value 3)))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateOverrideGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "GenerateDataGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DATA_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateFieldGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_FIELD_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateMessageGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "GenerateMessageMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_MSG_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "MESSAGE_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "OLEFactory"
+ value ("OLEFactorySet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "OLEFactorySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Built_in"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Simple"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Licensed"
+ value 3)))
+ (object Attribute
+ tool "MSVC"
+ name "OLEName"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "OLEClassID"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GenerateOLECtlType"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "OLECtlType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GenerateOLETypeLib"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "OLETypeLibID"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "OLETypeLibMajor"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "OLETypeLibMinor"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GeneratePropPageIDs"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "OLEPropPageIDs"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateDispatchMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "StockProperties"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "StockFunctions"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DispatchDefValue"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GenerateDispIdEnum"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISP_ID_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateInterfaceMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "INTERFACE_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "InitInterface"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GenerateEventMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENT_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "EVENT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "StockEvents"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateEventSinkMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENTSINK_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENTSINK_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "EVENTSINK_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "PropNotifySinks"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateConnectionMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "CONNECTION_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "ConnectionPointIID"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "InheritanceType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "OLECommands"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "MFCDeclares"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "MFCImplements"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "ATL_Declares"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateCOMMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "COM_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateConnectionPointMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "CONNECTION_POINT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateMsgMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "MSG_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GeneratePropertyMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "PROPERTY_MAP_Entries"
+ value (value Text ""))))
+ (object Attribute
+ tool "MSVC"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCOperationTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCOperationTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Virtual_Override"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Message_Handler"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Dispatch_Handler"
+ value 3)
+ (object Attribute
+ tool "MSVC"
+ name "Event_Firing_Function"
+ value 4)
+ (object Attribute
+ tool "MSVC"
+ name "Event_Sink_Handler"
+ value 5)
+ (object Attribute
+ tool "MSVC"
+ name "Std_OLE_Method"
+ value 6)
+ (object Attribute
+ tool "MSVC"
+ name "Command_Parser"
+ value 7)
+ (object Attribute
+ tool "MSVC"
+ name "Property_Get_Function"
+ value 8)
+ (object Attribute
+ tool "MSVC"
+ name "Property_Set_Function"
+ value 9)
+ (object Attribute
+ tool "MSVC"
+ name "Property_Notify_Function"
+ value 10)
+ (object Attribute
+ tool "MSVC"
+ name "Macro_Generated_Function"
+ value 11)))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_MSG_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "MESSAGE_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "EVENT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENTSINK_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "EVENTSINK_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "CallType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "BodyImage"
+ value (value Text ""))))
+ (object Attribute
+ tool "MSVC"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCAttributeTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCAttributeTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Member_Property"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Get_Set_Property"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Dialog_Data"
+ value 3)
+ (object Attribute
+ tool "MSVC"
+ name "Field_Data"
+ value 4)
+ (object Attribute
+ tool "MSVC"
+ name "Stock_Property"
+ value 5)))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "PointerBase"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "CallType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "StockPropertyImplementation"
+ value "")))
+ (object Attribute
+ tool "MSVC"
+ name "default__Has"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCAttributeTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCAttributeTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Member_Property"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Get_Set_Property"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Dialog_Data"
+ value 3)
+ (object Attribute
+ tool "MSVC"
+ name "Field_Data"
+ value 4)
+ (object Attribute
+ tool "MSVC"
+ name "Stock_Property"
+ value 5)))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "PointerBase"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "CallType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "StockPropertyImplementation"
+ value "")))
+ (object Attribute
+ tool "MSVC"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCAttributeTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCAttributeTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Member_Property"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Get_Set_Property"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Dialog_Data"
+ value 3)
+ (object Attribute
+ tool "MSVC"
+ name "Field_Data"
+ value 4)
+ (object Attribute
+ tool "MSVC"
+ name "Stock_Property"
+ value 5)))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "PointerBase"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "CallType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "StockPropertyImplementation"
+ value "")))
+ (object Attribute
+ tool "MSVC"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "GenerateIncludesGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_INCLUDES_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateInsertLocation"
+ value FALSE)))
+ (object Attribute
+ tool "MSVC"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "GenerateIncludesGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_INCLUDES_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateInsertLocation"
+ value FALSE)))
+ (object Attribute
+ tool "cg"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "SCC"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "TypeLibImporter"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "propertyId"
+ value "783606378")
+ (object Attribute
+ tool "Visual Basic"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Visual Basic"
+ name "CreatableSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Visual Basic"
+ name "Private"
+ value 221)
+ (object Attribute
+ tool "Visual Basic"
+ name "PublicNotCreatable"
+ value 213)
+ (object Attribute
+ tool "Visual Basic"
+ name "SingleUse"
+ value 214)
+ (object Attribute
+ tool "Visual Basic"
+ name "GlobalSingleUse"
+ value 215)
+ (object Attribute
+ tool "Visual Basic"
+ name "MultiUse"
+ value 219)
+ (object Attribute
+ tool "Visual Basic"
+ name "GlobalMultiUse"
+ value 220)))
+ (object Attribute
+ tool "Visual Basic"
+ name "OptionBase"
+ value "0")
+ (object Attribute
+ tool "Visual Basic"
+ name "OptionExplicit"
+ value TRUE)
+ (object Attribute
+ tool "Visual Basic"
+ name "OptionCompare"
+ value ("CompareSet" 202))
+ (object Attribute
+ tool "Visual Basic"
+ name "Creatable"
+ value ("CreatableSet" 221))
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateInitialization"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateTermination"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "CollectionClass"
+ value "Collection")
+ (object Attribute
+ tool "Visual Basic"
+ name "CompareSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Visual Basic"
+ name "None"
+ value 202)
+ (object Attribute
+ tool "Visual Basic"
+ name "Binary"
+ value 203)
+ (object Attribute
+ tool "Visual Basic"
+ name "Text"
+ value 204)))))
+ (object Attribute
+ tool "Visual Basic"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Visual Basic"
+ name "OperationName"
+ value "$operation")
+ (object Attribute
+ tool "Visual Basic"
+ name "LibraryName"
+ value "")
+ (object Attribute
+ tool "Visual Basic"
+ name "AliasName"
+ value "")
+ (object Attribute
+ tool "Visual Basic"
+ name "IsStatic"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "EntryCode"
+ value (value Text ""))
+ (object Attribute
+ tool "Visual Basic"
+ name "ExitCode"
+ value (value Text ""))))
+ (object Attribute
+ tool "Visual Basic"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Visual Basic"
+ name "IsConst"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "New"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "WithEvents"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "Subscript"
+ value "")
+ (object Attribute
+ tool "Visual Basic"
+ name "NameIfUnlabeled"
+ value "the$supplier")
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "Visual Basic"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateGetOperation"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateSetOperation"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateLetOperation"
+ value FALSE)))
+ (object Attribute
+ tool "Visual Basic"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Visual Basic"
+ name "New"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "WithEvents"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "Subscript"
+ value "")
+ (object Attribute
+ tool "Visual Basic"
+ name "NameIfUnlabeled"
+ value "the$supplier")
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "Visual Basic"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateGetOperation"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateSetOperation"
+ value FALSE)
+ (object Attribute
+ tool "Visual Basic"
+ name "GenerateLetOperation"
+ value FALSE)))
+ (object Attribute
+ tool "Visual Basic"
+ name "default__Inherit"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Visual Basic"
+ name "ImplementsDelegation"
+ value TRUE)))
+ (object Attribute
+ tool "Visual Basic"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Visual Basic"
+ name "ProjectFile"
+ value "")))
+ (object Attribute
+ tool "Visual Basic"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "VisualStudio"
+ name "HiddenTool"
+ value FALSE))
+ quid "4362A29901BD"))
|