diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-02 22:26:03 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-02 22:26:03 +0000 |
commit | b8bb66d4a6e9a0951776e847538607e9e9aa9668 (patch) | |
tree | 4aac2bbda884249e126287f5c0988812074e0adc /das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder | |
parent | 1eb7f978e2d2ad83d1ba7b8dab20f635a0293bb9 (diff) |
Removing temporary release candidate tag
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@832154 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder')
12 files changed, 0 insertions, 1650 deletions
diff --git a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java deleted file mode 100644 index 58e1fd3ff0..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DefaultConverter.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DefaultConverter.java deleted file mode 100644 index a08f184b9a..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DefaultConverter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/GraphBuilderMetadata.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/GraphBuilderMetadata.java deleted file mode 100644 index 54afe95168..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/GraphBuilderMetadata.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * 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.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.util.DataObjectUtil; -import org.apache.tuscany.sdo.util.SDOUtil; - -import commonj.sdo.Property; -import commonj.sdo.Type; -import commonj.sdo.helper.TypeHelper; - -/** - */ -public class GraphBuilderMetadata { - - private MappingWrapper configWrapper; - - private final Collection resultSets = new ArrayList(); - - private String typeURI; - - private Type rootType; - - private TypeHelper typeHelper = SDOUtil.createTypeHelper(); - - 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() { - - DataObjectUtil.initRuntime(); - - Type root = SDOUtil.createType(typeHelper, getDefaultURI(), "DataGraphRoot", false); - - 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(typeHelper, getDefaultURI(), tableName, false); - Property property = SDOUtil.createProperty(root, tableName, tableType); - SDOUtil.setMany(property, true); - SDOUtil.setContainment(property, true); - } - } - - // 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(typeHelper, getDefaultURI() + "/DataGraphRoot", "DataGraphRoot", false); - - List types = SDOUtil.getTypes(typeHelper, typeURI); - 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() { - if (this.typeURI == null) { - return SDOUtil.getTypes(typeHelper, getDefaultURI()); - } - - List types = SDOUtil.getTypes(typeHelper, typeURI); - types.add(rootType); - return types; - - } - -} diff --git a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/MultiTableRegistry.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/MultiTableRegistry.java deleted file mode 100644 index 7a96d7f66a..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/MultiTableRegistry.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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; - - } - -}
\ No newline at end of file diff --git a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultMetadata.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultMetadata.java deleted file mode 100644 index 8d3ca88c8e..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultMetadata.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * 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.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; - - //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 = ""; - 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); - - if (columnName.contains("_ID")) { - String colName = ""; - 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); - } - - Iterator i = impliedRelationships.keySet().iterator(); - while (i.hasNext()) { - String columnName = (String) i.next(); - String pkTableName = columnName.substring(0, columnName.indexOf("_ID")); - 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); - } - } - } - - } - - 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 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/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetProcessor.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetProcessor.java deleted file mode 100644 index 0455be0c4c..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetProcessor.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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()) { - continue; - } - - String tableName = rawDataFromRow.getTableName(); - DataObject tableObject = registry.get(tableName, rawDataFromRow.getPrimaryKeyValues()); - if (tableObject == null) { - 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); - } - tableObjects.put(tableName, tableObject); - } - - tableObjects.processRelationships(); - - } - -} diff --git a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetRow.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetRow.java deleted file mode 100644 index 8dafa3f5e5..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/ResultSetRow.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * 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.HashMap; -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); - } - - } - - public void processRecursiveRow(ResultSet rs) throws SQLException { - this.allTableData = new ArrayList(); - int i = 1; - if (this.logger.isDebugEnabled()) { - this.logger.debug(""); - } - - while (i <= metadata.getResultSetSize()) { - if (this.logger.isDebugEnabled()) { - this.logger.debug(""); - } - 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++; - } - } - } - - /** - * @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/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/RowObjects.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/RowObjects.java deleted file mode 100644 index c7f200cb1e..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/RowObjects.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/SingleTableRegistry.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/SingleTableRegistry.java deleted file mode 100644 index c83b0bbfa2..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/SingleTableRegistry.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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; - } - -} diff --git a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableData.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableData.java deleted file mode 100644 index 7f92fcd80e..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableData.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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; - - 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); - } - - 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; - } - primaryKey.add(data); - } - } - - 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; - } -} diff --git a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableRegistry.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableRegistry.java deleted file mode 100644 index 42d8751b03..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/TableRegistry.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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); -}
\ No newline at end of file diff --git a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/schema/ResultSetTypeMap.java b/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/schema/ResultSetTypeMap.java deleted file mode 100644 index 7f3bf5b5a6..0000000000 --- a/das-java/tags/1.0-incubating-beta1-rc3/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/schema/ResultSetTypeMap.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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", "ByteArray"); - - case Types.DATE: - case Types.TIME: - case Types.TIMESTAMP: - return helper.getType("commonj.sdo", "Date"); - - case Types.CLOB: - return helper.getType("commonj.sdo", "Clob"); - - case Types.BLOB: - return helper.getType("commonj.sdo", "Blob"); - - case Types.ARRAY: - return helper.getType("commonj.sdo", "Array"); - - 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); - } - -} |