Author: shawkins
Date: 2010-03-18 14:26:59 -0400 (Thu, 18 Mar 2010)
New Revision: 1974
Added:
trunk/client-jdbc/src/main/java/org/teiid/jdbc/MetadataProvider.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/ParameterMetaDataImpl.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsMetadataWithProvider.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStaticMetadataProvider.java
Removed:
trunk/client-jdbc/src/main/java/com/
trunk/client-jdbc/src/main/java/org/teiid/jdbc/AbstractMetadataProvider.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultsMetadataProvider.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultsMetadataWithProvider.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/StaticMetadataProvider.java
trunk/client/src/main/java/com/metamatrix/jdbc/
trunk/test-integration/common/src/test/java/com/metamatrix/connector/
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsMetadataWithProvider.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStaticMetadataProvider.java
Modified:
trunk/client-jdbc/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/DeferredMetadataProvider.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultSetImpl.java
trunk/client/src/main/java/com/metamatrix/dqp/client/MetadataResult.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
Log:
TEIID-1020 adding an implementation of ParameterMetadata
Modified: trunk/client/src/main/java/com/metamatrix/dqp/client/MetadataResult.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/client/MetadataResult.java 2010-03-18
16:18:20 UTC (rev 1973)
+++ trunk/client/src/main/java/com/metamatrix/dqp/client/MetadataResult.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -33,34 +33,35 @@
public class MetadataResult implements Externalizable {
private static final long serialVersionUID = -1520482281079030324L;
private Map[] columnMetadata;
- private int parameterCount;
+ private Map[] parameterMetadata;
public MetadataResult() {
}
- public MetadataResult(Map[] columnMetadata, int parameterCount) {
+ public MetadataResult(Map[] columnMetadata, Map[] parameterMetadata) {
super();
this.columnMetadata = columnMetadata;
- this.parameterCount = parameterCount;
+ this.parameterMetadata = parameterMetadata;
}
public Map[] getColumnMetadata() {
return columnMetadata;
}
- public int getParameterCount() {
- return parameterCount;
+
+ public Map[] getParameterMetadata() {
+ return parameterMetadata;
}
@Override
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
columnMetadata = ExternalizeUtil.readArray(in, Map.class);
- parameterCount = in.readInt();
+ parameterMetadata = ExternalizeUtil.readArray(in, Map.class);
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizeUtil.writeArray(out, columnMetadata);
- out.writeInt(parameterCount);
+ ExternalizeUtil.writeArray(out, parameterMetadata);
}
}
Deleted: trunk/client-jdbc/src/main/java/org/teiid/jdbc/AbstractMetadataProvider.java
===================================================================
---
trunk/client-jdbc/src/main/java/org/teiid/jdbc/AbstractMetadataProvider.java 2010-03-18
16:18:20 UTC (rev 1973)
+++
trunk/client-jdbc/src/main/java/org/teiid/jdbc/AbstractMetadataProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.jdbc;
-
-import java.sql.SQLException;
-
-/**
- */
-public abstract class AbstractMetadataProvider implements ResultsMetadataProvider {
- public String getStringValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException {
- return (String) getValue(columnIndex, metadataPropertyKey);
- }
-
- public int getIntValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException {
- return ((Integer) getValue(columnIndex, metadataPropertyKey)).intValue();
- }
-
- public boolean getBooleanValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException {
- return ((Boolean) getValue(columnIndex, metadataPropertyKey)).booleanValue();
- }
-}
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2010-03-18
16:18:20 UTC (rev 1973)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -464,7 +464,7 @@
}
private ResultSet createResultSet(List records, Map[] columnMetadata) throws
SQLException {
- ResultSetMetaData rsmd =
ResultsMetadataWithProvider.newInstance(StaticMetadataProvider.createWithData(columnMetadata,
0));
+ ResultSetMetaData rsmd = new ResultSetMetaDataImpl(new
MetadataProvider(columnMetadata));
return createResultSet(records, rsmd);
}
@@ -488,7 +488,7 @@
for (int i = 0; i < columnNames.length; i++) {
metadata[i] = getColumnMetadata(null, columnNames[i], dataTypes[i],
ResultsMetadataConstants.NULL_TYPES.UNKNOWN);
}
- return new ResultSetImpl(resultsMsg, stmt,
ResultsMetadataWithProvider.newInstance(StaticMetadataProvider.createWithData(metadata,
0)), 0);
+ return new ResultSetImpl(resultsMsg, stmt, new ResultSetMetaDataImpl(new
MetadataProvider(metadata)), 0);
}
private ResultsMessage createDummyResultsMessage(String[] columnNames, String[]
dataTypes, List records) {
@@ -1791,7 +1791,7 @@
metadataList[16] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." +
DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATETIME_SUB, MMJDBCSQLTypeInfo.INTEGER,
ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE);//$NON-NLS-1$
metadataList[17] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." +
DATA_TYPES, JDBCColumnNames.TYPE_INFO.NUM_PREC_RADIX, MMJDBCSQLTypeInfo.INTEGER,
ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE,
Boolean.FALSE);//$NON-NLS-1$
- ResultSetMetaData rmetadata =
ResultsMetadataWithProvider.newInstance(StaticMetadataProvider.createWithData(metadataList,
0));
+ ResultSetMetaData rmetadata = new ResultSetMetaDataImpl(new
MetadataProvider(metadataList));
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTypes_success"));
//$NON-NLS-1$
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/DeferredMetadataProvider.java
===================================================================
---
trunk/client-jdbc/src/main/java/org/teiid/jdbc/DeferredMetadataProvider.java 2010-03-18
16:18:20 UTC (rev 1973)
+++
trunk/client-jdbc/src/main/java/org/teiid/jdbc/DeferredMetadataProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -36,44 +36,30 @@
* This metadata provider starts with just column names and types (provided in the
response)
* but must lazily load the rest of the metadata when necessary.
*/
-public class DeferredMetadataProvider extends AbstractMetadataProvider {
- private StaticMetadataProvider staticProvider;
-
+public class DeferredMetadataProvider extends MetadataProvider {
private StatementImpl statement;
private long requestID;
- DeferredMetadataProvider() {
+ public DeferredMetadataProvider(String[] columnNames, String[] columnTypes,
StatementImpl statement, long requestID) {
+ super(loadPartialMetadata(columnNames, columnTypes));
+ this.statement = statement;
+ this.requestID = requestID;
}
- public static DeferredMetadataProvider createWithInitialData(String[] columnNames,
String[] columnTypes, StatementImpl statement, long requestID) {
- if(columnNames == null || columnTypes == null || columnNames.length !=
columnTypes.length) {
+ static Map[] loadPartialMetadata(String[] columnNames, String[] columnTypes) {
+ if(columnNames == null || columnTypes == null || columnNames.length !=
columnTypes.length) {
Object[] params = new Object[] {
StringUtil.toString(columnNames), StringUtil.toString(columnTypes)
};
throw new
IllegalArgumentException(JDBCPlugin.Util.getString("DeferredMetadataProvider.Invalid_data",
params)); //$NON-NLS-1$
}
-
- DeferredMetadataProvider provider = null;
- provider = new DeferredMetadataProvider();
- provider.setDeferredLookupAttributes(statement, requestID);
- provider.loadPartialMetadata(columnNames, columnTypes);
- return provider;
- }
-
- private void setDeferredLookupAttributes(StatementImpl statement, long requestID) {
- this.statement = statement;
- this.requestID = requestID;
- }
-
- private void loadPartialMetadata(String[] columnNames, String[] columnTypes) {
Map[] columnMetadata = new Map[columnNames.length];
for(int i=0; i<columnNames.length; i++) {
columnMetadata[i] = new HashMap();
columnMetadata[i].put(ResultsMetadataConstants.ELEMENT_NAME,
columnNames[i]);
columnMetadata[i].put(ResultsMetadataConstants.DATA_TYPE, columnTypes[i]);
}
-
- this.staticProvider = StaticMetadataProvider.createWithData(columnMetadata, -1);
+ return columnMetadata;
}
private void loadFullMetadata() throws SQLException {
@@ -85,33 +71,19 @@
} catch (MetaMatrixProcessingException e) {
throw TeiidSQLException.create(e);
}
- this.staticProvider =
StaticMetadataProvider.createWithData(results.getColumnMetadata(),
results.getParameterCount());
+ this.metadata = results.getColumnMetadata();
}
- public int getColumnCount() throws SQLException {
- return staticProvider.getColumnCount();
- }
-
+ @Override
public Object getValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException {
- Object value = staticProvider.getValue(columnIndex, metadataPropertyKey);
+ Object value = super.getValue(columnIndex, metadataPropertyKey);
if(value == null) {
loadFullMetadata();
- value = staticProvider.getValue(columnIndex, metadataPropertyKey);
+ value = super.getValue(columnIndex, metadataPropertyKey);
}
return value;
}
- public int getParameterCount() throws SQLException {
- int count = staticProvider.getParameterCount();
-
- if(count < 0) {
- loadFullMetadata();
- count = staticProvider.getParameterCount();
- }
-
- return count;
- }
-
}
Copied: trunk/client-jdbc/src/main/java/org/teiid/jdbc/MetadataProvider.java (from rev
1973, trunk/client-jdbc/src/main/java/org/teiid/jdbc/StaticMetadataProvider.java)
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/MetadataProvider.java
(rev 0)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/MetadataProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.sql.SQLException;
+import java.util.Map;
+
+
+/**
+ */
+public class MetadataProvider {
+
+ // Map of detail maps -- <columnIndex, Map<propertyName,
metadataObject>>
+ protected Map[] metadata;
+
+ public MetadataProvider(Map[] metadata) {
+ this.metadata = metadata;
+ }
+
+ public Object getValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException {
+ if(columnIndex < 0 || columnIndex >= metadata.length) {
+ throw new
SQLException(JDBCPlugin.Util.getString("StaticMetadataProvider.Invalid_column",
columnIndex)); //$NON-NLS-1$
+ }
+
+ Map column = this.metadata[columnIndex];
+ return column.get(metadataPropertyKey);
+ }
+
+ public int getColumnCount() throws SQLException {
+ return metadata.length;
+ }
+
+ public String getStringValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException {
+ return (String) getValue(columnIndex, metadataPropertyKey);
+ }
+
+ public int getIntValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException {
+ return ((Integer) getValue(columnIndex, metadataPropertyKey)).intValue();
+ }
+
+ public boolean getBooleanValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException {
+ return ((Boolean) getValue(columnIndex, metadataPropertyKey)).booleanValue();
+ }
+
+}
Added: trunk/client-jdbc/src/main/java/org/teiid/jdbc/ParameterMetaDataImpl.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/ParameterMetaDataImpl.java
(rev 0)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/ParameterMetaDataImpl.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.sql.CallableStatement;
+import java.sql.ParameterMetaData;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
+
+/**
+ * Note: this is currently only accurate for {@link PreparedStatement}s.
+ * Only the basic type information will be accurate for {@link CallableStatement}s.
+ */
+public class ParameterMetaDataImpl extends WrapperImpl implements ParameterMetaData {
+
+ private ResultSetMetaDataImpl metadata;
+
+ public ParameterMetaDataImpl(ResultSetMetaDataImpl metadata) {
+ this.metadata = metadata;
+ }
+
+ @Override
+ public String getParameterClassName(int param) throws SQLException {
+ return MMJDBCSQLTypeInfo.getJavaClassName(getParameterType(param));
+ }
+
+ @Override
+ public int getParameterCount() throws SQLException {
+ return metadata.getColumnCount();
+ }
+
+ @Override
+ public int getParameterMode(int param) throws SQLException {
+ return parameterModeUnknown;
+ }
+
+ @Override
+ public int getParameterType(int param) throws SQLException {
+ return metadata.getColumnType(param);
+ }
+
+ @Override
+ public String getParameterTypeName(int param) throws SQLException {
+ return metadata.getColumnTypeName(param);
+ }
+
+ @Override
+ public int getPrecision(int param) throws SQLException {
+ return metadata.getPrecision(param);
+ }
+
+ @Override
+ public int getScale(int param) throws SQLException {
+ return metadata.getScale(param);
+ }
+
+ @Override
+ public int isNullable(int param) throws SQLException {
+ return metadata.isNullable(param);
+ }
+
+ @Override
+ public boolean isSigned(int param) throws SQLException {
+ return metadata.isSigned(param);
+ }
+
+}
Property changes on:
trunk/client-jdbc/src/main/java/org/teiid/jdbc/ParameterMetaDataImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2010-03-18
16:18:20 UTC (rev 1973)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -87,7 +87,9 @@
protected List<List<Object>> batchParameterList;
// metadata
+ private MetadataResult metadataResults;
private ResultSetMetaData metadata;
+ private ParameterMetaData parameterMetaData;
private Calendar serverCalendar;
@@ -251,25 +253,30 @@
} else if(resultSet != null) {
metadata = resultSet.getMetaData();
} else {
- MetadataResult results;
- try {
- results = this.getDQP().getMetadata(this.currentRequestID, prepareSql,
Boolean.valueOf(getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS)).booleanValue());
- } catch (MetaMatrixComponentException e) {
- throw TeiidSQLException.create(e);
- } catch (MetaMatrixProcessingException e) {
- throw TeiidSQLException.create(e);
- }
- if (results.getColumnMetadata() == null) {
+ if (getMetadataResults().getColumnMetadata() == null) {
return null;
}
- StaticMetadataProvider provider =
StaticMetadataProvider.createWithData(results.getColumnMetadata(),
results.getParameterCount());
- metadata = ResultsMetadataWithProvider.newInstance(provider);
+ MetadataProvider provider = new
MetadataProvider(getMetadataResults().getColumnMetadata());
+ metadata = new ResultSetMetaDataImpl(provider);
}
}
return metadata;
}
+ private MetadataResult getMetadataResults() throws TeiidSQLException {
+ if (metadataResults == null) {
+ try {
+ metadataResults = this.getDQP().getMetadata(this.currentRequestID, prepareSql,
Boolean.valueOf(getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS)).booleanValue());
+ } catch (MetaMatrixComponentException e) {
+ throw TeiidSQLException.create(e);
+ } catch (MetaMatrixProcessingException e) {
+ throw TeiidSQLException.create(e);
+ }
+ }
+ return metadataResults;
+ }
+
public void setAsciiStream (int parameterIndex, java.io.InputStream in, int length)
throws SQLException {
//create a clob from the ascii stream
try {
@@ -661,12 +668,12 @@
return new ArrayList<Object>(parameterMap.values());
}
- /* (non-Javadoc)
- * @see java.sql.PreparedStatement#getParameterMetaData()
- */
public ParameterMetaData getParameterMetaData() throws SQLException {
- /* Implement for JDBC 3.0 */
- return null;
+ if (parameterMetaData == null) {
+ //TODO: some of the base implementation of ResultSetMetadata could be on the
MetadataProvider
+ this.parameterMetaData = new ParameterMetaDataImpl(new ResultSetMetaDataImpl(new
MetadataProvider(getMetadataResults().getParameterMetadata())));
+ }
+ return parameterMetaData;
}
/**
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-03-18 16:18:20
UTC (rev 1973)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-03-18 18:26:59
UTC (rev 1974)
@@ -130,10 +130,10 @@
this.serverTimeZone = statement.getServerTimeZone();
if (metadata == null) {
- ResultsMetadataProvider provider =
DeferredMetadataProvider.createWithInitialData(resultsMsg.getColumnNames(),
+ MetadataProvider provider = new DeferredMetadataProvider(resultsMsg.getColumnNames(),
resultsMsg.getDataTypes(), statement,
statement.getCurrentRequestID());
- rmetadata = ResultsMetadataWithProvider.newInstance(provider);
+ rmetadata = new ResultSetMetaDataImpl(provider);
} else {
rmetadata = metadata;
}
@@ -142,7 +142,7 @@
this.resultColumns = columnCount - parameters;
if (this.parameters > 0) {
- rmetadata = FilteredResultsMetadata.newInstance(rmetadata, resultColumns);
+ rmetadata = new FilteredResultsMetadata(rmetadata, resultColumns);
}
this.fetchSize = statement.getFetchSize();
}
Copied: trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java (from
rev 1973,
trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultsMetadataWithProvider.java)
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java
(rev 0)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultSetMetaDataImpl.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+
+import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
+import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
+
+/**
+ */
+public class ResultSetMetaDataImpl extends WrapperImpl implements ResultSetMetaData {
+
+ private MetadataProvider provider;
+
+ public ResultSetMetaDataImpl(MetadataProvider provider) {
+ this.provider = provider;
+ }
+
+ /**
+ * Adjust from 1-based to internal 0-based representation
+ * @param index External 1-based representation
+ * @return Internal 0-based representation
+ */
+ private int adjustColumn(int index) {
+ return index-1;
+ }
+
+ public String getVirtualDatabaseName(int index) throws SQLException {
+ return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.VIRTUAL_DATABASE_NAME);
+ }
+
+ public String getVirtualDatabaseVersion(int index) throws SQLException {
+ return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION);
+ }
+
+ public int getColumnCount() throws SQLException {
+ return provider.getColumnCount();
+ }
+
+ public boolean isAutoIncrement(int index) throws SQLException {
+ return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.AUTO_INCREMENTING);
+ }
+
+ public boolean isCaseSensitive(int index) throws SQLException {
+ return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.CASE_SENSITIVE);
+ }
+
+ public boolean isSearchable(int index) throws SQLException {
+ Integer searchable = (Integer) provider.getValue(adjustColumn(index),
ResultsMetadataConstants.SEARCHABLE);
+ return !(ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE.equals(searchable));
+ }
+
+ public boolean isCurrency(int index) throws SQLException {
+ return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.CURRENCY);
+ }
+
+ public int isNullable(int index) throws SQLException {
+ Object nullable = provider.getValue(adjustColumn(index),
ResultsMetadataConstants.NULLABLE);
+ if(nullable.equals(ResultsMetadataConstants.NULL_TYPES.NULLABLE)) {
+ return columnNullable;
+ } else if(nullable.equals(ResultsMetadataConstants.NULL_TYPES.NOT_NULL)) {
+ return columnNoNulls;
+ } else {
+ return columnNullableUnknown;
+ }
+ }
+
+ public boolean isSigned(int index) throws SQLException {
+ return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.SIGNED);
+ }
+
+ public int getColumnDisplaySize(int index) throws SQLException {
+ return provider.getIntValue(adjustColumn(index),
ResultsMetadataConstants.DISPLAY_SIZE);
+ }
+
+ public String getColumnLabel(int index) throws SQLException {
+ return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.ELEMENT_LABEL);
+ }
+
+ public String getColumnName(int index) throws SQLException {
+ return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.ELEMENT_NAME);
+ }
+
+ public String getSchemaName(int index) throws SQLException {
+ String name = provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.GROUP_NAME);
+ if (name != null) {
+ int dotIndex = name.indexOf('.');
+ if (dotIndex != -1) {
+ return name.substring(0, dotIndex);
+ }
+ }
+ return null;
+ }
+
+ public int getPrecision(int index) throws SQLException {
+ return provider.getIntValue(adjustColumn(index),
ResultsMetadataConstants.PRECISION);
+ }
+
+ public int getScale(int index) throws SQLException {
+ return provider.getIntValue(adjustColumn(index),
ResultsMetadataConstants.SCALE);
+ }
+
+ public String getTableName(int index) throws SQLException {
+ String name = provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.GROUP_NAME);
+ if (name != null) {
+ int dotIndex = name.indexOf('.');
+ if (dotIndex != -1) {
+ return name.substring(dotIndex + 1);
+ }
+ }
+ return name;
+ }
+
+ public String getCatalogName(int index) throws SQLException {
+ return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.VIRTUAL_DATABASE_NAME);
+ }
+
+ public int getColumnType(int index) throws SQLException {
+ String runtimeTypeName = provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.DATA_TYPE);
+ return MMJDBCSQLTypeInfo.getSQLType(runtimeTypeName);
+ }
+
+ public String getColumnTypeName(int index) throws SQLException {
+ return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.DATA_TYPE);
+ }
+
+ public boolean isReadOnly(int index) throws SQLException {
+ return ! provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.WRITABLE);
+ }
+
+ public boolean isWritable(int index) throws SQLException {
+ return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.WRITABLE);
+ }
+
+ public boolean isDefinitelyWritable(int index) throws SQLException {
+ return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.WRITABLE);
+ }
+
+ public String getColumnClassName(int index) throws SQLException {
+ return MMJDBCSQLTypeInfo.getJavaClassName(getColumnType(index));
+ }
+
+}
Deleted: trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultsMetadataProvider.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultsMetadataProvider.java 2010-03-18
16:18:20 UTC (rev 1973)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultsMetadataProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.jdbc;
-
-import java.sql.SQLException;
-
-/**
- * Interface to provide result set metadata.
- */
-public interface ResultsMetadataProvider {
-
- /**
- * Get number of columns in the result set metadata
- * @return Column count
- * @throws SQLException
- */
- int getColumnCount() throws SQLException;
-
- /**
- * Get metadata value for the column at columnIndex for a given
- * metadata property.
- * @param columnIndex The column index
- * @param metadataPropertyKey The metadata property
- * @return The value to return
- * @throws SQLException
- */
- Object getValue(int columnIndex, Integer metadataPropertyKey) throws SQLException;
-
- /**
- * Get metadata value for the column at columnIndex for a given
- * metadata property.
- * @param columnIndex The column index
- * @param metadataPropertyKey The metadata property
- * @return The value to return
- * @throws SQLException
- */
- String getStringValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException;
-
- /**
- * Get metadata value for the column at columnIndex for a given
- * metadata property.
- * @param columnIndex The column index
- * @param metadataPropertyKey The metadata property
- * @return The value to return
- * @throws SQLException
- */
- int getIntValue(int columnIndex, Integer metadataPropertyKey) throws SQLException;
-
- /**
- * Get metadata value for the column at columnIndex for a given
- * metadata property.
- * @param columnIndex The column index
- * @param metadataPropertyKey The metadata property
- * @return The value to return
- * @throws SQLException
- */
- boolean getBooleanValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException;
-
- /**
- * Get parameter count from original command
- * @return count
- */
- int getParameterCount() throws SQLException;
-}
Deleted: trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultsMetadataWithProvider.java
===================================================================
---
trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultsMetadataWithProvider.java 2010-03-18
16:18:20 UTC (rev 1973)
+++
trunk/client-jdbc/src/main/java/org/teiid/jdbc/ResultsMetadataWithProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -1,213 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.jdbc;
-
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
-import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
-
-/**
- */
-public class ResultsMetadataWithProvider extends WrapperImpl implements ResultSetMetaData
{
-
- private ResultsMetadataProvider provider;
-
- /**
- * Factory Constructor
- * @param statement
- * @param valueID
- */
- public static ResultsMetadataWithProvider newInstance(ResultsMetadataProvider
provider) {
- return new ResultsMetadataWithProvider(provider);
- }
-
- public ResultsMetadataWithProvider(ResultsMetadataProvider provider) {
- setMetadataProvider(provider);
- }
-
- void setMetadataProvider(ResultsMetadataProvider provider) {
- this.provider = provider;
- }
-
- private void verifyProvider() throws SQLException {
- if(this.provider == null) {
- throw new
SQLException(JDBCPlugin.Util.getString("ResultsMetadataWithProvider.No_provider"));
//$NON-NLS-1$
- }
- }
-
- /**
- * Adjust from 1-based to internal 0-based representation
- * @param index External 1-based representation
- * @return Internal 0-based representation
- */
- private int adjustColumn(int index) {
- return index-1;
- }
-
- public String getVirtualDatabaseName(int index) throws SQLException {
- verifyProvider();
- return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.VIRTUAL_DATABASE_NAME);
- }
-
- public String getVirtualDatabaseVersion(int index) throws SQLException {
- verifyProvider();
- return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION);
- }
-
- public int getColumnCount() throws SQLException {
- verifyProvider();
- return provider.getColumnCount();
- }
-
- public boolean isAutoIncrement(int index) throws SQLException {
- verifyProvider();
- return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.AUTO_INCREMENTING);
- }
-
- public boolean isCaseSensitive(int index) throws SQLException {
- verifyProvider();
- return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.CASE_SENSITIVE);
- }
-
- public boolean isSearchable(int index) throws SQLException {
- verifyProvider();
- Integer searchable = (Integer) provider.getValue(adjustColumn(index),
ResultsMetadataConstants.SEARCHABLE);
- return !(ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE.equals(searchable));
- }
-
- public boolean isCurrency(int index) throws SQLException {
- verifyProvider();
- return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.CURRENCY);
- }
-
- public int isNullable(int index) throws SQLException {
- verifyProvider();
- Object nullable = provider.getValue(adjustColumn(index),
ResultsMetadataConstants.NULLABLE);
- if(nullable.equals(ResultsMetadataConstants.NULL_TYPES.NULLABLE)) {
- return columnNullable;
- } else if(nullable.equals(ResultsMetadataConstants.NULL_TYPES.NOT_NULL)) {
- return columnNoNulls;
- } else {
- return columnNullableUnknown;
- }
- }
-
- public boolean isSigned(int index) throws SQLException {
- verifyProvider();
- return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.SIGNED);
- }
-
- public int getColumnDisplaySize(int index) throws SQLException {
- verifyProvider();
- return provider.getIntValue(adjustColumn(index),
ResultsMetadataConstants.DISPLAY_SIZE);
- }
-
- public String getColumnLabel(int index) throws SQLException {
- verifyProvider();
- return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.ELEMENT_LABEL);
- }
-
- public String getColumnName(int index) throws SQLException {
- verifyProvider();
- return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.ELEMENT_NAME);
- }
-
- public String getSchemaName(int index) throws SQLException {
- verifyProvider();
- String name = provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.GROUP_NAME);
- if (name != null) {
- int dotIndex = name.indexOf('.');
- if (dotIndex != -1) {
- return name.substring(0, dotIndex);
- }
- }
- return null;
- }
-
- public int getPrecision(int index) throws SQLException {
- verifyProvider();
- return provider.getIntValue(adjustColumn(index),
ResultsMetadataConstants.PRECISION);
- }
-
- public int getScale(int index) throws SQLException {
- verifyProvider();
- return provider.getIntValue(adjustColumn(index),
ResultsMetadataConstants.SCALE);
- }
-
- public String getTableName(int index) throws SQLException {
- verifyProvider();
- String name = provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.GROUP_NAME);
- if (name != null) {
- int dotIndex = name.indexOf('.');
- if (dotIndex != -1) {
- return name.substring(dotIndex + 1);
- }
- }
- return name;
- }
-
- public String getCatalogName(int index) throws SQLException {
- verifyProvider();
- return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.VIRTUAL_DATABASE_NAME);
- }
-
- public int getColumnType(int index) throws SQLException {
- verifyProvider();
-
- String runtimeTypeName = provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.DATA_TYPE);
- return MMJDBCSQLTypeInfo.getSQLType(runtimeTypeName);
- }
-
- public String getColumnTypeName(int index) throws SQLException {
- verifyProvider();
- return provider.getStringValue(adjustColumn(index),
ResultsMetadataConstants.DATA_TYPE);
- }
-
- public boolean isReadOnly(int index) throws SQLException {
- verifyProvider();
- return ! provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.WRITABLE);
- }
-
- public boolean isWritable(int index) throws SQLException {
- verifyProvider();
- return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.WRITABLE);
- }
-
- public boolean isDefinitelyWritable(int index) throws SQLException {
- verifyProvider();
- return provider.getBooleanValue(adjustColumn(index),
ResultsMetadataConstants.WRITABLE);
- }
-
- public String getColumnClassName(int index) throws SQLException {
- verifyProvider();
-
- return MMJDBCSQLTypeInfo.getJavaClassName(getColumnType(index));
- }
-
- public int getParameterCount() throws SQLException{
- return provider.getParameterCount();
- }
-
-}
Deleted: trunk/client-jdbc/src/main/java/org/teiid/jdbc/StaticMetadataProvider.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/StaticMetadataProvider.java 2010-03-18
16:18:20 UTC (rev 1973)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/StaticMetadataProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.jdbc;
-
-import java.sql.SQLException;
-import java.util.Map;
-
-
-/**
- */
-public class StaticMetadataProvider extends AbstractMetadataProvider {
-
- // Map of detail maps -- <columnIndex, Map<propertyName,
metadataObject>>
- private Map[] columnMetadata;
- private int paramCount;
-
- StaticMetadataProvider() {
- }
-
- public static StaticMetadataProvider createWithData(Map[] columnMetadata, int
paramCount) {
- StaticMetadataProvider provider = null;
-
- provider = new StaticMetadataProvider();
- provider.setData(columnMetadata);
- provider.setParameterCount(paramCount);
- return provider;
- }
-
- /**
- * Set column metadata. The Map[] holds metadata for each column,
- * indexed by column
- * @param columnMetadata Each Map is from metadata key to metadata value
- */
- private void setData(Map[] columnMetadata) {
- this.columnMetadata = columnMetadata;
- }
-
- private void checkMetadataExists() throws SQLException {
- if(columnMetadata == null) {
- throw new
SQLException(JDBCPlugin.Util.getString("StaticMetadataProvider.No_metadata"));
//$NON-NLS-1$
- }
- }
-
- public Object getValue(int columnIndex, Integer metadataPropertyKey) throws
SQLException {
- checkMetadataExists();
-
- if(columnIndex < 0 || columnIndex >= columnMetadata.length) {
- throw new
SQLException(JDBCPlugin.Util.getString("StaticMetadataProvider.Invalid_column",
columnIndex)); //$NON-NLS-1$
- }
-
- Map column = this.columnMetadata[columnIndex];
- return column.get(metadataPropertyKey);
- }
-
- public int getColumnCount() throws SQLException {
- checkMetadataExists();
- return columnMetadata.length;
- }
-
- public int getParameterCount() {
- return paramCount;
- }
-
- public void setParameterCount(int paramCount) {
- this.paramCount = paramCount;
- }
-
-}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-03-18
16:18:20 UTC (rev 1973)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -61,6 +61,7 @@
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
import com.metamatrix.query.tempdata.TempTableStore;
@@ -168,7 +169,13 @@
columnMetadata = createProjectedSymbolMetadata(originalCommand);
}
- return new MetadataResult(columnMetadata,
ReferenceCollectorVisitor.getReferences(originalCommand).size());
+ List<Reference> params =
ReferenceCollectorVisitor.getReferences(originalCommand);
+ Map[] paramMetadata = new Map[params.size()];
+ for (int i = 0; i < params.size(); i++) {
+ paramMetadata[i] = getDefaultColumn(null, null, params.get(i).getType());
+ }
+
+ return new MetadataResult(columnMetadata, paramMetadata);
}
private Map[] createProjectedSymbolMetadata(Command originalCommand) throws
MetaMatrixComponentException {
Copied: trunk/test-integration/common/src/test/java/org/teiid/jdbc (from rev 1972,
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc)
Deleted:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsMetadataWithProvider.java
===================================================================
---
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java 2010-03-17
16:45:58 UTC (rev 1972)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsMetadataWithProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.jdbc;
-
-import java.util.Map;
-
-import org.teiid.dqp.internal.process.MetaDataProcessor;
-
-import junit.framework.TestCase;
-
-
-/**
- */
-public class TestResultsMetadataWithProvider extends TestCase {
-
- /**
- * Constructor for TestResultsMetadataWithProvider.
- * @param name
- */
- public TestResultsMetadataWithProvider(String name) {
- super(name);
- }
-
- public StaticMetadataProvider exampleProvider() throws Exception {
- MetaDataProcessor processor = new MetaDataProcessor(null, null, "vdb",
1); //$NON-NLS-1$
- Map col1 = processor.getDefaultColumn("table", "col1",
String.class); //$NON-NLS-1$ //$NON-NLS-2$
- Map col2 = processor.getDefaultColumn("table", "col2",
Integer.class); //$NON-NLS-1$ //$NON-NLS-2$
-
- Map[] columnMetadata = new Map[] {
- col1, col2
- };
-
- StaticMetadataProvider provider =
StaticMetadataProvider.createWithData(columnMetadata, 0);
- return provider;
- }
-
- public void test1() throws Exception {
- ResultsMetadataWithProvider rmd = new
ResultsMetadataWithProvider(exampleProvider());
-
- assertEquals(false, rmd.isAutoIncrement(1));
- assertEquals(false, rmd.isCaseSensitive(1));
- assertEquals(false, rmd.isCurrency(1));
- assertEquals(true, rmd.isDefinitelyWritable(1));
- assertEquals(false, rmd.isReadOnly(1));
- assertEquals(true, rmd.isSearchable(1));
- assertEquals(true, rmd.isSigned(1));
- assertEquals(true, rmd.isWritable(1));
- assertEquals("vdb", rmd.getCatalogName(1)); //$NON-NLS-1$
- assertEquals(null, rmd.getSchemaName(1));
- assertEquals("table", rmd.getTableName(1)); //$NON-NLS-1$
- assertEquals("col1", rmd.getColumnName(1)); //$NON-NLS-1$
- assertEquals("string", rmd.getColumnTypeName(1)); //$NON-NLS-1$
- }
-}
Copied:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsMetadataWithProvider.java
(from rev 1973,
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java)
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsMetadataWithProvider.java
(rev 0)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsMetadataWithProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.util.Map;
+
+import org.teiid.dqp.internal.process.MetaDataProcessor;
+import org.teiid.jdbc.ResultSetMetaDataImpl;
+import org.teiid.jdbc.MetadataProvider;
+
+import junit.framework.TestCase;
+
+
+/**
+ */
+public class TestResultsMetadataWithProvider extends TestCase {
+
+ /**
+ * Constructor for TestResultsMetadataWithProvider.
+ * @param name
+ */
+ public TestResultsMetadataWithProvider(String name) {
+ super(name);
+ }
+
+ public MetadataProvider exampleProvider() throws Exception {
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, "vdb",
1); //$NON-NLS-1$
+ Map col1 = processor.getDefaultColumn("table", "col1",
String.class); //$NON-NLS-1$ //$NON-NLS-2$
+ Map col2 = processor.getDefaultColumn("table", "col2",
Integer.class); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Map[] columnMetadata = new Map[] {
+ col1, col2
+ };
+
+ MetadataProvider provider = new MetadataProvider(columnMetadata);
+ return provider;
+ }
+
+ public void test1() throws Exception {
+ ResultSetMetaDataImpl rmd = new ResultSetMetaDataImpl(exampleProvider());
+
+ assertEquals(false, rmd.isAutoIncrement(1));
+ assertEquals(false, rmd.isCaseSensitive(1));
+ assertEquals(false, rmd.isCurrency(1));
+ assertEquals(true, rmd.isDefinitelyWritable(1));
+ assertEquals(false, rmd.isReadOnly(1));
+ assertEquals(true, rmd.isSearchable(1));
+ assertEquals(true, rmd.isSigned(1));
+ assertEquals(true, rmd.isWritable(1));
+ assertEquals("vdb", rmd.getCatalogName(1)); //$NON-NLS-1$
+ assertEquals(null, rmd.getSchemaName(1));
+ assertEquals("table", rmd.getTableName(1)); //$NON-NLS-1$
+ assertEquals("col1", rmd.getColumnName(1)); //$NON-NLS-1$
+ assertEquals("string", rmd.getColumnTypeName(1)); //$NON-NLS-1$
+ }
+}
Deleted:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStaticMetadataProvider.java
===================================================================
---
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java 2010-03-17
16:45:58 UTC (rev 1972)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStaticMetadataProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -1,108 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.jdbc;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.teiid.dqp.internal.process.MetaDataProcessor;
-
-import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
-
-/**
- */
-public class TestStaticMetadataProvider extends TestCase {
-
- /**
- * Constructor for TestStaticMetadataProvider.
- * @param name
- */
- public TestStaticMetadataProvider(String name) {
- super(name);
- }
-
- private StaticMetadataProvider example1() throws Exception {
- MetaDataProcessor processor = new MetaDataProcessor(null, null, "vdb", 1);
//$NON-NLS-1$
- Map[] columnMetadata = new Map[] {
- processor.getDefaultColumn("table", "c1", String.class),
//$NON-NLS-1$ //$NON-NLS-2$
- processor.getDefaultColumn("table", "c2", Integer.class)
//$NON-NLS-1$ //$NON-NLS-2$
- };
-
- return StaticMetadataProvider.createWithData(columnMetadata, 0);
- }
-
- public void testMetadata() throws Exception {
- StaticMetadataProvider provider = example1();
- assertEquals(2, provider.getColumnCount());
-
- for(int i=0; i<provider.getColumnCount(); i++) {
- assertNotNull(provider.getValue(i,
ResultsMetadataConstants.VIRTUAL_DATABASE_NAME));
- assertNotNull(provider.getValue(i,
ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION));
- assertNotNull(provider.getValue(i, ResultsMetadataConstants.GROUP_NAME));
- assertNotNull(provider.getValue(i, ResultsMetadataConstants.ELEMENT_NAME));
-
- }
- }
-
- public void testGetStringValue() throws Exception {
- Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
- String value = "vdb"; //$NON-NLS-1$
-
- Map columnMetadata = new HashMap();
- columnMetadata.put(property, value);
-
- StaticMetadataProvider md = StaticMetadataProvider.createWithData(new Map[]
{columnMetadata}, 0);
-
- String actualValue = md.getStringValue(0, property);
- assertEquals(value, actualValue);
- }
-
- public void testGetIntValue() throws Exception {
- Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
- Integer value = new Integer(10);
-
- Map columnMetadata = new HashMap();
- columnMetadata.put(property, value);
-
- StaticMetadataProvider md = StaticMetadataProvider.createWithData(new Map[]
{columnMetadata}, 0);
-
- int actualValue = md.getIntValue(0, property);
- assertEquals(10, actualValue);
- }
-
- public void testGetBooleanValue() throws Exception {
- Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
- Boolean value = Boolean.TRUE;
-
- Map columnMetadata = new HashMap();
- columnMetadata.put(property, value);
-
- StaticMetadataProvider md = StaticMetadataProvider.createWithData(new Map[]
{columnMetadata}, 0);
-
- boolean actualValue = md.getBooleanValue(0, property);
- assertEquals(true, actualValue);
- }
-
-}
Copied:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStaticMetadataProvider.java
(from rev 1973,
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java)
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStaticMetadataProvider.java
(rev 0)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStaticMetadataProvider.java 2010-03-18
18:26:59 UTC (rev 1974)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.teiid.dqp.internal.process.MetaDataProcessor;
+import org.teiid.jdbc.MetadataProvider;
+
+import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
+
+/**
+ */
+public class TestStaticMetadataProvider extends TestCase {
+
+ /**
+ * Constructor for TestStaticMetadataProvider.
+ * @param name
+ */
+ public TestStaticMetadataProvider(String name) {
+ super(name);
+ }
+
+ private MetadataProvider example1() throws Exception {
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, "vdb", 1);
//$NON-NLS-1$
+ Map[] columnMetadata = new Map[] {
+ processor.getDefaultColumn("table", "c1", String.class),
//$NON-NLS-1$ //$NON-NLS-2$
+ processor.getDefaultColumn("table", "c2", Integer.class)
//$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ return new MetadataProvider(columnMetadata);
+ }
+
+ public void testMetadata() throws Exception {
+ MetadataProvider provider = example1();
+ assertEquals(2, provider.getColumnCount());
+
+ for(int i=0; i<provider.getColumnCount(); i++) {
+ assertNotNull(provider.getValue(i,
ResultsMetadataConstants.VIRTUAL_DATABASE_NAME));
+ assertNotNull(provider.getValue(i,
ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION));
+ assertNotNull(provider.getValue(i, ResultsMetadataConstants.GROUP_NAME));
+ assertNotNull(provider.getValue(i, ResultsMetadataConstants.ELEMENT_NAME));
+
+ }
+ }
+
+ public void testGetStringValue() throws Exception {
+ Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
+ String value = "vdb"; //$NON-NLS-1$
+
+ Map columnMetadata = new HashMap();
+ columnMetadata.put(property, value);
+
+ MetadataProvider md = new MetadataProvider(new Map[] {columnMetadata});
+
+ String actualValue = md.getStringValue(0, property);
+ assertEquals(value, actualValue);
+ }
+
+ public void testGetIntValue() throws Exception {
+ Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
+ Integer value = new Integer(10);
+
+ Map columnMetadata = new HashMap();
+ columnMetadata.put(property, value);
+
+ MetadataProvider md = new MetadataProvider(new Map[] {columnMetadata});
+
+ int actualValue = md.getIntValue(0, property);
+ assertEquals(10, actualValue);
+ }
+
+ public void testGetBooleanValue() throws Exception {
+ Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
+ Boolean value = Boolean.TRUE;
+
+ Map columnMetadata = new HashMap();
+ columnMetadata.put(property, value);
+
+ MetadataProvider md = new MetadataProvider(new Map[] {columnMetadata});
+
+ boolean actualValue = md.getBooleanValue(0, property);
+ assertEquals(true, actualValue);
+ }
+
+}