teiid SVN: r1974 - in trunk: client/src/main/java/com/metamatrix/dqp/client and 6 other directories.
by teiid-commits@lists.jboss.org
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);
+ }
+
+}
14 years, 9 months
teiid SVN: r1972 - in trunk/client/src: main/java/org/teiid/adminapi/impl and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-03-17 12:45:58 -0400 (Wed, 17 Mar 2010)
New Revision: 1972
Added:
trunk/client/src/main/java/org/teiid/adminapi/DataRole.java
Removed:
trunk/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java
Modified:
trunk/client/src/main/java/org/teiid/adminapi/VDB.java
trunk/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
trunk/client/src/main/resources/vdb-deployer.xsd
trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
Log:
TEIID-1017: Step :1 Adding support to read data roles from VDB.xml file.
Added: trunk/client/src/main/java/org/teiid/adminapi/DataRole.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/DataRole.java (rev 0)
+++ trunk/client/src/main/java/org/teiid/adminapi/DataRole.java 2010-03-17 16:45:58 UTC (rev 1972)
@@ -0,0 +1,83 @@
+/*
+ * 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.adminapi;
+
+import java.util.List;
+
+public interface DataRole {
+ /**
+ * Get the Name of the Data Role
+ * @return
+ */
+ String getName();
+
+ /**
+ * Get the description of the Data Role
+ * @return
+ */
+ String getDescription();
+
+ /**
+ * Get the List of Permissions for this Data Role.
+ * @return
+ */
+ List<Permission> getPermissions();
+
+ /**
+ * Mapped Container Role names for this Data Role
+ * @return
+ */
+ List<String> getMappedRoleNames();
+
+
+ interface Permission {
+ /**
+ * Get the Resource Name that Data Role representing
+ * @return
+ */
+ String getResourceName();
+
+ /**
+ * Is "CREATE" allowed?
+ * @return
+ */
+ boolean isAllowCreate();
+
+ /**
+ * Is "SELECT" allowed?
+ * @return
+ */
+ boolean isAllowRead();
+
+ /**
+ * Is "INSERT/UPDATE" allowed?
+ * @return
+ */
+ boolean isAllowUpdate();
+
+ /**
+ * Is "DELETE" allowed?
+ * @return
+ */
+ boolean isAllowDelete();
+ }
+}
Property changes on: trunk/client/src/main/java/org/teiid/adminapi/DataRole.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/client/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/VDB.java 2010-03-16 21:55:06 UTC (rev 1971)
+++ trunk/client/src/main/java/org/teiid/adminapi/VDB.java 2010-03-17 16:45:58 UTC (rev 1972)
@@ -88,4 +88,10 @@
* @return
*/
public boolean isValid();
+
+ /**
+ * Get the data roles defined on this VDB
+ * @return
+ */
+ public List<DataRole> getDataRoles();
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java 2010-03-16 21:55:06 UTC (rev 1971)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java 2010-03-17 16:45:58 UTC (rev 1972)
@@ -22,6 +22,8 @@
package org.teiid.adminapi.impl;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -30,55 +32,41 @@
import javax.xml.bind.annotation.XmlType;
import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.teiid.adminapi.DataRole;
-/**
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * <element name="resource-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
- * <element name="allow-create" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * <element name="allow-read" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * <element name="allow-update" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * <element name="allow-delete" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * </sequence>
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"description",
- "resourceName",
- "allowCreate",
- "allowRead",
- "allowUpdate",
- "allowDelete"
+ "permissions",
+ "mappedRoleNames"
})
-@ManagementObject
-public class DataRoleMetadata implements Serializable {
-
- @XmlAttribute(name = "name", required = true)
+(a)ManagementObject(properties=ManagementProperties.EXPLICIT)
+public class DataRoleMetadata implements DataRole, Serializable {
+ private static final long serialVersionUID = -4119646357275977190L;
+
+ @XmlAttribute(name = "name", required = true)
protected String name;
@XmlElement(name = "description")
protected String description;
- @XmlElement(name = "resource-name", required = true)
- protected String resourceName;
- @XmlElement(name = "allow-create")
- protected Boolean allowCreate;
- @XmlElement(name = "allow-read")
- protected Boolean allowRead;
- @XmlElement(name = "allow-update")
- protected Boolean allowUpdate;
- @XmlElement(name = "allow-delete")
- protected Boolean allowDelete;
+ @XmlElement(name = "permission")
+ protected ListOverMap<PermissionMetaData> permissions = new ListOverMap<PermissionMetaData>(new KeyBuilder<PermissionMetaData>() {
+ @Override
+ public String getKey(PermissionMetaData entry) {
+ return entry.getResourceName();
+ }
+ });
+
+ @XmlElement(name = "mapped-role-name")
+ protected List<String> mappedRoleNames;
+
+ @Override
+ @ManagementProperty(description="Role Name")
+ @ManagementObjectID(type="role")
public String getName() {
return name;
}
@@ -87,6 +75,8 @@
this.name = value;
}
+ @Override
+ @ManagementProperty(description="Role Description")
public String getDescription() {
return description;
}
@@ -95,43 +85,120 @@
this.description = value;
}
- public String getResourceName() {
- return resourceName;
- }
+ @Override
+ @ManagementProperty(description="Permissions in a Data Role", managed=true)
+ public List<Permission> getPermissions() {
+ return new ArrayList<Permission>(this.permissions.getMap().values());
+ }
+
+ public void setPermissions(List<Permission> permissions) {
+ this.permissions.getMap().clear();
+ for (Permission permission:permissions) {
+ this.permissions.getMap().put(permission.getResourceName(), (PermissionMetaData)permission);
+ }
+ }
+
+ public PermissionMetaData getPermission(String resourceName) {
+ return this.permissions.getMap().get(resourceName);
+ }
+
+ public void addPermission(PermissionMetaData permission) {
+ this.permissions.getMap().put(permission.getResourceName(), permission);
+ }
+
+ @Override
+ @ManagementProperty(description="Mapped Container role names mapped to this role")
+ public List<String> getMappedRoleNames() {
+ return mappedRoleNames;
+ }
- public void setResourceName(String value) {
- this.resourceName = value;
- }
+ public void setMappedRoleNames(List<String> names) {
+ this.mappedRoleNames = names;
+ }
+
+
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "resourceName",
+ "allowCreate",
+ "allowRead",
+ "allowUpdate",
+ "allowDelete"
+ })
+ @ManagementObject(properties=ManagementProperties.EXPLICIT)
+ public static class PermissionMetaData implements Permission{
+ @XmlElement(name = "resource-name", required = true)
+ protected String resourceName;
+ @XmlElement(name = "allow-create")
+ protected Boolean allowCreate;
+ @XmlElement(name = "allow-read")
+ protected Boolean allowRead;
+ @XmlElement(name = "allow-update")
+ protected Boolean allowUpdate;
+ @XmlElement(name = "allow-delete")
+ protected Boolean allowDelete;
+
+ @Override
+ @ManagementProperty(description="Resource Name, for which role defined")
+ @ManagementObjectID(type="permission")
+ public String getResourceName() {
+ return resourceName;
+ }
- public Boolean isAllowCreate() {
- return allowCreate;
- }
+ public void setResourceName(String value) {
+ this.resourceName = value;
+ }
- public void setAllowCreate(Boolean value) {
- this.allowCreate = value;
- }
+ @Override
+ @ManagementProperty(description="Allows Create")
+ public boolean isAllowCreate() {
+ if (allowCreate == null) {
+ return false;
+ }
+ return allowCreate;
+ }
- public Boolean isAllowRead() {
- return allowRead;
- }
+ public void setAllowCreate(Boolean value) {
+ this.allowCreate = value;
+ }
- public void setAllowRead(Boolean value) {
- this.allowRead = value;
- }
+ @Override
+ @ManagementProperty(description="Allows Read")
+ public boolean isAllowRead() {
+ if (allowRead == null) {
+ return false;
+ }
+ return allowRead;
+ }
- public Boolean isAllowUpdate() {
- return allowUpdate;
- }
+ public void setAllowRead(Boolean value) {
+ this.allowRead = value;
+ }
- public void setAllowUpdate(Boolean value) {
- this.allowUpdate = value;
- }
+ @Override
+ @ManagementProperty(description="Allows Update")
+ public boolean isAllowUpdate() {
+ if (allowUpdate == null) {
+ return false;
+ }
+ return allowUpdate;
+ }
- public Boolean isAllowDelete() {
- return allowDelete;
- }
+ public void setAllowUpdate(Boolean value) {
+ this.allowUpdate = value;
+ }
- public void setAllowDelete(Boolean value) {
- this.allowDelete = value;
- }
+ @Override
+ @ManagementProperty(description="Allows Delete")
+ public boolean isAllowDelete() {
+ if (allowDelete == null) {
+ return false;
+ }
+ return allowDelete;
+ }
+
+ public void setAllowDelete(Boolean value) {
+ this.allowDelete = value;
+ }
+ }
}
Deleted: trunk/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java 2010-03-16 21:55:06 UTC (rev 1971)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java 2010-03-17 16:45:58 UTC (rev 1972)
@@ -1,130 +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.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementProperty;
-
-
-/**
- * <pre>
- * <complexType name="reference-mapping">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="ref-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
- * <element name="resource-name" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "reference-mapping", propOrder = {
- "refName",
- "resourceNames"
-})
-@ManagementObject
-public class ReferenceMappingMetadata implements Serializable {
-
- @XmlElement(name = "ref-name", required = true)
- protected String refName;
-
- @XmlElement(name = "resource-name", required = true)
- protected List<String> resourceNames;
-
- public ReferenceMappingMetadata() {
- }
-
- public ReferenceMappingMetadata(String refName, String resourceName) {
- setRefName(refName);
- addResourceName(resourceName);
- }
-
- public ReferenceMappingMetadata(String refName, List<String> resourceNames) {
- setRefName(refName);
- this.resourceNames = new ArrayList<String>(resourceNames);
- }
-
- @ManagementProperty(description="Reference Name", readOnly=true)
- public String getRefName() {
- return refName;
- }
-
- public void setRefName(String value) {
- this.refName = value;
- }
-
- @ManagementProperty(description="Resource Names")
- public List<String> getResourceNames() {
- if (this.resourceNames == null) {
- this.resourceNames = new ArrayList<String>();
- }
- return this.resourceNames;
- }
-
- public void setResourceNames(List<String> names) {
- this.resourceNames = new ArrayList<String>(names);
- }
-
- public void addResourceName(String name) {
- getResourceNames().add(name);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((refName == null) ? 0 : refName.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ReferenceMappingMetadata other = (ReferenceMappingMetadata) obj;
- if (refName == null) {
- if (other.refName != null)
- return false;
- } else if (!refName.equals(other.refName))
- return false;
- return true;
- }
-
-
-}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-03-16 21:55:06 UTC (rev 1971)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-03-17 16:45:58 UTC (rev 1972)
@@ -39,6 +39,7 @@
import org.jboss.managed.api.annotation.ManagementObjectID;
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
+import org.teiid.adminapi.DataRole;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
@@ -50,7 +51,7 @@
"description",
"JAXBProperties",
"models",
- "securityRoleMappings"
+ "roles"
})
@XmlRootElement(name = "vdb")
public class VDBMetaData extends AdminObjectImpl implements VDB {
@@ -70,26 +71,23 @@
}
});
+ @XmlElement(name = "role", required = true, type = DataRoleMetadata.class)
+ protected ListOverMap<DataRoleMetadata> roles = new ListOverMap<DataRoleMetadata>(new KeyBuilder<DataRoleMetadata>() {
+ @Override
+ public String getKey(DataRoleMetadata entry) {
+ return entry.getName();
+ }
+ });
+
@XmlAttribute(name = "version", required = true)
private int version = 1;
@XmlElement(name = "description")
protected String description;
- @XmlElement(name = "role-mapping")
- protected ListOverMap<ReferenceMappingMetadata> securityRoleMappings = new ListOverMap<ReferenceMappingMetadata>(new KeyBuilder<ReferenceMappingMetadata>() {
- @Override
- public String getKey(ReferenceMappingMetadata entry) {
- return entry.getRefName();
- }
- });
-
private String fileUrl = null;
private boolean dynamic = false;
- public VDBMetaData() {
- // auto add sytem model.
- }
@ManagementProperty(description="Name of the VDB")
@ManagementObjectID(type="vdb")
@@ -230,15 +228,6 @@
return list;
}
- @ManagementProperty(description="Security refrence mappings", managed=true)
- public List<ReferenceMappingMetadata> getSecurityRoleMappings() {
- return new ArrayList<ReferenceMappingMetadata>(this.securityRoleMappings);
- }
-
- public void addSecurityRoleMapping(ReferenceMappingMetadata data) {
- this.securityRoleMappings.getMap().put(data.getRefName(), data);
- }
-
@Override
public Properties getProperties() {
return super.getProperties();
@@ -260,4 +249,29 @@
public void setDynamic(boolean dynamic) {
this.dynamic = dynamic;
}
+
+ @Override
+ @ManagementProperty(description="Data Roles in a VDB", managed=true)
+ public List<DataRole> getDataRoles(){
+ return new ArrayList<DataRole>(this.roles.getMap().values());
+ }
+
+ /**
+ * This method is required by the Management framework to write the mappings.
+ * @param roles
+ */
+ public void setDataRoles(List<DataRole> roles){
+ this.roles.getMap().clear();
+ for (DataRole role:roles) {
+ this.roles.getMap().put(role.getName(), (DataRoleMetadata)role);
+ }
+ }
+
+ public void addDataRole(DataRoleMetadata role){
+ this.roles.getMap().put(role.getName(), role);
+ }
+
+ public DataRoleMetadata getDataRole(String roleName) {
+ return this.roles.getMap().get(roleName);
+ }
}
Modified: trunk/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- trunk/client/src/main/resources/vdb-deployer.xsd 2010-03-16 21:55:06 UTC (rev 1971)
+++ trunk/client/src/main/resources/vdb-deployer.xsd 2010-03-17 16:45:58 UTC (rev 1972)
@@ -53,11 +53,18 @@
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string" minOccurs="0"/>
- <xs:element name="resource-name" type="xs:string"/>
- <xs:element name="allow-create" type="xs:boolean" minOccurs="0"/>
- <xs:element name="allow-read" type="xs:boolean" minOccurs="0"/>
- <xs:element name="allow-update" type="xs:boolean" minOccurs="0"/>
- <xs:element name="allow-delete" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="permission" minOccurs="1" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="resource-name" type="xs:string"/>
+ <xs:element name="allow-create" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="allow-read" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="allow-update" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="allow-delete" type="xs:boolean" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="mapped-role-name" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
@@ -71,7 +78,6 @@
<xs:attribute name="path" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
- <xs:element name="role-mapping" type="reference-mapping" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:int" use="required"/>
@@ -84,10 +90,4 @@
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
- <xs:complexType name="reference-mapping">
- <xs:sequence>
- <xs:element name="ref-name" type="xs:string"/>
- <xs:element name="resource-name" type="xs:string" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
</xs:schema>
Modified: trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-03-16 21:55:06 UTC (rev 1971)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-03-17 16:45:58 UTC (rev 1972)
@@ -25,6 +25,8 @@
import java.io.StringReader;
import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.List;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
@@ -34,7 +36,9 @@
import javax.xml.validation.SchemaFactory;
import org.junit.Test;
+import org.teiid.adminapi.DataRole;
import org.teiid.adminapi.Model;
+import org.teiid.adminapi.impl.DataRoleMetadata.PermissionMetaData;
public class TestVDBMetaData {
@@ -43,34 +47,53 @@
public void testMarshellUnmarshell() throws Exception {
VDBMetaData vdb = new VDBMetaData();
- vdb.setName("myVDB");
- vdb.setDescription("vdb description");
+ vdb.setName("myVDB"); //$NON-NLS-1$
+ vdb.setDescription("vdb description"); //$NON-NLS-1$
vdb.setVersion(1);
- vdb.addProperty("vdb-property", "vdb-value");
+ vdb.addProperty("vdb-property", "vdb-value"); //$NON-NLS-1$ //$NON-NLS-2$
ModelMetaData modelOne = new ModelMetaData();
- modelOne.setName("model-one");
- modelOne.addSourceMapping("s1", "java:mybinding");
- modelOne.setModelType("PHYSICAL");
- modelOne.addProperty("model-prop", "model-value");
- modelOne.addProperty("model-prop", "model-value-override");
+ modelOne.setName("model-one"); //$NON-NLS-1$
+ modelOne.addSourceMapping("s1", "java:mybinding"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setModelType("PHYSICAL"); //$NON-NLS-1$
+ modelOne.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.addProperty("model-prop", "model-value-override"); //$NON-NLS-1$ //$NON-NLS-2$
modelOne.setVisible(false);
- modelOne.addError("ERROR", "There is an error in VDB");
+ modelOne.addError("ERROR", "There is an error in VDB"); //$NON-NLS-1$ //$NON-NLS-2$
vdb.addModel(modelOne);
ModelMetaData modelTwo = new ModelMetaData();
- modelTwo.setName("model-two");
- modelTwo.addSourceMapping("s1", "java:binding-one");
- modelTwo.addSourceMapping("s2", "java:binding-two");
- modelTwo.setModelType("VIRTUAL");
- modelTwo.addProperty("model-prop", "model-value");
+ modelTwo.setName("model-two"); //$NON-NLS-1$
+ modelTwo.addSourceMapping("s1", "java:binding-one"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelTwo.addSourceMapping("s2", "java:binding-two"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelTwo.setModelType("VIRTUAL"); //$NON-NLS-1$
+ modelTwo.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
vdb.addModel(modelTwo);
+ DataRoleMetadata roleOne = new DataRoleMetadata();
+ roleOne.setName("roleOne"); //$NON-NLS-1$
+ roleOne.setDescription("roleOne described"); //$NON-NLS-1$
+
+ PermissionMetaData perm1 = new PermissionMetaData();
+ perm1.setResourceName("myTable.T1"); //$NON-NLS-1$
+ perm1.setAllowRead(true);
+ roleOne.addPermission(perm1);
+
+ PermissionMetaData perm2 = new PermissionMetaData();
+ perm2.setResourceName("myTable.T2"); //$NON-NLS-1$
+ perm2.setAllowRead(false);
+ perm2.setAllowDelete(true);
+ roleOne.addPermission(perm2);
+
+ roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ vdb.addDataRole(roleOne);
+
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd"));
+ Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd")); //$NON-NLS-1$
JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
Marshaller marshell = jc.createMarshaller();
marshell.setSchema(schema);
@@ -86,31 +109,51 @@
un.setSchema(schema);
vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
- assertEquals("myVDB", vdb.getName());
- assertEquals("vdb description", vdb.getDescription());
+ assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$
+ assertEquals("vdb description", vdb.getDescription()); //$NON-NLS-1$
assertEquals(1, vdb.getVersion());
- assertEquals("vdb-value", vdb.getPropertyValue("vdb-property"));
+ assertEquals("vdb-value", vdb.getPropertyValue("vdb-property")); //$NON-NLS-1$ //$NON-NLS-2$
- assertNotNull(vdb.getModel("model-one"));
- assertNotNull(vdb.getModel("model-two"));
- assertNull(vdb.getModel("model-unknown"));
+ assertNotNull(vdb.getModel("model-one")); //$NON-NLS-1$
+ assertNotNull(vdb.getModel("model-two")); //$NON-NLS-1$
+ assertNull(vdb.getModel("model-unknown")); //$NON-NLS-1$
- modelOne = vdb.getModel("model-one");
- assertEquals("model-one", modelOne.getName());
- assertEquals("s1", modelOne.getSourceNames().get(0));
+ modelOne = vdb.getModel("model-one"); //$NON-NLS-1$
+ assertEquals("model-one", modelOne.getName()); //$NON-NLS-1$
+ assertEquals("s1", modelOne.getSourceNames().get(0)); //$NON-NLS-1$
assertEquals(Model.Type.PHYSICAL, modelOne.getModelType());
- assertEquals("model-value-override", modelOne.getPropertyValue("model-prop"));
+ assertEquals("model-value-override", modelOne.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
assertFalse(modelOne.isVisible());
- modelTwo = vdb.getModel("model-two");
- assertEquals("model-two", modelTwo.getName());
- assertTrue(modelTwo.getSourceNames().contains("s1"));
- assertTrue(modelTwo.getSourceNames().contains("s2"));
+ modelTwo = vdb.getModel("model-two"); //$NON-NLS-1$
+ assertEquals("model-two", modelTwo.getName()); //$NON-NLS-1$
+ assertTrue(modelTwo.getSourceNames().contains("s1")); //$NON-NLS-1$
+ assertTrue(modelTwo.getSourceNames().contains("s2")); //$NON-NLS-1$
assertEquals(Model.Type.VIRTUAL, modelTwo.getModelType()); // this is not persisted in the XML
- assertEquals("model-value", modelTwo.getPropertyValue("model-prop"));
+ assertEquals("model-value", modelTwo.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue(vdb.getValidityErrors().contains("There is an error in VDB"));
+ assertTrue(vdb.getValidityErrors().contains("There is an error in VDB")); //$NON-NLS-1$
+
+ List<DataRole> roles = vdb.getDataRoles();
+
+ assertTrue(roles.size() == 1);
+
+ DataRoleMetadata role = vdb.getDataRole("roleOne"); //$NON-NLS-1$
+ assertEquals("roleOne described", role.getDescription()); //$NON-NLS-1$
+ assertNotNull(role.getMappedRoleNames());
+ assertTrue(role.getMappedRoleNames().contains("ROLE1")); //$NON-NLS-1$
+ assertTrue(role.getMappedRoleNames().contains("ROLE2")); //$NON-NLS-1$
+
+ assertEquals(2, role.getPermissions().size());
+ PermissionMetaData p1 = role.getPermission("myTable.T1"); //$NON-NLS-1$
+
+ assertTrue(p1.isAllowRead());
+ assertFalse(p1.isAllowDelete());
+
+ PermissionMetaData p2 = role.getPermission("myTable.T2"); //$NON-NLS-1$
+ assertFalse(p2.isAllowRead());
+ assertTrue(p2.isAllowDelete());
}
}
14 years, 9 months
teiid SVN: r1971 - trunk/documentation/reference/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-03-16 17:55:06 -0400 (Tue, 16 Mar 2010)
New Revision: 1971
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
Log:
TEIID-897 updating the docs for the auto wrap detect mode
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2010-03-16 21:23:22 UTC (rev 1970)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2010-03-16 21:55:06 UTC (rev 1971)
@@ -3,11 +3,11 @@
<chapter id="transaction_support">
<title>Transaction Support</title>
<para>
- Teiid utilizes XA transactions for both participating in global
- transactions and for demarcating its own local and command scoped
+ Teiid utilizes XA transactions for participating in global
+ transactions and for demarcating its local and command scoped
transactions.
<ulink url="http://www.jboss.org/jbosstm/">JBoss Transactions</ulink>
- is used by Teiid as its internal transaction manager. See
+ is used by Teiid as its transaction manager. See
<ulink url="http://www.jboss.org/jbosstm/docs/index.html"> this documentation</ulink>
for the advanced features provided by JBoss Transactions.
</para>
@@ -44,6 +44,7 @@
</tbody>
</tgroup>
</table>
+ <para>The default transaction isolation level for Teiid is READ_COMMITTED.</para>
<sect1 id="autowrap">
<title>AutoCommitTxn Execution Property</title>
<para>Since user level commands may execute multiple source
@@ -71,28 +72,39 @@
<row>
<entry>ON</entry>
<entry>Wrap each command in a transaction. This mode is the
- safest, but may be burdonsome on performance.</entry>
+ safest, but may introduce performance overhead.</entry>
</row>
<row>
<entry>AUTO</entry>
<entry>
This is the default setting. Will automatically wrap commands in a transaction, but only if
- the command seems to be
- <link linkend="updating_model_count">transactionally unsafe.</link>
+ the command seems to be transactionally unsafe.
</entry>
</row>
</tbody>
</tgroup>
</table>
<para>The concept of command safety with respect to a transaction
- is determined by Teiid based upon command type and available
- metadata. Whenever any INSERT, UPDATE, DELETE, or EXECUTE (with
- update count greater than 0) command is detected and the success or
- failure of that command is not the same as the user level command,
- then the command is deemed unsafe without a transaction.</para>
- <para>The update count may be set on dynamic SQL as part of the
- command and on all other procedures as part of the procedure metadata
- in the model.</para>
+ is determined by Teiid based upon command type, the transaction isolation level, and available
+ metadata. A wrapping transaction is not needed if:
+ <itemizedlist>
+ <listitem>
+ <para>If a user command is fully pushed to the source.
+ </para>
+ </listitem>
+ <listitem>
+ <para>If the user command is a SELECT (including XML) or an XQuery and the transaction isolation is not REPEATABLE_READ nor SERIALIABLE.
+ </para>
+ </listitem>
+ <listitem>
+ <para>If the user command is a stored procedure and the transaction isolation is not REPEATABLE_READ nor SERIALIABLE and the
+ <link linkend="updating_model_count">updating model count</link> is zero.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>The update count may be set on all procedures as part of
+ the procedure metadata in the model.</para>
</sect1>
<sect1 id="updating_model_count">
<title>Updating Model Count</title>
@@ -110,14 +122,12 @@
<row>
<entry>Count</entry>
<entry>Description</entry>
- <entry>Default For</entry>
</row>
</thead>
<tbody>
<row>
<entry>0</entry>
<entry>No updates are performed by this command.</entry>
- <entry>Dynamic SQL instructions</entry>
</row>
<row>
<entry>1</entry>
@@ -127,30 +137,16 @@
It should not be possible for the update to succeed while the
command fails. Execution is not considered transactionally
unsafe.</entry>
- <entry>Physical procedures, inserts, updates, and deletes
- </entry>
</row>
<row>
<entry>*</entry>
<entry>Any number greater than 1 indicates that exection is
transactionally unsafe and an XA transaction will be required.
</entry>
- <entry>XQuery commands</entry>
</row>
</tbody>
</tgroup>
</table>
- <para> By default Teiid will calculate the updating model count for
- a user query (which may be composed of many subcommands) given the
- above table. Thus a command with a single update as a subcommand may
- still require a transaction if the update is not tied to the success
- of the command.</para>
- <para>
- Explicit values for updating model count may be set using Teiid
- Designer and directly in the
- <link linkend="dynamic_sql">dynamic SQL command</link>
- .
- </para>
</sect1>
<sect1>
<title>JDBC and Transactions</title>
@@ -220,27 +216,21 @@
<itemizedlist>
<listitem>
<para>The client setting of transaction isolation level is not
- used. The transaction isolation level can be set on each XA
+ propogated to the connectors. The transaction isolation level can be set on each XA
connector, however this isolation level is fixed and cannot be
changed at runtime for specific connections/commands.</para>
</listitem>
<listitem>
- <para>Since the client transaction isolation level is not used,
- Teiid internally assumes a level of READ_COMMITTED. This implies
- that explicit transactions are not required for user level commands
- performing multiple reads.</para>
- </listitem>
- <listitem>
<para>Temporary tables are not transactional. For example,
a global temporary table will retain all inserts performed during a
local transaction that was rolled back.</para>
</listitem>
- <listitem>
+ <!-- <listitem>
<para>Connectors may be set to immutable to prevent their
participation in transactions. This is useful in situations where
update commands are being issued against a source that lacks XA
transaction capabilities.</para>
- </listitem>
+ </listitem>-->
</itemizedlist>
</sect1>
</chapter>
\ No newline at end of file
14 years, 9 months
teiid SVN: r1970 - in trunk: client-jdbc/src/main/java/com/metamatrix/jdbc and 67 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-03-16 17:23:22 -0400 (Tue, 16 Mar 2010)
New Revision: 1970
Added:
trunk/engine/src/main/java/com/metamatrix/common/log/LogConstants.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPostProcessor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/SqlEval.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleInputSource.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleXMLReader.java
trunk/engine/src/main/java/com/metamatrix/query/util/Permutation.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
trunk/engine/src/test/java/com/metamatrix/query/util/
Removed:
trunk/engine/src/main/java/com/metamatrix/common/util/
trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
trunk/engine/src/test/java/com/metamatrix/common/util/
trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestBatchedUpdateCommand.java
trunk/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/
trunk/metadata/src/test/java/com/metamatrix/metadata/
trunk/runtime/src/main/java/com/metamatrix/
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
trunk/client-jdbc/src/main/resources/com/metamatrix/jdbc/i18n.properties
trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
trunk/common-core/src/main/java/com/metamatrix/common/types/StandardXMLTranslator.java
trunk/common-core/src/main/java/com/metamatrix/common/types/XMLTranslator.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/TestTPCR.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/TestXMLTypeTranslations.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java
trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java
trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanJoins.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java
trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/batch/BatchedUpdatePlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AssignmentInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CreateCursorResultSetInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/program/Program.java
trunk/engine/src/main/java/com/metamatrix/query/processor/program/ProgramInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PlanExecutionNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/UnionAllNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AbortProcessingInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddCommentInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddNodeInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndBlockInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndDocumentInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecStagingTableInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/IfInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/InitializeDocumentInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveCursorInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveDocInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/WhileInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BatchedUpdateCommand.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Create.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Drop.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DynamicCommand.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ProcedureContainer.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/XQuery.java
trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java
trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
trunk/engine/src/main/java/com/metamatrix/query/xquery/saxon/SaxonXQueryExpression.java
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
trunk/engine/src/main/java/org/teiid/security/roles/AuthorizationPermissionsImpl.java
trunk/engine/src/main/java/org/teiid/security/roles/AuthorizationPolicyFactory.java
trunk/engine/src/main/java/org/teiid/security/roles/BasicAuthorizationPermission.java
trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptionalJoins.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestNameInSourceResolverVisitor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/TestSqlEval.java
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLPlanningEnhancements.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
trunk/engine/src/test/java/com/metamatrix/query/util/TestPermutation.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/Index.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java
trunk/runtime/src/main/java/org/teiid/services/AuthorizationServiceImpl.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
trunk/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
trunk/runtime/src/main/java/org/teiid/transport/SocketTransport.java
Log:
TEIID-897 rounding out the DETECT autoCommit transaction logic. still need to refine connector updatability. consolidated several engine packages and removed the logic to get subplans (required splitting the stylesheet handling into a separate class).
Modified: trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -71,6 +71,7 @@
private int rowLimit;
private Serializable executionPayload;
private long executionId;
+ private int transactionIsolation;
public RequestMessage() {
}
@@ -322,6 +323,14 @@
public void setResultsMode(ResultsMode resultsMode) {
this.resultsMode = resultsMode;
}
+
+ public int getTransactionIsolation() {
+ return transactionIsolation;
+ }
+
+ public void setTransactionIsolation(int transactionIsolation) {
+ this.transactionIsolation = transactionIsolation;
+ }
@Override
public void readExternal(ObjectInput in) throws IOException,
@@ -344,6 +353,7 @@
this.rowLimit = in.readInt();
this.executionPayload = (Serializable)in.readObject();
this.executionId = in.readLong();
+ this.transactionIsolation = in.readInt();
}
@Override
@@ -366,6 +376,7 @@
out.writeInt(rowLimit);
out.writeObject(executionPayload);
out.writeLong(executionId);
+ out.writeInt(transactionIsolation);
}
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -116,7 +116,8 @@
private boolean disableLocalTransactions = false;
private DQP dqp;
- protected ServerConnection serverConn;
+ protected ServerConnection serverConn;
+ private int transactionIsolation = Connection.TRANSACTION_READ_COMMITTED;
/**
* <p>MMConnection constructor, tring to establish connection to metamatrix with
@@ -525,16 +526,8 @@
return ResultSet.HOLD_CURSORS_OVER_COMMIT;
}
- /**
- * Return the corresponding java.sql.Connection Transaction isolation level that
- * this connection is currently set to. Although there is no concept of transaction
- * isolation in MetaMatrix, it is assumed that the level is TRANSACTION_SERIALIZABLE
- * to be able to work with client applications.
- * @return int value giving the transaction isolation level
- * @throws SQLException
- */
public int getTransactionIsolation() throws SQLException {
- return Connection.TRANSACTION_SERIALIZABLE;
+ return this.transactionIsolation;
}
/**
@@ -1034,7 +1027,7 @@
}
public void setTransactionIsolation(int level) throws SQLException {
-
+ this.transactionIsolation = level;
}
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -844,6 +844,7 @@
reqMsg.setFetchSize(this.fetchSize);
reqMsg.setStyleSheet(this.styleSheet);
reqMsg.setRowLimit(this.maxRows);
+ reqMsg.setTransactionIsolation(this.driverConnection.getTransactionIsolation());
// Get connection properties and set them onto request message
copyPropertiesToRequest(reqMsg);
Modified: trunk/client-jdbc/src/main/resources/com/metamatrix/jdbc/i18n.properties
===================================================================
--- trunk/client-jdbc/src/main/resources/com/metamatrix/jdbc/i18n.properties 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/client-jdbc/src/main/resources/com/metamatrix/jdbc/i18n.properties 2010-03-16 21:23:22 UTC (rev 1970)
@@ -131,7 +131,7 @@
MMDataSource.Port_number_must_be_positive=The port number must be a positive number
MMDataSource.serverPort_must_be_a_number=The serverPort property must be a number.
MMDataSource.Server_name_required=The server name must be specified
-MMDataSource.Invalid_trans_auto_wrap_mode=The transaction auto-wrap setting must be one of \"{0}\", \"{1}\", \"{2}\", or \"{3}\".
+MMDataSource.Invalid_trans_auto_wrap_mode=The transaction auto-wrap setting must be one of \"{0}\", \"{1}\", or \"{2}\".
MMDataSource.Name_value_pair_missing_name=The name-value pair \"{0}\" is missing a name
MMDataSource.Name_value_pair_missing_value=The name-value pair \"{0}\" is missing a value
MMDataSource.Name_value_pair_used=There name-value pair \"{0}\" has the same name as a previous pair in the same credential specification
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,7 +22,6 @@
package com.metamatrix.common.types;
-import java.io.IOException;
import java.lang.ref.WeakReference;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -771,7 +770,7 @@
StandardXMLTranslator sxt = new StandardXMLTranslator(value, null);
try {
return new XMLType(new SQLXMLImpl(sxt.getString()));
- } catch (IOException e) {
+ } catch (Exception e) {
throw new MetaMatrixRuntimeException(e);
}
}
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/StandardXMLTranslator.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/StandardXMLTranslator.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/StandardXMLTranslator.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -61,19 +61,13 @@
}
@Override
- public void translate(Writer writer) throws IOException {
- try {
- Transformer t = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(idenityTransform)));
- writer.write(XMLPI);
- if (useIndentation()) {
- writer.write(newLine);
- }
- t.transform(source, new StreamResult(writer));
- } catch (TransformerException e) {
- IOException ex = new IOException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ public void translate(Writer writer) throws TransformerException, IOException {
+ Transformer t = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(idenityTransform)));
+ writer.write(XMLPI);
+ if (useIndentation()) {
+ writer.write(newLine);
}
+ t.transform(source, new StreamResult(writer));
}
private boolean useIndentation() {
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/XMLTranslator.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/XMLTranslator.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/XMLTranslator.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -26,15 +26,17 @@
import java.io.StringWriter;
import java.io.Writer;
+import javax.xml.transform.TransformerException;
+
/**
* This an interface defined to convert the various kinds of the XML sources
* defined into a character stream.
*/
public abstract class XMLTranslator {
- public abstract void translate(Writer writer) throws IOException;
+ public abstract void translate(Writer writer) throws TransformerException, IOException;
- public String getString() throws IOException {
+ public String getString() throws IOException, TransformerException {
StringWriter writer = new StringWriter();
this.translate(writer);
return writer.toString();
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -23,6 +23,7 @@
package com.metamatrix.common.types.basic;
import java.io.IOException;
+import java.io.Reader;
import java.sql.SQLException;
import com.metamatrix.common.types.DataTypeManager;
@@ -47,15 +48,23 @@
*/
public Object transformDirect(Object value) throws TransformationException {
XMLType source = (XMLType)value;
-
+ Reader reader = null;
try {
char[] result = new char[DataTypeManager.MAX_STRING_LENGTH];
- int read = source.getCharacterStream().read(result);
+ reader = source.getCharacterStream();
+ int read = reader.read(result);
return new String(result, 0, read);
} catch (SQLException e) {
throw new TransformationException(e, CorePlugin.Util.getString("failed_convert", new Object[] {getSourceType().getName(), getTargetType().getName()})); //$NON-NLS-1$
} catch (IOException e) {
throw new TransformationException(e, CorePlugin.Util.getString("failed_convert", new Object[] {getSourceType().getName(), getTargetType().getName()})); //$NON-NLS-1$
+ } finally {
+ try {
+ if (reader != null) {
+ reader.close();
+ }
+ } catch (IOException e) {
+ }
}
}
Modified: trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -93,15 +93,15 @@
public static byte[] convertToByteArray(final InputStream is) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(out);
-
- byte[] l_buffer = new byte[1024]; // buffer holding bytes to be transferred
- int l_nbytes = 0; // Number of bytes read
- while ((l_nbytes = is.read(l_buffer)) != -1) // Read from BLOB stream
- bos.write(l_buffer,0,l_nbytes); // Write to file stream
-
- bos.flush();
- bos.close();
-
+ try {
+ byte[] l_buffer = new byte[1024]; // buffer holding bytes to be transferred
+ int l_nbytes = 0; // Number of bytes read
+ while ((l_nbytes = is.read(l_buffer)) != -1) // Read from BLOB stream
+ bos.write(l_buffer,0,l_nbytes); // Write to file stream
+ } finally {
+ is.close();
+ bos.close();
+ }
byte[] data = out.toByteArray();
return data;
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -35,7 +35,6 @@
import org.teiid.connector.language.Expression;
import org.teiid.connector.language.Function;
import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.LanguageFactory;
import com.metamatrix.query.unittest.TimestampUtil;
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/TestTPCR.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/TestTPCR.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/TestTPCR.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -27,7 +27,7 @@
import org.teiid.connector.jdbc.oracle.OracleCapabilities;
import org.teiid.connector.jdbc.sqlserver.SqlServerCapabilities;
-import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
+import org.teiid.dqp.internal.datamgr.impl.CapabilitiesConverter;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -193,7 +193,6 @@
METADATA, null, finder,
new String[] {"SELECT v_0.c_0, COUNT(*) AS c_1, SUM(v_0.c_1) AS c_2 FROM (SELECT left(g_0.C_PHONE, 2) AS c_0, g_0.C_ACCTBAL AS c_1 FROM TPCR_Oracle_9i.CUSTOMER AS g_0 WHERE (left(g_0.C_PHONE, 2) IN ('13', '31', '23', '29', '30', '18', '17')) AND (g_0.C_ACCTBAL > (SELECT AVG(g_1.C_ACCTBAL) FROM TPCR_Oracle_9i.CUSTOMER AS g_1 WHERE (g_1.C_ACCTBAL > 0.0) AND (left(g_1.C_PHONE, 2) IN ('13', '31', '23', '29', '30', '18', '17')))) AND (NOT (EXISTS (SELECT g_2.O_ORDERKEY, g_2.O_CUSTKEY, g_2.O_ORDERSTATUS, g_2.O_TOTALPRICE, g_2.O_ORDERDATE, g_2.O_ORDERPRIORITY, g_2.O_CLERK, g_2.O_SHIPPRIORITY, g_2.O_COMMENT FROM TPCR_Oracle_9i.ORDERS AS g_2 WHERE g_2.O_CUSTKEY = g_0.C_CUSTKEY)))) AS v_0 GROUP BY v_0.c_0 ORDER BY c_0"}, true); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- TestOptimizer.checkSubPlanCount(plan, 0);
}
public void testDefect22475() throws Exception {
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/TestXMLTypeTranslations.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/TestXMLTypeTranslations.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/TestXMLTypeTranslations.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -29,7 +29,7 @@
import java.util.Set;
import org.teiid.connector.jdbc.oracle.OracleCapabilities;
-import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
+import org.teiid.dqp.internal.datamgr.impl.CapabilitiesConverter;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.query.metadata.QueryMetadataInterface;
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -32,10 +32,10 @@
import java.util.concurrent.atomic.AtomicLong;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -112,7 +112,7 @@
private int columnCount;
public ManagedBatchImpl(String id, FileStore store, TupleBatch batch) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", batchAdded.incrementAndGet()); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", batchAdded.incrementAndGet()); //$NON-NLS-1$
this.id = id;
this.store = store;
this.activeBatch = batch;
@@ -149,7 +149,7 @@
@Override
public TupleBatch getBatch(boolean cache, String[] types) throws MetaMatrixComponentException {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, "Reading batch from disk", readAttempts.incrementAndGet(), "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, "Reading batch from disk", readAttempts.incrementAndGet(), "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
synchronized (activeBatches) {
TupleBufferInfo tbi = activeBatches.remove(this.id);
if (tbi != null) {
@@ -185,7 +185,7 @@
return batch;
}
}
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, "Reading batch from disk", readCount.incrementAndGet()); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, "Reading batch from disk", readCount.incrementAndGet()); //$NON-NLS-1$
try {
ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(store.createInputStream(this.offset), IO_BUFFER_SIZE));
batch = new TupleBatch();
@@ -210,7 +210,7 @@
TupleBatch batch = activeBatch;
if (batch != null) {
if (!persistent) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, "Writing batch to disk", writeCount.incrementAndGet()); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, "Writing batch to disk", writeCount.incrementAndGet()); //$NON-NLS-1$
synchronized (store) {
offset = store.getLength();
FileStoreOutputStream fsos = store.createOutputStream(IO_BUFFER_SIZE);
@@ -349,16 +349,16 @@
}
};
TupleBuffer tupleBuffer = new TupleBuffer(batchManager, newID, elements, getProcessorBatchSize());
- if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
- LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, new Object[]{"Creating TupleBuffer:", newID, "of type "+tupleSourceType}); //$NON-NLS-1$ //$NON-NLS-2$
+ if (LogManager.isMessageToBeRecorded(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, new Object[]{"Creating TupleBuffer:", newID, "of type "+tupleSourceType}); //$NON-NLS-1$ //$NON-NLS-2$
}
return tupleBuffer;
}
@Override
public FileStore createFileStore(String name) {
- if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
- LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$
}
return this.diskMgr.createFileStore(name);
}
@@ -461,7 +461,7 @@
try {
mb.persist();
} catch (MetaMatrixComponentException e) {
- LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, e, "Error persisting batch, attempts to read that batch later will result in an exception"); //$NON-NLS-1$
+ LogManager.logDetail(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, e, "Error persisting batch, attempts to read that batch later will result in an exception"); //$NON-NLS-1$
}
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -221,8 +221,8 @@
File createFile(String name, int fileNumber) throws MetaMatrixComponentException {
try {
File storageFile = File.createTempFile(FILE_PREFIX + name + "_" + String.valueOf(fileNumber) + "_", null, this.dirFile); //$NON-NLS-1$ //$NON-NLS-2$
- if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
- LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR, "Created temporary storage area file " + storageFile.getAbsoluteFile()); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR, "Created temporary storage area file " + storageFile.getAbsoluteFile()); //$NON-NLS-1$
}
return storageFile;
} catch(IOException e) {
Copied: trunk/engine/src/main/java/com/metamatrix/common/log/LogConstants.java (from rev 1958, trunk/engine/src/main/java/com/metamatrix/common/util/LogConstants.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/log/LogConstants.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/common/log/LogConstants.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -0,0 +1,47 @@
+/*
+ * 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.common.log;
+
+import org.teiid.connector.basic.DefaultConnectorLogger;
+
+public interface LogConstants {
+ // add the new contexts to the Log4JUtil.java class, for configuration purpose
+ public static final String CTX_SESSION = "SESSION"; //$NON-NLS-1$
+ public static final String CTX_MEMBERSHIP = "MEMBERSHIP"; //$NON-NLS-1$
+ public static final String CTX_AUTHORIZATION = "AUTHORIZATION"; //$NON-NLS-1$
+ public static final String CTX_TRANSPORT = "TRANSPORT"; //$NON-NLS-1$
+ public static final String CTX_QUERY_PLANNER = "PLANNER"; //$NON-NLS-1$
+ public static final String CTX_DQP = "PROCESSOR"; //$NON-NLS-1$
+ public static final String CTX_CONNECTOR = DefaultConnectorLogger.CTX_CONNECTOR;
+ public static final String CTX_BUFFER_MGR = "BUFFER_MGR"; //$NON-NLS-1$
+ public static final String CTX_TXN_LOG = "TXN_LOG"; //$NON-NLS-1$
+ public static final String CTX_COMMANDLOGGING = "COMMAND_LOG"; //$NON-NLS-1$
+ public static final String CTX_AUDITLOGGING = "AUDIT_LOG"; //$NON-NLS-1$
+ public static final String CTX_ADMIN_API = "ADMIN_API"; //$NON-NLS-1$
+ public static final String CTX_RUNTIME = "RUNTIME"; //$NON-NLS-1$
+ // Query contexts
+ public static final String CTX_FUNCTION_TREE = CTX_QUERY_PLANNER + ".FUNCTION_TREE"; //$NON-NLS-1$
+ public static final String CTX_QUERY_RESOLVER = CTX_QUERY_PLANNER + ".RESOLVER"; //$NON-NLS-1$
+ public static final String CTX_XML_PLANNER = CTX_QUERY_PLANNER + ".XML_PLANNER"; //$NON-NLS-1$
+ public static final String CTX_XML_PLAN = CTX_DQP + ".XML_PLAN"; //$NON-NLS-1$
+}
Property changes on: trunk/engine/src/main/java/com/metamatrix/common/log/LogConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -31,6 +31,7 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.dqp.service.TransactionContext;
+import com.metamatrix.dqp.service.TransactionContext.Scope;
import com.metamatrix.query.sql.lang.Command;
/**
@@ -121,7 +122,7 @@
}
public boolean isTransactional(){
- return this.txnContext != null && this.txnContext.getXid() != null;
+ return this.txnContext != null && this.txnContext.getTransactionType() != Scope.NONE;
}
public Command getCommand() {
@@ -138,7 +139,7 @@
public void setFetchSize(int fetchSize) {
if (fetchSize < 1) {
- throw new IllegalArgumentException("fetch size must be positive");
+ throw new IllegalArgumentException("fetch size must be positive"); //$NON-NLS-1$
}
this.fetchSize = fetchSize;
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -81,6 +81,7 @@
finalRow = in.readInt();
supportsImplicitClose = in.readBoolean();
warnings = (List<Exception>)in.readObject();
+ isTransactional = in.readBoolean();
}
public void writeExternal(ObjectOutput out) throws IOException {
@@ -89,6 +90,7 @@
out.writeInt(finalRow);
out.writeBoolean(supportsImplicitClose);
out.writeObject(warnings);
+ out.writeBoolean(isTransactional);
}
public boolean isTransactional() {
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -46,17 +46,8 @@
private long creationTime;
private boolean rollback;
private Transaction transaction;
- private boolean embeddedTransaction;
private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
- public boolean isEmbeddedTransaction() {
- return embeddedTransaction;
- }
-
- public void setEmbeddedTransaction(boolean embeddedTransaction) {
- this.embeddedTransaction = embeddedTransaction;
- }
-
public long getCreationTime() {
return creationTime;
}
@@ -90,14 +81,17 @@
}
public String toString() {
- StringBuffer sb = new StringBuffer();
- if (getXid() != null) {
- sb.append("xid: ").append(getXid()); //$NON-NLS-1$
- } else {
- sb.append(transaction);
- }
- return sb.toString();
+ return threadId + " " + transactionType + " ID:" + getTransactionId(); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ public String getTransactionId() {
+ if (this.transaction != null) {
+ return this.transaction.toString();
+ } else if (this.getXid() != null) {
+ return this.getXid().toString();
+ }
+ return "NONE"; //$NON-NLS-1$
+ }
public void setRollbackOnly() {
this.rollback = true;
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,25 +22,22 @@
package com.metamatrix.query.function;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.metamatrix.api.exception.query.InvalidFunctionException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.query.function.metadata.FunctionMethod;
+import com.metamatrix.query.function.metadata.FunctionParameter;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.api.exception.query.InvalidFunctionException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.function.metadata.FunctionParameter;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
/**
* The function library is the primary way for the system to find out what
* functions are available, resolve function signatures, and invoke system
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -35,9 +35,9 @@
import java.util.Map;
import java.util.Set;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.core.util.ReflectionHelper;
@@ -62,14 +62,8 @@
// Constant used to look up the special descriptor key in a node map
private static final Integer DESCRIPTOR_KEY = new Integer(-1);
- /**
- * Function selection use: Category name (uppercase) to <Map of function name to List of FunctionMethod>
- */
- private Map metadata = new HashMap();
+ private Map<String, Set<String>> categories = new HashMap<String, Set<String>>();
- /**
- * Function selection use: Map of function name (uppercase) to List of FunctionMethod
- */
private Map<String, List<FunctionMethod>> functionsByName = new HashMap<String, List<FunctionMethod>>();
private Set<FunctionMethod> allFunctions = new HashSet<FunctionMethod>();
@@ -179,26 +173,15 @@
String nameKey = method.getName().toUpperCase();
// Look up function map (create if necessary)
- Map functions = null;
- if(metadata.containsKey(categoryKey)) {
- functions = (Map) metadata.get(categoryKey);
- } else {
- functions = new HashMap();
- metadata.put(categoryKey, functions);
+ Set<String> functions = categories.get(categoryKey);
+ if (functions == null) {
+ functions = new HashSet<String>();
+ categories.put(categoryKey, functions);
}
// Look up function in function map
- List methods = null;
- if(functions.containsKey(nameKey)) {
- methods = (List) functions.get(nameKey);
- } else {
- methods = new ArrayList();
- functions.put(nameKey, methods);
- }
+ functions.add(nameKey);
- // Add method to method list
- methods.add(method);
-
// Add method to list by function name
List<FunctionMethod> knownMethods = functionsByName.get(nameKey);
if(knownMethods == null) {
@@ -213,8 +196,8 @@
* Get collection of category names.
* @return Category names
*/
- Collection getCategories() {
- return metadata.keySet();
+ Collection<String> getCategories() {
+ return categories.keySet();
}
/**
@@ -222,19 +205,14 @@
* @param category Category to get (case-insensitive)
* @return Collection of {@link FunctionForm}s
*/
- Collection getFunctionForms(String category) {
- Set functionForms = new HashSet();
+ Collection<FunctionForm> getFunctionForms(String category) {
+ Set<FunctionForm> functionForms = new HashSet<FunctionForm>();
- Map functions = (Map) metadata.get(category.toUpperCase());
+ Set<String> functions = categories.get(category.toUpperCase());
if(functions != null) {
- Iterator functionIter = functions.values().iterator();
- while(functionIter.hasNext()) {
- List methods = (List) functionIter.next();
-
- Iterator methodIter = methods.iterator();
- while(methodIter.hasNext()) {
- FunctionMethod method = (FunctionMethod) methodIter.next();
- functionForms.add(new FunctionForm(method));
+ for (String functionName : functions) {
+ for (FunctionMethod functionMethod : this.functionsByName.get(functionName)) {
+ functionForms.add(new FunctionForm(functionMethod));
}
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,8 +22,6 @@
package com.metamatrix.query.function.source;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -306,10 +306,6 @@
*/
CONNECTOR_ID,
/**
- * @since 6.0.0 indicates the source supports XA transactions
- */
- TRANSACTIONS_XA,
- /**
* @since 6.0.0 indicates support for where all
*/
REQUIRES_CRITERIA,
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -39,8 +39,8 @@
import com.metamatrix.api.exception.query.QueryPlannerException;
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.api.exception.query.QueryValidatorException;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.id.IDGenerator;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.analysis.AnalysisRecord;
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -37,9 +37,9 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.SupportConstants;
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -31,8 +31,8 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryPlannerException;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -34,8 +34,8 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryPlannerException;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanJoins.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanJoins.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanJoins.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -38,7 +38,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.common.util.Permutation;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -54,6 +53,7 @@
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.util.CommandContext;
+import com.metamatrix.query.util.Permutation;
/**
* Determines join orderings based upon dependency and cost information
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -31,8 +31,8 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryPlannerException;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.id.IDGenerator;
import com.metamatrix.query.analysis.AnalysisRecord;
@@ -62,7 +62,6 @@
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.symbol.SelectSymbol;
import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
import com.metamatrix.query.util.CommandContext;
/**
@@ -111,8 +110,7 @@
}
// lookup mapping node for the user command
- Collection groups = GroupCollectorVisitor.getGroups(xmlQuery, true);
- GroupSymbol group = (GroupSymbol) groups.iterator().next();
+ GroupSymbol group = (GroupSymbol)xmlQuery.getFrom().getGroups().iterator().next();
MappingDocument doc = (MappingDocument)metadata.getMappingNode(group.getMetadataID());
doc = (MappingDocument)doc.clone();
@@ -140,7 +138,7 @@
XMLProcessorEnvironment env = planEnv.createProcessorEnvironment(programPlan);
env.setChildPlans(getChildPlans(doc));
XMLPlan plan = new XMLPlan(env);
-
+ plan.setXMLSchemas(metadata.getXMLSchemas(group.getMetadataID()));
if(debug) {
analysisRecord.println(""); //$NON-NLS-1$
analysisRecord.println(plan.toString());
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,7 +22,6 @@
package com.metamatrix.query.parser;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -23,13 +23,14 @@
package com.metamatrix.query.processor;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.*;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.query.processor.BatchCollector.BatchProducer;
import com.metamatrix.query.util.CommandContext;
@@ -143,11 +144,9 @@
* processing
*/
public abstract ProcessorPlan clone();
+
+ public boolean requiresTransaction(boolean transactionalReads) {
+ return transactionalReads;
+ }
- /**
- * Finds all nested plans and returns them.
- * @return List of ProcessorPlan
- * @since 4.2
- */
- public abstract Collection getChildPlans();
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -32,8 +32,8 @@
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.BufferManager.BufferReserveMode;
import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/batch/BatchedUpdatePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/batch/BatchedUpdatePlan.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/batch/BatchedUpdatePlan.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -241,13 +240,13 @@
public List getUpdatePlans() {
return Arrays.asList(updatePlans);
}
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- return Arrays.asList(updatePlans);
+
+ @Override
+ public boolean requiresTransaction(boolean transactionalReads) {
+ if (updatePlans.length == 1) {
+ return updatePlans[0].requiresTransaction(transactionalReads);
+ }
+ return true;
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,8 +22,7 @@
package com.metamatrix.query.processor.proc;
-import java.util.ArrayList;
-import java.util.Collection;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -128,13 +127,10 @@
* @see com.metamatrix.query.processor.program.ProgramInstruction#getChildPlans()
* @since 4.2
*/
- public Collection getChildPlans() {
+ public List<ProcessorPlan> getChildPlans() {
if(this.processPlan != null) {
- List plans = new ArrayList(1);
- plans.add(this.processPlan);
- return plans;
+ return Arrays.asList(this.processPlan);
}
-
return null;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AssignmentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AssignmentInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AssignmentInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -59,7 +59,7 @@
protected void processValue(Object value, VariableContext varContext) throws MetaMatrixComponentException,
MetaMatrixProcessingException {
varContext.setValue(getVariable(), value);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP,
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP,
new Object[] {this.toString() + " The variable " //$NON-NLS-1$
+ getVariable() + " in the variablecontext is updated with the value :", value}); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CreateCursorResultSetInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CreateCursorResultSetInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CreateCursorResultSetInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -24,8 +24,7 @@
*/
package com.metamatrix.query.processor.proc;
-import java.util.ArrayList;
-import java.util.Collection;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -73,7 +72,7 @@
* Returns a deep clone
*/
public Object clone(){
- ProcessorPlan clonedPlan = (ProcessorPlan) this.plan.clone();
+ ProcessorPlan clonedPlan = this.plan.clone();
return new CreateCursorResultSetInstruction(this.rsName, clonedPlan);
}
@@ -89,18 +88,8 @@
return props;
}
- public Object getCommand() { //Defect 13291 - added method to support changes to ProcedurePlan
+ public ProcessorPlan getCommand() { //Defect 13291 - added method to support changes to ProcedurePlan
return plan;
}
- /**
- * @see com.metamatrix.query.processor.program.ProgramInstruction#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- List plans = new ArrayList(1);
- plans.add(this.plan);
- return plans;
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -66,7 +66,7 @@
*/
protected void processValue(Object value, VariableContext varContext) throws MetaMatrixComponentException,
MetaMatrixProcessingException {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP,
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP,
new Object[] {"Processing RaiseErrorInstruction with the value :", value}); //$NON-NLS-1$
throw new ProcedureErrorInstructionException(ERROR_PREFIX + (value != null ? value.toString() : "")); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,7 +22,6 @@
package com.metamatrix.query.processor.proc;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@@ -145,7 +144,7 @@
.getString("ExecDynamicSqlInstruction.0")); //$NON-NLS-1$
}
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP,
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP,
new Object[] { "Executing dynamic sql ", value }); //$NON-NLS-1$
Command command = QueryParser.getQueryParser().parseCommand(value.toString());
@@ -235,7 +234,7 @@
for (SetClause setClause : dynamicCommand.getUsing().getClauses()) {
Object assignment = procEnv.evaluateExpression(setClause.getValue());
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP,
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP,
new Object[] { this, " The using variable ", //$NON-NLS-1$
setClause.getSymbol(), " has value :", assignment }); //$NON-NLS-1$
localContext.setValue(setClause.getSymbol(), assignment);
@@ -343,15 +342,4 @@
return props;
}
- /**
- * @see com.metamatrix.query.processor.program.ProgramInstruction#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- if (this.dynamicProgram != null) {
- return dynamicProgram.getChildPlans();
- }
- return Collections.EMPTY_LIST;
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,10 +22,7 @@
package com.metamatrix.query.processor.proc;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -93,13 +90,13 @@
boolean evalValue = procEnv.evaluateCriteria(condition);
if(evalValue) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, new Object[]{"IFInstruction: "+ //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, new Object[]{"IFInstruction: "+ //$NON-NLS-1$
" The criteria on the if block evaluated to true, processing the if block"}); //$NON-NLS-1$
//push the "if" Program onto the stack
procEnv.push(ifProgram);
} else if(elseProgram != null) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, new Object[]{"IFInstruction: "+ //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, new Object[]{"IFInstruction: "+ //$NON-NLS-1$
" The criteria on the if block evaluated to false, processing the else block"}); //$NON-NLS-1$
//push the "else" Program onto the stack
procEnv.push(elseProgram);
@@ -143,18 +140,4 @@
return props;
}
- /**
- * @see com.metamatrix.query.processor.program.ProgramInstruction#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- List plans = new ArrayList();
- plans.addAll(this.ifProgram.getChildPlans());
- if(this.elseProgram != null) {
- plans.addAll(this.elseProgram.getChildPlans());
- }
- return plans;
- }
-
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -25,7 +25,6 @@
package com.metamatrix.query.processor.proc;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -75,7 +74,7 @@
* Returns a deep clone
*/
public Object clone(){
- ProcessorPlan clonedPlan = (ProcessorPlan) this.plan.clone();
+ ProcessorPlan clonedPlan = this.plan.clone();
return new LoopInstruction((Program)this.loopProgram.clone(), this.rsName, clonedPlan);
}
@@ -92,16 +91,6 @@
}
/**
- * @see com.metamatrix.query.processor.program.ProgramInstruction#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- Collection result = new ArrayList(super.getChildPlans());
- result.addAll(loopProgram.getChildPlans());
- return result;
- }
-
- /**
* @see com.metamatrix.query.processor.proc.RepeatedInstruction#testCondition(com.metamatrix.query.processor.proc.ProcedureEnvironment)
*/
public boolean testCondition(ProcedurePlan procEnv) throws MetaMatrixComponentException, MetaMatrixProcessingException {
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -23,7 +23,6 @@
package com.metamatrix.query.processor.proc;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -128,6 +127,10 @@
this.programs.add(originalProgram);
createVariableContext();
}
+
+ public Program getOriginalProgram() {
+ return originalProgram;
+ }
/**
* @see ProcessorPlan#initialize(ProcessorDataManager, Object)
@@ -165,7 +168,7 @@
originalProgram.resetProgramCounter();
programs.clear();
programs.push(originalProgram);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, "ProcedurePlan reset"); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, "ProcedurePlan reset"); //$NON-NLS-1$
}
public ProcessorDataManager getDataManager() {
@@ -264,23 +267,23 @@
Program program = peek();
inst = program.getCurrentInstruction();
if (inst == null){
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, "Finished program", program); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, "Finished program", program); //$NON-NLS-1$
this.pop();
continue;
}
if (inst instanceof RepeatedInstruction) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, "Executing repeated instruction", inst); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, "Executing repeated instruction", inst); //$NON-NLS-1$
RepeatedInstruction loop = (RepeatedInstruction)inst;
if (loop.testCondition(this)) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, "Passed condition, executing program " + loop.getNestedProgram()); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, "Passed condition, executing program " + loop.getNestedProgram()); //$NON-NLS-1$
inst.process(this);
this.push(loop.getNestedProgram());
continue;
}
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, "Exiting repeated instruction", inst); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, "Exiting repeated instruction", inst); //$NON-NLS-1$
loop.postInstruction(this);
} else {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, "Executing instruction", inst); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, "Executing instruction", inst); //$NON-NLS-1$
inst.process(this);
}
program.incrementProgramCounter();
@@ -370,14 +373,6 @@
return props;
}
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- return this.originalProgram.getChildPlans();
- }
-
public void setMetadata( QueryMetadataInterface metadata ) {
this.metadata = metadata;
}
@@ -630,4 +625,9 @@
return programs.peek();
}
+ @Override
+ public boolean requiresTransaction(boolean transactionalReads) {
+ return true;
+ }
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -24,7 +24,6 @@
*/
package com.metamatrix.query.processor.proc;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -76,14 +75,6 @@
}
/**
- * @see com.metamatrix.query.processor.program.ProgramInstruction#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- return this.whileProgram.getChildPlans();
- }
-
- /**
* @throws MetaMatrixProcessingException
* @see com.metamatrix.query.processor.proc.RepeatedInstruction#testCondition(com.metamatrix.query.processor.proc.ProcedureEnvironment)
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/program/Program.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/program/Program.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/program/Program.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -23,11 +23,9 @@
package com.metamatrix.query.processor.program;
import java.util.*;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
import com.metamatrix.query.processor.Describable;
+import com.metamatrix.query.processor.ProcessorPlan;
/**
* A program is a sequence of {@link ProgramInstruction ProgramInstruction}. Certain
@@ -156,12 +154,12 @@
* @return List of ProcessorPlan
* @since 4.2
*/
- public Collection getChildPlans() {
- List plans = new ArrayList();
+ public List<ProcessorPlan> getChildPlans() {
+ List<ProcessorPlan> plans = new ArrayList<ProcessorPlan>();
if (programInstructions != null) {
for(int i=0; i<programInstructions.size(); i++) {
ProgramInstruction inst = (ProgramInstruction) programInstructions.get(i);
- Collection instPlans = inst.getChildPlans();
+ Collection<ProcessorPlan> instPlans = inst.getChildPlans();
if(instPlans != null) {
plans.addAll(instPlans);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/program/ProgramInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/program/ProgramInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/program/ProgramInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,13 +22,14 @@
package com.metamatrix.query.processor.program;
-import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.query.processor.Describable;
+import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.proc.ProcedurePlan;
/**
@@ -61,7 +62,7 @@
* @return List of ProcessorPlan
* @since 4.2
*/
- public Collection getChildPlans() {
+ public List<ProcessorPlan> getChildPlans() {
return null;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -335,14 +335,6 @@
}
@Override
- public Collection<? extends LanguageObject> getLanguageObjects() {
- if (this.joinCriteria == null) {
- return Collections.emptyList();
- }
- return Arrays.asList(this.joinCriteria);
- }
-
- @Override
protected void addBatchRow(List row) {
List projectTuple = projectTuple(this.projectionIndexes, row);
super.addBatchRow(projectTuple);
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PlanExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PlanExecutionNode.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PlanExecutionNode.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,7 +22,6 @@
package com.metamatrix.query.processor.relational;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -139,7 +138,7 @@
try {
plan.close();
} catch (MetaMatrixComponentException e1){
- LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, e1, "Error closing processor"); //$NON-NLS-1$
+ LogManager.logDetail(com.metamatrix.common.log.LogConstants.CTX_DQP, e1, "Error closing processor"); //$NON-NLS-1$
}
}
@@ -147,7 +146,7 @@
super.getNodeString(str);
}
- protected ProcessorPlan getProcessorPlan(){
+ public ProcessorPlan getProcessorPlan(){
return this.plan;
}
@@ -171,13 +170,4 @@
return props;
}
- /**
- * @see com.metamatrix.query.processor.relational.RelationalNode#getSubPlans()
- * @since 4.2
- */
- public List getChildPlans() {
- List subPlans = new ArrayList(1);
- subPlans.add(this.plan);
- return subPlans;
- }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -267,9 +267,4 @@
return props;
}
- @Override
- public Collection<LanguageObject> getLanguageObjects() {
- return this.getSelectSymbols();
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -23,10 +23,8 @@
package com.metamatrix.query.processor.relational;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -41,13 +39,9 @@
import com.metamatrix.query.processor.Describable;
import com.metamatrix.query.processor.DescribableUtil;
import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.BatchCollector.BatchProducer;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
import com.metamatrix.query.util.CommandContext;
public abstract class RelationalNode implements Cloneable, Describable, BatchProducer {
@@ -388,7 +382,7 @@
* @param batch Batch being sent
*/
private void recordBatch(TupleBatch batch) {
- if (!this.context.getProcessDebug() || !LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ if (!this.context.getProcessDebug() || !LogManager.isMessageToBeRecorded(com.metamatrix.common.log.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
return;
}
// Print summary
@@ -404,7 +398,7 @@
for (int row = batch.getBeginRow(); row <= batch.getEndRow(); row++) {
str.append("\t").append(row).append(": ").append(batch.getTuple(row)).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, str.toString());
+ LogManager.logDetail(com.metamatrix.common.log.LogConstants.CTX_DQP, str.toString());
}
// =========================================================================
@@ -500,34 +494,6 @@
}
}
- /**
- * Find all ProcessorPlans used by this node. If no plans are used, null may be returned.
- * The default implementation will return null.
- * @return List of ProcessorPlan or null if none
- * @since 4.2
- */
- public List getChildPlans() {
- Collection<? extends LanguageObject> objs = getLanguageObjects();
- if (objs == null || objs.isEmpty()) {
- return null;
- }
- Collection<SubqueryContainer> containers = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(objs);
- if (containers.isEmpty()) {
- return null;
- }
- List<ProcessorPlan> plans = new LinkedList<ProcessorPlan>();
- for (SubqueryContainer container : containers) {
- if (container.getCommand().getProcessorPlan() != null) {
- plans.add(container.getCommand().getProcessorPlan());
- }
- }
- return plans;
- }
-
- public Collection<? extends LanguageObject> getLanguageObjects() {
- return null;
- }
-
/*
* @see com.metamatrix.query.processor.Describable#getDescriptionProperties()
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalPlan.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalPlan.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -23,7 +23,6 @@
package com.metamatrix.query.processor.relational;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -34,10 +33,10 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.log.LogManager;
import com.metamatrix.query.processor.DescribableUtil;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.sql.lang.QueryCommand;
import com.metamatrix.query.util.CommandContext;
/**
@@ -133,34 +132,6 @@
return plan;
}
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- // Walk nodes and find all sub-plans
- List plans = new ArrayList();
- findPlans(this.root, plans);
- return plans;
- }
-
- private void findPlans(RelationalNode node, List plans) {
- List subPlans = node.getChildPlans();
- if(subPlans != null) {
- plans.addAll(subPlans);
- }
-
- RelationalNode[] children = node.getChildren();
- for(int i=0; i<children.length; i++) {
- if(children[i] != null) {
- findPlans(children[i], plans);
- } else {
- break;
- }
- }
- }
-
-
/*
* @see com.metamatrix.query.processor.Describable#getDescriptionProperties()
*/
@@ -181,5 +152,19 @@
public void setOutputElements(List outputCols) {
this.outputCols = outputCols;
}
+
+ @Override
+ public boolean requiresTransaction(boolean transactionalReads) {
+ if (root instanceof DependentAccessNode) {
+ if (transactionalReads || !(((DependentAccessNode)root).getCommand() instanceof QueryCommand)) {
+ return true;
+ }
+ return false;
+ }
+ if (root instanceof AccessNode) {
+ return false; //full pushdown
+ }
+ return transactionalReads; //embedded procedures are not detected
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,8 +22,6 @@
package com.metamatrix.query.processor.relational;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -33,7 +31,6 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.util.CommandContext;
@@ -158,9 +155,4 @@
return props;
}
- @Override
- public Collection<? extends LanguageObject> getLanguageObjects() {
- return Arrays.asList(this.criteria);
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -261,8 +261,8 @@
bufferManager.releaseBuffers(release);
reserved -= release;
try {
- if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.TRACE)) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, "Merging", maxSortIndex, "sublists out of", activeTupleBuffers.size()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (LogManager.isMessageToBeRecorded(com.metamatrix.common.log.LogConstants.CTX_DQP, MessageLevel.TRACE)) {
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, "Merging", maxSortIndex, "sublists out of", activeTupleBuffers.size()); //$NON-NLS-1$ //$NON-NLS-2$
}
// initialize the sublists with the min value
for(int i = 0; i<maxSortIndex; i++) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/UnionAllNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/UnionAllNode.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/UnionAllNode.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -100,9 +100,6 @@
}
}
} catch(BlockedException e) {
- if(i<children.length-1 && hasDependentProcedureExecutionNode(children[0])){
- throw e;
- }
// no problem - try the next one
}
} else {
@@ -162,22 +159,4 @@
return props;
}
- private boolean hasDependentProcedureExecutionNode(RelationalNode node) {
- if(node == null){
- return false;
- }
-
- if(node instanceof DependentProcedureExecutionNode) {
- return true;
- }
- if(node.getChildren() != null ) {
- for(int i=0; i<node.getChildren().length; i++){
- if(hasDependentProcedureExecutionNode(node.getChildren()[i])){
- return true;
- }
- }
- }
- return false;
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AbortProcessingInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AbortProcessingInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AbortProcessingInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -60,7 +60,7 @@
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, "ABORT processing now."); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, "ABORT processing now."); //$NON-NLS-1$
throw new MetaMatrixComponentException(DEFAULT_MESSAGE);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddCommentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddCommentInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddCommentInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -56,7 +56,7 @@
DocumentInProgress doc = env.getDocumentInProgress();
doc.addComment(this.commentText);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, "COMMENT"); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, "COMMENT"); //$NON-NLS-1$
env.incrementCurrentProgramCounter();
return context;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddNodeInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddNodeInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddNodeInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -95,15 +95,15 @@
if (defaultValue != null){
if(isElement) {
success = doc.addElement(descriptor, defaultValue);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName(),"fixed value",defaultValue}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName(),"fixed value",defaultValue}); //$NON-NLS-1$ //$NON-NLS-2$
} else {
success = doc.addAttribute(descriptor, defaultValue);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"TAG attr",descriptor.getName(),"fixed value",defaultValue}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"TAG attr",descriptor.getName(),"fixed value",defaultValue}); //$NON-NLS-1$ //$NON-NLS-2$
}
} else {
if(isElement) {
success = doc.addElement(descriptor, nillableDescriptor);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName()}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName()}); //$NON-NLS-1$
} //else nothing gets outputted for attribute with no content
}
} else {
@@ -113,24 +113,24 @@
if (valueStr != null){
if(isElement) {
success = doc.addElement(descriptor, valueStr);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName(),"value",valueStr}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName(),"value",valueStr}); //$NON-NLS-1$ //$NON-NLS-2$
} else {
success = doc.addAttribute(descriptor, valueStr);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"TAG attr",descriptor.getName(),"value",valueStr}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"TAG attr",descriptor.getName(),"value",valueStr}); //$NON-NLS-1$ //$NON-NLS-2$
}
} else {
if (defaultValue != null){
if(isElement) {
success = doc.addElement(descriptor, defaultValue);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName(),"default value",defaultValue}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName(),"default value",defaultValue}); //$NON-NLS-1$ //$NON-NLS-2$
} else {
success = doc.addAttribute(descriptor, defaultValue);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"TAG attr",descriptor.getName(),"default value",defaultValue}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"TAG attr",descriptor.getName(),"default value",defaultValue}); //$NON-NLS-1$ //$NON-NLS-2$
}
} else {
if(isElement) {
success = doc.addElement(descriptor, nillableDescriptor);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName(),"no value"}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"TAG elem",descriptor.getName(),"no value"}); //$NON-NLS-1$ //$NON-NLS-2$
} //else nothing gets outputted for attribute with no content
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndBlockInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndBlockInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndBlockInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -65,7 +65,7 @@
context.removeResultSet(resultSetName);
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{CLOSE_FINISHED,resultSetName});
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{CLOSE_FINISHED,resultSetName});
env.incrementCurrentProgramCounter();
return context;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndDocumentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndDocumentInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndDocumentInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -53,7 +53,7 @@
// program stack (don't want to start a new doc in the middle of
// recursive processing)
if (!env.isRecursiveProgramInStack()) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, "ending document"); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, "ending document"); //$NON-NLS-1$
env.getDocumentInProgress().markAsFinished();
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecSqlInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecSqlInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -47,7 +47,7 @@
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"SQL: Result set DOESN'T exist:",resultSetName}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"SQL: Result set DOESN'T exist:",resultSetName}); //$NON-NLS-1$
PlanExecutor executor = context.getResultExecutor(resultSetName);
if (executor == null) {
executor = env.createResultExecutor(resultSetName, info);
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecStagingTableInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecStagingTableInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecStagingTableInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -58,7 +58,7 @@
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
if (!env.isStagingTableLoaded(this.resultSetName)) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"SQL: Result set DOESN'T exist:",resultSetName}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"SQL: Result set DOESN'T exist:",resultSetName}); //$NON-NLS-1$
PlanExecutor executor = context.getResultExecutor(resultSetName);
if (executor == null) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/IfInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/IfInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/IfInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -195,7 +195,7 @@
Program thenProgram = condition.getThenProgram();
env.pushProgram(thenProgram, condition.isProgramRecursive());
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"IF: true condition", condition, "- then program:", thenProgram}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"IF: true condition", condition, "- then program:", thenProgram}); //$NON-NLS-1$ //$NON-NLS-2$
}
return context;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/InitializeDocumentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/InitializeDocumentInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/InitializeDocumentInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -77,7 +77,7 @@
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, "DOC begin"); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, "DOC begin"); //$NON-NLS-1$
// Only process this instruction if there are no recursive programs in the
// program stack (don't want to start a new doc in the middle of
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveCursorInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveCursorInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveCursorInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -51,7 +51,7 @@
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"NEXT", resultSetName}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"NEXT", resultSetName}); //$NON-NLS-1$
context.getNextRow(resultSetName);
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveDocInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveDocInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveDocInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -61,7 +61,7 @@
switch(this.direction) {
case UP:
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, "UP in document"); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, "UP in document"); //$NON-NLS-1$
try {
doc.moveToParent();
} catch (SAXException err) {
@@ -69,7 +69,7 @@
}
break;
case DOWN:
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, "LAST child in document"); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, "LAST child in document"); //$NON-NLS-1$
doc.moveToLastChild();
break;
default:
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -153,7 +153,7 @@
*/
public void close() throws MetaMatrixComponentException {
this.internalProcessor.closeProcessing();
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"closed executor", resultInfo.getResultSetName()}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"closed executor", resultInfo.getResultSetName()}); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -153,7 +153,7 @@
return true;
}
} catch (SAXException e) {
- LogManager.logError(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, e, e.getMessage());
+ LogManager.logError(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, e, e.getMessage());
return false;
}
showState( "addElement(2) - BOT" ); //$NON-NLS-1$
@@ -343,19 +343,19 @@
private void showState( String sOccasion ) {
- if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, MessageLevel.TRACE)) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"\n [showState] State Vars at: " + sOccasion} ); //$NON-NLS-1$
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent: " + currentParent} ); //$NON-NLS-1$
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentObject: " + currentObject} ); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, MessageLevel.TRACE)) {
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"\n [showState] State Vars at: " + sOccasion} ); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent: " + currentParent} ); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentObject: " + currentObject} ); //$NON-NLS-1$
if ( currentObject != null ) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentObject.getNillableDescriptor(): " + currentObject.getNillableDescriptor()}); //$NON-NLS-1$
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] workingElements: " + currentObject.getChildren()}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentObject.getNillableDescriptor(): " + currentObject.getNillableDescriptor()}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] workingElements: " + currentObject.getChildren()}); //$NON-NLS-1$
}
if ( currentParent != null ) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent.getParent(): " + currentParent.getParent()}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent.getParent(): " + currentParent.getParent()}); //$NON-NLS-1$
} else {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent.getParent(): is NULL "}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent.getParent(): is NULL "}); //$NON-NLS-1$
}
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/WhileInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/WhileInstruction.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/WhileInstruction.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -69,7 +69,7 @@
setFirst(context.getVariableContext(), Boolean.TRUE);
}
else {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"WHILE removed finished result set:",resultSetName}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"WHILE removed finished result set:",resultSetName}); //$NON-NLS-1$
//increment the current program counter, so this
//While instruction will not be executed again
@@ -97,7 +97,7 @@
protected void pushProgram(XMLProcessorEnvironment env,
XMLContext context,
List row) throws MetaMatrixComponentException {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"WHILE repeating for result set:",resultSetName,", block program:", blockProgram}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"WHILE repeating for result set:",resultSetName,", block program:", blockProgram}); //$NON-NLS-1$ //$NON-NLS-2$
context.setVariableValues(resultSetName, row);
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -25,10 +25,8 @@
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
-import java.io.Writer;
import java.nio.charset.Charset;
import java.sql.SQLException;
-import java.sql.SQLXML;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -37,19 +35,11 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import net.sf.saxon.TransformerFactoryImpl;
-
import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
@@ -67,11 +57,11 @@
import com.metamatrix.common.buffer.FileStore;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.SQLXMLImpl;
import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.types.XMLTranslator;
import com.metamatrix.common.types.XMLType;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.execution.QueryExecPlugin;
@@ -85,7 +75,6 @@
import com.metamatrix.query.tempdata.TempTableStoreImpl;
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ErrorMessageKeys;
-import com.metamatrix.query.util.XMLFormatConstants;
/**
*
*/
@@ -110,8 +99,6 @@
private FileStore docInProgressStore;
// Post-processing
- private String styleSheet;
- private boolean shouldValidate = false;
private Collection xmlSchemas;
/**
@@ -140,14 +127,11 @@
public void reset() {
super.reset();
- styleSheet = null;
- shouldValidate = false;
-
nextBatchCount = 1;
this.env = (XMLProcessorEnvironment)this.env.clone();
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, "XMLPlan reset"); //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_XML_PLAN, "XMLPlan reset"); //$NON-NLS-1$
}
public ProcessorDataManager getDataManager() {
@@ -216,7 +200,6 @@
private XMLType processXML(LobChunk chunk)
throws MetaMatrixComponentException, BlockedException {
- boolean postProcess = (this.styleSheet != null || this.shouldValidate);
// Note that we need to stream the document right away, as multiple documents
// results are generated from the same "env" object. So the trick here is either
// post process will stream it, or save to buffer manager to stream the document
@@ -253,8 +236,21 @@
}
// check to see if we need to do any post validation on the document.
- if (postProcess){
- xml = postProcessDocument(xml, getProperties());
+ if (getContext().validateXML()){
+ Reader reader;
+ try {
+ reader = xml.getCharacterStream();
+ } catch (SQLException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ try {
+ validateDoc(reader);
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ }
+ }
}
return xml;
@@ -272,7 +268,7 @@
// do the xml processing.
ProcessorInstruction inst = env.getCurrentInstruction();
while (inst != null){
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, "Executing instruction", inst); //$NON-NLS-1$
+ LogManager.logTrace(LogConstants.CTX_XML_PLAN, "Executing instruction", inst); //$NON-NLS-1$
this.context = inst.process(this.env, this.context);
//code to check for end of document, set current doc
@@ -294,33 +290,6 @@
return null;
}
- private Properties getProperties() {
- Properties props = new Properties();
- if (XMLFormatConstants.XML_TREE_FORMAT.equals(this.env.getXMLFormat())) {
- props.setProperty("indent", "yes");//$NON-NLS-1$//$NON-NLS-2$
- }
- return props;
- }
-
- private XMLType postProcessDocument(XMLType xmlDoc, Properties props) throws MetaMatrixComponentException {
- Reader source = null;
-
- try {
- source = xmlDoc.getCharacterStream();
-
- // Validate against schema
- if(this.shouldValidate) {
- validateDoc(source);
- }
-
- // Apply XSLT
- xmlDoc = transformXML(xmlDoc, props);
- return xmlDoc;
- } catch (SQLException e) {
- throw new MetaMatrixComponentException(e);
- }
- }
-
/**
* Sets the XML schema
* @param xmlSchema
@@ -482,69 +451,6 @@
return nameSpaceMap;
}
- /**
- * <p> This method is used to transform the XML results obtained, by applying transformations
- * using any style sheets that are added to the <code>Query</code> object.
- * @param xmlResults The xml result string that is being transformed using stylesheets
- * @return The xml string transformed using style sheets.
- * @throws MetaMatrixComponentException if there is an error trying to perform transformation
- */
- private XMLType transformXML(XMLType xmlResults, Properties props) throws SQLException, MetaMatrixComponentException {
-
- // perform transformation only if a style sheet is specified
- if(styleSheet != null && styleSheet.trim().length() > 0) {
-
- // get a reader object for the style sheet
- Reader styleReader = new StringReader(styleSheet);
- // construct a Xlan source object for the syle sheet
- final Source styleSource = new StreamSource(styleReader);
-
- // get a reader object for the xml results
- //Reader xmlReader = new StringReader(xmlResults);
- // construct a Xlan source object for the xml results
- final Source xmlSource = new StreamSource(xmlResults.getCharacterStream());
-
- // Convert the output target for use in Xalan-J 2
- SQLXML result = XMLUtil.saveToBufferManager(bufferMgr, new XMLTranslator() {
-
- @Override
- public void translate(Writer writer) throws IOException {
- try {
- // get the Xalan-J 2 XSLT transformer
- TransformerFactory factory = new TransformerFactoryImpl();
- Transformer transformer = factory.newTransformer(styleSource);
-
- /*
- * To use this line, the system property "javax.xml.transform.TransformerFactory"
- * needs to be set to "com.icl.saxon.TransformerFactoryImpl" or desired
- * TransformerFactory classname. See com.metamatrix.jdbc.TestXMLQuery
- */
- //Transformer transformer = TransformerFactory.newInstance().newTransformer(styleSource);
-
- // Feed the resultant I/O stream into the XSLT processor
- transformer.transform(xmlSource, new StreamResult(writer));
- } catch(Exception e) {
- throw new IOException(QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0046), e);
- }
- }
- }, chunkSize);
-
- // obtain the stringified XML results for the
- xmlResults = new XMLType(result);
- }
-
- return xmlResults;
- }
-
- /**
- * <p> This method sets a style sheet to this object. The style sheet is
- * used to perform transformations on XML results
- * @param styleSheet A string representing a xslt styleSheet
- */
- public void setStylesheet(String styleSheet) {
- this.styleSheet = styleSheet;
- }
-
/**
* This method sets whether the documents should be returned in compact
* format (no extraneous whitespace). Non-compact format is more human-readable
@@ -556,14 +462,6 @@
}
/**
- * Set the validation mode on this plan. By default validation is off.
- * @param validate True to validate, false to not validate
- */
- public void setShouldValidate(boolean validate) {
- this.shouldValidate = validate;
- }
-
- /**
* Clean up the tuple source when the plan is closed.
* @see com.metamatrix.query.processor.ProcessorPlan#close()
*/
@@ -575,7 +473,7 @@
return "XMLPlan:\n" + ProgramUtil.programToString(this.originalProgram); //$NON-NLS-1$
} catch (Exception e){
e.printStackTrace();
- LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, e,
+ LogManager.logWarning(LogConstants.CTX_XML_PLAN, e,
QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0001));
}
return "XMLPlan"; //$NON-NLS-1$
@@ -645,6 +543,7 @@
*/
public XMLPlan clone(){
XMLPlan xmlPlan = new XMLPlan((XMLProcessorEnvironment)this.env.clone());
+ xmlPlan.xmlSchemas = this.xmlSchemas;
return xmlPlan;
}
@@ -671,14 +570,6 @@
return props;
}
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- return this.env.getChildPlans();
- }
-
public GroupSymbol getDocumentGroup() {
return env.getDocumentGroup();
}
Added: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPostProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPostProcessor.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPostProcessor.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -0,0 +1,205 @@
+/*
+ * 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.query.processor.xml;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.types.Streamable;
+import com.metamatrix.common.types.XMLTranslator;
+import com.metamatrix.common.types.XMLType;
+import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.util.CommandContext;
+import com.metamatrix.query.util.XMLFormatConstants;
+
+/**
+ * TODO: sometime later this functionality should be handled with system functions
+ */
+public class XMLPostProcessor extends ProcessorPlan {
+
+ // Post-processing
+ private String styleSheet;
+ private String xmlFormat;
+ private BufferManager bufferMgr;
+ private ProcessorPlan plan;
+
+ public XMLPostProcessor(ProcessorPlan plan) {
+ this.plan = plan;
+ }
+
+ XMLType postProcessDocument(XMLType xmlDoc) throws MetaMatrixComponentException {
+ try {
+ return transformXML(xmlDoc);
+ } catch (SQLException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ }
+
+ /**
+ * <p> This method is used to transform the XML results obtained, by applying transformations
+ * using any style sheets that are added to the <code>Query</code> object.
+ * @param xmlResults The xml result string that is being transformed using stylesheets
+ * @return The xml string transformed using style sheets.
+ * @throws MetaMatrixComponentException if there is an error trying to perform transformation
+ */
+ private XMLType transformXML(XMLType xmlResults) throws SQLException, MetaMatrixComponentException {
+ final Source styleSource;
+ if (styleSheet != null) {
+ Reader styleReader = new StringReader(styleSheet);
+ styleSource = new StreamSource(styleReader);
+ } else {
+ styleSource = null;
+ }
+
+ // get a reader object for the xml results
+ //Reader xmlReader = new StringReader(xmlResults);
+ // construct a Xlan source object for the xml results
+ Reader reader = xmlResults.getCharacterStream();
+ final Source xmlSource = new StreamSource(reader);
+ try {
+ // Convert the output target for use in Xalan-J 2
+ SQLXML result = XMLUtil.saveToBufferManager(bufferMgr, new XMLTranslator() {
+
+ @Override
+ public void translate(Writer writer) throws TransformerException {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = null;
+ if (styleSource == null) {
+ transformer = factory.newTransformer();
+ } else {
+ transformer = factory.newTransformer(styleSource);
+ }
+ if (XMLFormatConstants.XML_TREE_FORMAT.equals(xmlFormat)) {
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+ }
+ // Feed the resultant I/O stream into the XSLT processor
+ transformer.transform(xmlSource, new StreamResult(writer));
+ }
+ }, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
+ // obtain the stringified XML results for the
+ return new XMLType(result);
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ /**
+ * <p> This method sets a style sheet to this object. The style sheet is
+ * used to perform transformations on XML results
+ * @param styleSheet A string representing a xslt styleSheet
+ */
+ public void setStylesheet(String styleSheet) {
+ this.styleSheet = styleSheet;
+ }
+
+ /**
+ * This method sets whether the documents should be returned in compact
+ * format (no extraneous whitespace). Non-compact format is more human-readable
+ * (and bigger). Additional formats may be possible in future.
+ * @param xmlFormat A string giving the format in which xml results need to be returned
+ */
+ public void setXMLFormat(String xmlFormat) {
+ this.xmlFormat = xmlFormat;
+ }
+
+ @Override
+ public ProcessorPlan clone() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void close() throws MetaMatrixComponentException {
+ this.plan.close();
+ }
+
+ @Override
+ public List getOutputElements() {
+ return this.plan.getOutputElements();
+ }
+
+ @Override
+ public void initialize(CommandContext context,
+ ProcessorDataManager dataMgr, BufferManager bufferMgr) {
+ this.bufferMgr = bufferMgr;
+ }
+
+ @Override
+ public TupleBatch nextBatch() throws BlockedException,
+ MetaMatrixComponentException, MetaMatrixProcessingException {
+ TupleBatch batch = plan.nextBatch();
+ List<List<XMLType>> result = new ArrayList<List<XMLType>>(batch.getAllTuples().length);
+ for (List tuple : batch.getAllTuples()) {
+ result.add(Arrays.asList(postProcessDocument((XMLType)tuple.get(0))));
+ }
+ TupleBatch resultBatch = new TupleBatch(batch.getBeginRow(), result);
+ resultBatch.setTerminationFlag(batch.getTerminationFlag());
+ return resultBatch;
+ }
+
+ @Override
+ public void open() throws MetaMatrixComponentException,
+ MetaMatrixProcessingException {
+ this.plan.open();
+ }
+
+ @Override
+ public Map getDescriptionProperties() {
+ return this.plan.getDescriptionProperties();
+ }
+
+ @Override
+ public boolean requiresTransaction(boolean transactionalReads) {
+ return plan.requiresTransaction(transactionalReads);
+ }
+
+ @Override
+ public void reset() {
+ this.plan.reset();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPostProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -56,7 +56,6 @@
private DocumentInProgress documentInProgress;
private String xmlFormat;
- private String xmlResultsForm;
private GroupSymbol documentGroup;
@@ -138,8 +137,8 @@
while (this.programStack.size() > 1 &&
programState.programCounter >= programState.program.getProcessorInstructions().size()) {
this.programStack.removeFirst();
- if(LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, MessageLevel.TRACE)) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"Processor Environment popped program w/ recursion count " + programState.recursionCount, "; " + this.programStack.size(), " programs left."}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if(LogManager.isMessageToBeRecorded(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, MessageLevel.TRACE)) {
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"Processor Environment popped program w/ recursion count " + programState.recursionCount, "; " + this.programStack.size(), " programs left."}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
programState = (ProgramState)this.programStack.getFirst();
}
@@ -163,10 +162,10 @@
} else {
programState.recursionCount = ProgramState.NOT_RECURSIVE + 1;
}
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"Pushed recursive program w/ recursion count " + programState.recursionCount}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"Pushed recursive program w/ recursion count " + programState.recursionCount}); //$NON-NLS-1$
} else {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_XML_PLAN, new Object[]{"Pushed non-recursive program w/ recursion count " + programState.recursionCount}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"Pushed non-recursive program w/ recursion count " + programState.recursionCount}); //$NON-NLS-1$
}
this.programStack.addFirst(programState);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -28,6 +28,8 @@
import java.io.OutputStreamWriter;
import java.io.Writer;
+import javax.xml.transform.TransformerException;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.FileStore;
@@ -63,6 +65,8 @@
return createSQLXML(lobBuffer);
} catch(IOException e) {
throw new MetaMatrixComponentException(e);
+ } catch(TransformerException e) {
+ throw new MetaMatrixComponentException(e);
} finally {
if (!success && lobBuffer != null) {
lobBuffer.remove();
Copied: trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/SqlEval.java (from rev 1958, trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SqlEval.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/SqlEval.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/SqlEval.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -0,0 +1,209 @@
+/*
+ * 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.query.processor.xquery;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.api.exception.query.ExpressionEvaluationException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.TupleSource;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.XMLType;
+import com.metamatrix.query.eval.Evaluator;
+import com.metamatrix.query.processor.BatchIterator;
+import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.QueryProcessor;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import com.metamatrix.query.sql.symbol.Symbol;
+import com.metamatrix.query.util.CommandContext;
+import com.metamatrix.query.xquery.XQuerySQLEvaluator;
+
+
+/**
+ * A SQL evaluator used in XQuery expression, where this will take SQL string and return a
+ * XML 'Source' as output for the request evaluated.
+ */
+public class SqlEval implements XQuerySQLEvaluator {
+
+ private static final String NO_RESULTS_DOCUMENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><results/>"; //$NON-NLS-1$
+
+ private CommandContext context;
+ private ArrayList<QueryProcessor> processors;
+ private String parentGroup;
+ private Map<String, Expression> params;
+ private ProcessorDataManager dataManager;
+
+ public static Source createSource(TupleSource source)
+ throws MetaMatrixProcessingException {
+
+ try {
+ // we only want to return the very first document from the result set
+ // as XML we expect in doc function to have single XML document
+ List tuple = source.nextTuple();
+ if (tuple != null) {
+ Object value = tuple.get(0);
+ if (value != null) {
+ // below we will catch any invalid LOB refereces and return them
+ // as processing excceptions.
+ if (value instanceof XMLType) {
+ XMLType xml = (XMLType)value;
+ return xml.getSource(null);
+ }
+ return new StreamSource(new StringReader((String)value));
+ }
+ }
+ } catch (Exception e) {
+ throw new MetaMatrixProcessingException(e);
+ }
+ return new StreamSource(new StringReader(NO_RESULTS_DOCUMENT));
+ }
+
+ public static SAXSource createSource(String[] columns, Class[] types, TupleSource source) throws MetaMatrixProcessingException, MetaMatrixComponentException {
+
+ try {
+ // get the sax parser and the its XML reader and replace with
+ // our own. and then supply the customized input source.
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setNamespaceAware(true);
+ SAXParser sp = spf.newSAXParser();
+ XMLReader reader = sp.getXMLReader();
+
+ return new SAXSource(new TupleXMLReader(reader), new TupleInputSource(columns, types, source));
+
+ } catch (ParserConfigurationException e) {
+ throw new MetaMatrixComponentException(e);
+ } catch (SAXException e) {
+ throw new MetaMatrixProcessingException(e);
+ }
+ }
+
+ public SqlEval(ProcessorDataManager dataManager, CommandContext context, String parentGroup, Map<String, Expression> params) {
+ this.dataManager = dataManager;
+ this.context = context;
+ this.parentGroup = parentGroup;
+ this.params = params;
+ }
+
+ /**
+ * @see com.metamatrix.query.xquery.XQuerySQLEvaluator#executeDynamicSQL(java.lang.String)
+ * @since 4.3
+ */
+ public Source executeSQL(String sql)
+ throws QueryParserException, MetaMatrixProcessingException, MetaMatrixComponentException {
+
+ QueryProcessor processor = context.getQueryProcessorFactory().createQueryProcessor(sql, parentGroup, context);
+ processor.setNonBlocking(true);
+ if (processors == null) {
+ processors = new ArrayList<QueryProcessor>();
+ }
+ processors.add(processor);
+ TupleSource src = new BatchIterator(processor);
+
+ String[] columns = elementNames(src.getSchema());
+ Class[] types= elementTypes(src.getSchema());
+ boolean xml = false;
+
+ // check to see if we have XML results
+ if (src.getSchema().size() > 0) {
+ xml = src.getSchema().get(0).getType().equals(DataTypeManager.DefaultDataClasses.XML);
+ }
+
+ if (xml) {
+ return createSource(src);
+ }
+ return createSource(columns, types, src);
+ }
+
+ @Override
+ public Object getParameterValue(String key) throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ String paramName = this.parentGroup + ElementSymbol.SEPARATOR + key;
+ paramName = paramName.toUpperCase();
+ Expression expr = this.params.get(paramName);
+ return new Evaluator(Collections.emptyMap(), this.dataManager, context).evaluate(expr, Collections.emptyList());
+ }
+
+ /**
+ * Get the Column names from Element Objects
+ * @param elements
+ * @return Names of all the columns in the set.
+ */
+ String[] elementNames(List elements) {
+ String[] columns = new String[elements.size()];
+
+ for(int i = 0; i < elements.size(); i++) {
+ SingleElementSymbol element = (SingleElementSymbol)elements.get(i);
+ String name = ((Symbol)(element)).getName();
+ int index = name.lastIndexOf('.');
+ if (index != -1) {
+ name = name.substring(index+1);
+ }
+ columns[i] = name;
+ }
+ return columns;
+ }
+
+ /**
+ * Get types of the all the elements
+ * @param elements
+ * @return class[] of element types
+ */
+ Class[] elementTypes(List elements) {
+ Class[] types = new Class[elements.size()];
+
+ for(int i = 0; i < elements.size(); i++) {
+ SingleElementSymbol element = (SingleElementSymbol)elements.get(i);
+ types[i] = element.getType();
+ }
+ return types;
+ }
+
+ /**
+ * Closes any resources opened during the evaluation
+ */
+ public void close() throws MetaMatrixComponentException {
+ if (processors != null) {
+ for (QueryProcessor processor : processors) {
+ processor.closeProcessing();
+ }
+ }
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleInputSource.java (from rev 1958, trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/TupleInputSource.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleInputSource.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleInputSource.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -0,0 +1,105 @@
+/*
+ * 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.query.processor.xquery;
+
+import java.util.List;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.buffer.TupleSource;
+import com.metamatrix.common.types.DataTypeManager;
+
+
+/**
+ * A extend class which defines the "InputSource" interface on a
+ * MetaMatrix's TupleSource. This will be used as in SaxSource's
+ * input source object to represent the tuple as sax stream.
+ */
+public class TupleInputSource extends InputSource {
+ static final String nsURI = ""; //$NON-NLS-1$
+ static final AttributesImpl atts = new AttributesImpl();
+ private static final String ROW = "row"; //$NON-NLS-1$
+ private static final String RESULTS = "results"; //$NON-NLS-1$
+ private static final String NULL = "null";//$NON-NLS-1$
+
+ String[] columns;
+ TupleSource source;
+ Class[] types;
+
+ public TupleInputSource(String[] columns, Class[] types, TupleSource source) {
+ this.columns = columns;
+ this.source = source;
+ this.types = types;
+ }
+
+ /**
+ * This will be called by the extended XMLReader to parse the
+ * Tuple source.
+ * @param saxHandler
+ */
+ public void parse(ContentHandler saxHandler) throws SAXException{
+ saxHandler.startDocument();
+ saxHandler.startElement(nsURI, RESULTS, RESULTS, atts);
+
+ try {
+ List tuple = this.source.nextTuple();
+ while (tuple != null) {
+ saxHandler.startElement(nsURI, ROW, ROW, atts);
+
+ // write each column of the row
+ for(int i = 0; i < this.columns.length; i++) {
+ String element = this.columns[i];
+
+ saxHandler.startElement(nsURI, element, element, atts);
+ Object obj = tuple.get(i);
+ String value = NULL;
+ if (obj != null
+ && types[i] != DataTypeManager.getDataTypeClass(DataTypeManager.DefaultDataTypes.CLOB)
+ && types[i] != DataTypeManager.getDataTypeClass(DataTypeManager.DefaultDataTypes.BLOB)) {
+ value = obj.toString();
+ }
+ saxHandler.characters (value.toCharArray(), 0, value.length());
+ saxHandler.endElement(nsURI, element, element);
+ }
+ saxHandler.endElement(nsURI, ROW, ROW);
+
+ // get the next tuple
+ tuple = this.source.nextTuple();
+ }
+ saxHandler.endElement(nsURI, RESULTS, RESULTS);
+ saxHandler.endDocument();
+ this.source.closeSource();
+ } catch (MetaMatrixComponentException e) {
+ throw new SAXException(e);
+ } catch (MetaMatrixProcessingException e) {
+ throw new SAXException(e);
+ }
+ }
+}
+
+
Copied: trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleXMLReader.java (from rev 1958, trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/TupleXMLReader.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleXMLReader.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleXMLReader.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -0,0 +1,151 @@
+/*
+ * 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.query.processor.xquery;
+
+import java.io.IOException;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.XMLReader;
+
+
+/**
+ * This is a replacement XMl Reader for the SAX Source; so that we can
+ * customize this to read a tuple soruce and generate the SAX Events.
+ * The parse method is overloaded with our specific implementation.
+ *
+ * Also, note that this is decorator for the actual XML Reader of the
+ * parser.
+ */
+public class TupleXMLReader implements XMLReader {
+
+ XMLReader reader;
+ public TupleXMLReader(XMLReader reader) {
+ this.reader = reader;
+ }
+
+ /**
+ * @see org.xml.sax.XMLReader#getContentHandler()
+ */
+ public ContentHandler getContentHandler() {
+ return this.reader.getContentHandler();
+ }
+
+ /**
+ * @see org.xml.sax.XMLReader#getDTDHandler()
+ */
+ public DTDHandler getDTDHandler() {
+ return this.reader.getDTDHandler();
+ }
+ /**
+ * @see org.xml.sax.XMLReader#getEntityResolver()
+ */
+ public EntityResolver getEntityResolver() {
+ return this.reader.getEntityResolver();
+ }
+ /**
+ * @see org.xml.sax.XMLReader#getErrorHandler()
+ */
+ public ErrorHandler getErrorHandler() {
+ return this.reader.getErrorHandler();
+ }
+ /**
+ * @see org.xml.sax.XMLReader#getFeature(java.lang.String)
+ */
+ public boolean getFeature(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
+ return this.reader.getFeature(name);
+ }
+ /**
+ * @see org.xml.sax.XMLReader#getProperty(java.lang.String)
+ */
+ public Object getProperty(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
+ return this.reader.getProperty(name);
+ }
+
+ /**
+ * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
+ */
+ public void parse(InputSource input)
+ throws IOException, SAXException {
+ if (input instanceof TupleInputSource) {
+ TupleInputSource in = (TupleInputSource)input;
+ in.parse(getContentHandler());
+ }
+ else {
+ this.reader.parse(input);
+ }
+ }
+ /**
+ * @see org.xml.sax.XMLReader#parse(java.lang.String)
+ */
+ public void parse(String systemId)
+ throws IOException, SAXException {
+ this.reader.parse(systemId);
+ }
+ /**
+ * @see org.xml.sax.XMLReader#setContentHandler(org.xml.sax.ContentHandler)
+ */
+ public void setContentHandler(ContentHandler handler) {
+ this.reader.setContentHandler(handler);
+ }
+ /**
+ * @see org.xml.sax.XMLReader#setDTDHandler(org.xml.sax.DTDHandler)
+ */
+ public void setDTDHandler(DTDHandler handler) {
+ this.reader.setDTDHandler(handler);
+ }
+ /**
+ * @see org.xml.sax.XMLReader#setEntityResolver(org.xml.sax.EntityResolver)
+ */
+ public void setEntityResolver(EntityResolver resolver) {
+ this.reader.setEntityResolver(resolver);
+ }
+ /**
+ * @see org.xml.sax.XMLReader#setErrorHandler(org.xml.sax.ErrorHandler)
+ */
+ public void setErrorHandler(ErrorHandler handler) {
+ this.reader.setErrorHandler(handler);
+ }
+ /**
+ * @see org.xml.sax.XMLReader#setFeature(java.lang.String, boolean)
+ */
+ public void setFeature(String name, boolean value)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
+ this.reader.setFeature(name, value);
+ }
+ /**
+ * @see org.xml.sax.XMLReader#setProperty(java.lang.String, java.lang.Object)
+ */
+ public void setProperty(String name, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
+ this.reader.setProperty(name, value);
+ }
+}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -24,8 +24,6 @@
import java.sql.SQLXML;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -43,7 +41,6 @@
import com.metamatrix.query.processor.DescribableUtil;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.dynamic.SqlEval;
import com.metamatrix.query.processor.xml.XMLUtil;
import com.metamatrix.query.sql.lang.XQuery;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -185,15 +182,6 @@
return "XQueryPlan: " + this.xQuery.toString(); //$NON-NLS-1$
}
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- //return xmlPlans.values();
- return Collections.EMPTY_LIST;
- }
-
/**
* This method sets whether the documents should be returned in compact
* format (no extraneous whitespace). Non-compact format is more human-readable
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -131,7 +131,7 @@
AnalysisRecord analysis, boolean resolveNullLiterals)
throws QueryResolverException, MetaMatrixComponentException {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving command", currentCommand}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving command", currentCommand}); //$NON-NLS-1$
TempMetadataAdapter resolverMetadata = null;
try {
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -170,7 +170,7 @@
private void resolveBlock(CreateUpdateProcedureCommand command, Block block, GroupContext externalGroups,
TempMetadataAdapter metadata, boolean isUpdateProcedure, AnalysisRecord analysis)
throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving block", block}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving block", block}); //$NON-NLS-1$
//create a new variable and metadata context for this block so that discovered metadata is not visible else where
TempMetadataStore store = new TempMetadataStore(new HashMap(metadata.getMetadataStore().getData()));
@@ -188,7 +188,7 @@
private void resolveStatement(CreateUpdateProcedureCommand command, Statement statement, GroupContext externalGroups, GroupSymbol variables, TempMetadataAdapter metadata, boolean isUpdateProcedure, AnalysisRecord analysis)
throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving statement", statement}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving statement", statement}); //$NON-NLS-1$
switch(statement.getType()) {
case Statement.TYPE_IF:
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BatchedUpdateCommand.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BatchedUpdateCommand.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BatchedUpdateCommand.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -115,54 +115,6 @@
return Command.getUpdateCommandSymbol();
}
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException{
- //if all the updates are against the same physical source,
- //the txn is handled in the connector using the transaction
- //from the source, and 0 will be returned
-
- int sunCommandUpdatingModelCount = 0;
- if(commands != null && !commands.isEmpty()) {
- Object sourceModel = null;
- //if all the updates are against the same physical source,
- //the txn is handled in the connector using the transaction
- //from the source, and 0 will be returned
- Iterator iter = commands.iterator();
- while(iter.hasNext()) {
- Command command = (Command)iter.next();
- GroupSymbol group = null;
- if(command.getType() == Command.TYPE_INSERT) {
- group = ((Insert)command).getGroup();
- }else if(command.getType() == Command.TYPE_UPDATE) {
- group = ((Update)command).getGroup();
- }else if(command.getType() == Command.TYPE_DELETE) {
- group = ((Delete)command).getGroup();
- }else {
- sunCommandUpdatingModelCount += command.updatingModelCount(metadata);
- }
-
- if(group != null) {
- try {
- if(sourceModel == null) {
- sourceModel = metadata.getModelID(group.getMetadataID());
- sunCommandUpdatingModelCount += 1;
- continue;
- }
- if(!sourceModel.equals(metadata.getModelID(group.getMetadataID()))) {
- return 2;
- }
- }catch(QueryMetadataException qme) {
- throw new MetaMatrixComponentException(qme);
- }
- }
-
- if(sunCommandUpdatingModelCount > 1) {
- break;
- }
- }
- }
- return sunCommandUpdatingModelCount;
- }
-
/**
* @since 4.2
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -31,9 +31,7 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -319,24 +317,6 @@
return updateCommandSymbol;
}
- /**
- * Return the number of updates on physical sources by this command.
- * @param metadata QueryMetadataInterface
- * @return The number of updates on physical sources by this command.
- * @since 4.3
- */
- public abstract int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException;
-
- protected int getSubCommandsUpdatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException{
- List<Command> subCommands = CommandCollectorVisitor.getCommands(this);
- for (Command command : subCommands) {
- if (command.updatingModelCount(metadata) > 0) {
- return 2; //require a transaction if there is more than 1 statement
- }
- }
- return 0;
- }
-
public ProcessorPlan getProcessorPlan() {
return this.plan;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Create.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Create.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Create.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -92,14 +92,6 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#updatingModelCount(com.metamatrix.query.metadata.QueryMetadataInterface)
- * @since 5.5
- */
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException {
- return 0;
- }
-
- /**
* @see com.metamatrix.query.sql.LanguageObject#acceptVisitor(com.metamatrix.query.sql.LanguageVisitor)
* @since 5.5
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Drop.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Drop.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Drop.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -85,14 +85,6 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#updatingModelCount(com.metamatrix.query.metadata.QueryMetadataInterface)
- * @since 5.5
- */
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException {
- return 0;
- }
-
- /**
* @see com.metamatrix.query.sql.LanguageObject#acceptVisitor(com.metamatrix.query.sql.LanguageVisitor)
* @since 5.5
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DynamicCommand.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DynamicCommand.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DynamicCommand.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -27,10 +27,8 @@
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
@@ -140,13 +138,6 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#updatingModelCount(com.metamatrix.query.metadata.QueryMetadataInterface)
- */
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException {
- return updatingModelCount;
- }
-
- /**
* @see com.metamatrix.query.sql.LanguageObject#acceptVisitor(com.metamatrix.query.sql.LanguageVisitor)
*/
public void acceptVisitor(LanguageVisitor visitor) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ProcedureContainer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ProcedureContainer.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ProcedureContainer.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -24,9 +24,6 @@
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.symbol.GroupSymbol;
public abstract class ProcedureContainer extends Command {
@@ -35,32 +32,11 @@
public abstract GroupSymbol getGroup();
- protected void copyMetadataState(Command copy) {
+ protected void copyMetadataState(ProcedureContainer copy) {
super.copyMetadataState(copy);
+ copy.updateCount = updateCount;
}
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException{
- if (updateCount != -1) {
- return updateCount;
- }
-
- if(this.getGroup().isTempGroupSymbol()) {
- //TODO: this is not correct. once temp tables are transactional, this will need to return a better value
- return 0;
- }
-
- try {
- if (!metadata.isVirtualGroup(this.getGroup().getMetadataID())) {
- return 1; //physical stored procedures are assumed to perform an update
- }
- } catch (QueryMetadataException e) {
- throw new MetaMatrixComponentException(e);
- }
-
- return 2;
- }
-
-
/**
* @return Returns the updateCount.
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -27,11 +27,9 @@
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.SelectSymbol;
@@ -442,18 +440,6 @@
return true;
}
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException{
- if(isXML) { //TODO: this is incorrect
- return 0;
- }
-
- if(into != null && !into.getGroup().isTempGroupSymbol()) {
- return 2;
- }
-
- return getSubCommandsUpdatingModelCount(metadata);
- }
-
/**
* @see com.metamatrix.query.sql.lang.QueryCommand#getProjectedQuery()
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -27,7 +27,6 @@
import java.util.Collections;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -239,10 +238,6 @@
return leftQuery.areResultsCachable() && rightQuery.areResultsCachable();
}
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException {
- return getSubCommandsUpdatingModelCount(metadata);
- }
-
/**
* @return the left and right queries as a list. This list cannot be modified.
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/XQuery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/XQuery.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/XQuery.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -26,10 +26,8 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.visitor.SQLStringVisitor;
@@ -150,10 +148,6 @@
return true;
}
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException {
- return 2; //since there may be dynamic sql, just assume a transaction is required
- }
-
public String getProcedureGroup() {
return procedureGroup;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -28,13 +28,10 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Option;
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.visitor.SQLStringVisitor;
@@ -284,29 +281,6 @@
return true;
}
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException {
- List<Command> subCommands = getSubCommands();
- if (subCommands.isEmpty()) {
- return 0;
- }
- Command lastCommand = null;
- Statement statement = block.getStatements().get(block.getStatements().size() - 1);
- if (statement instanceof CommandStatement) {
- CommandStatement cmdStatement = (CommandStatement)statement;
- lastCommand = cmdStatement.getCommand();
- }
- for (Command command : subCommands) {
- int count = command.updatingModelCount(metadata);
- if (command == lastCommand) {
- return count;
- }
- if (count > 0) {
- return 2;
- }
- }
- return 0;
- }
-
public GroupSymbol getVirtualGroup() {
return this.virtualGroup;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -23,10 +23,10 @@
package com.metamatrix.query.util;
import java.io.Serializable;
+import java.util.LinkedList;
import java.util.Properties;
import java.util.Random;
import java.util.Set;
-import java.util.Stack;
import java.util.TimeZone;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -99,13 +99,15 @@
private long timeoutEnd = Long.MAX_VALUE;
private QueryMetadataInterface metadata;
+
+ private boolean validateXML;
}
private GlobalState globalState = new GlobalState();
private VariableContext variableContext = new VariableContext();
private Object tempTableStore;
- private Stack<String> recursionStack;
+ private LinkedList<String> recursionStack;
/**
* Construct a new context.
@@ -173,7 +175,7 @@
clone.globalState = this.globalState;
clone.variableContext = this.variableContext;
if (this.recursionStack != null) {
- clone.recursionStack = (Stack<String>)this.recursionStack.clone();
+ clone.recursionStack = new LinkedList<String>(this.recursionStack);
}
return clone;
}
@@ -318,7 +320,7 @@
public void pushCall(String value) throws QueryProcessingException {
if (recursionStack == null) {
- recursionStack = new Stack<String>();
+ recursionStack = new LinkedList<String>();
} else if (recursionStack.contains(value)) {
throw new QueryProcessingException(QueryExecPlugin.Util.getString("ExecDynamicSqlInstruction.3", value)); //$NON-NLS-1$
}
@@ -436,4 +438,13 @@
public QueryMetadataInterface getMetadata() {
return globalState.metadata;
}
+
+ public void setValidateXML(boolean validateXML) {
+ globalState.validateXML = validateXML;
+ }
+
+ public boolean validateXML() {
+ return globalState.validateXML;
+ }
+
}
Copied: trunk/engine/src/main/java/com/metamatrix/query/util/Permutation.java (from rev 1958, trunk/engine/src/main/java/com/metamatrix/common/util/Permutation.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/Permutation.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/Permutation.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -0,0 +1,172 @@
+/*
+ * 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.query.util;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import com.metamatrix.core.util.ArgCheck;
+
+public class Permutation {
+
+ private Object[] items;
+
+ public Permutation(Object[] items) {
+ ArgCheck.isNotNull(items);
+ this.items = items;
+ }
+
+ /**
+ * Create list of arrays of items, in all possible permutations (that's n! permutations).
+ * @return Iterator where each thing returned by the iterator is a permutation Object[]
+ */
+ public Iterator<Object[]> generate() {
+ return new PermutationIterator(this.items, this.items.length);
+ }
+
+ /**
+ * Create list of arrays of items, in all possible permutations (that's n! permutations).
+ * @return Iterator where each thing returned by the iterator is a permutation Object[] of
+ * length size
+ */
+ public Iterator<Object[]> generate(int size) {
+ if(size > items.length) {
+ throw new IllegalArgumentException("Size is larger than length"); //$NON-NLS-1$
+ } else if(size < 0) {
+ throw new IllegalArgumentException("Size is negative"); //$NON-NLS-1$
+ }
+
+ return new PermutationIterator(this.items, size);
+ }
+
+ private static class PermutationIterator implements Iterator<Object[]> {
+ // Given state
+ private Object[] items;
+ private int k;
+
+ // Derived state
+ private int n;
+ private int[] j;
+ private boolean more = true;
+ private int[] last;
+
+ private PermutationIterator(Object[] items, int k) {
+ this.items = items;
+ this.k = k;
+ this.n = items.length;
+
+ if(n == 0 || k == 0) {
+ more = false;
+ } else {
+ // Initialize
+ j = new int[n];
+ j[0] = -1;
+
+ // terminator
+ last = new int[n];
+ for(int i=n-1; i>=0; i--) {
+ last[n-1-i] = i;
+ }
+ }
+ }
+
+ public boolean hasNext() {
+ return more;
+ }
+
+ public Object[] next() {
+ if(! more) {
+ throw new NoSuchElementException();
+ }
+
+ if(j[0] < 0) {
+ for(int i=0; i<n; i++) {
+ j[i] = i;
+ }
+ int start = k;
+ int end = n-1;
+ while(start<end) {
+ int t = j[start];
+ j[start++] = j[end];
+ j[end--] = t;
+ }
+ } else {
+ int i;
+ for(i=n-2; i >= 0 && j[i] >= j[i+1]; --i) {}
+
+ if(i >= 0) {
+ int least = i+1;
+ for(int m=i+2; m<n; ++m) {
+ if(j[m] < j[least] && j[m] > j[i]) {
+ least = m;
+ }
+ }
+ int t = j[i];
+ j[i] = j[least];
+ j[least] = t;
+ if(k-1 > i) {
+ int start = i+1;
+ int end = n-1;
+ while(start < end) {
+ t = j[start];
+ j[start++] = j[end];
+ j[end--] = t;
+ }
+ start = k;
+ end = n-1;
+ while(start < end) {
+ t = j[start];
+ j[start++] = j[end];
+ j[end--] = t;
+ }
+ }
+ }
+ }
+
+ // Check for end
+ more = false;
+ for(int x=0; x<n; x++) {
+ if(j[x] != last[x]) {
+ more = true;
+ }
+ }
+
+ return getPermutation(j);
+ }
+
+ private Object[] getPermutation(int[] index) {
+ Object[] perm = new Object[k];
+ for(int i=0; i<k; i++) {
+ perm[i] = items[index[i]];
+ }
+ return perm;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+}
+
Modified: trunk/engine/src/main/java/com/metamatrix/query/xquery/saxon/SaxonXQueryExpression.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/xquery/saxon/SaxonXQueryExpression.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/com/metamatrix/query/xquery/saxon/SaxonXQueryExpression.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,7 +22,6 @@
package com.metamatrix.query.xquery.saxon;
-import java.io.IOException;
import java.io.Writer;
import java.sql.SQLException;
import java.sql.SQLXML;
@@ -184,12 +183,8 @@
return new XMLTranslator() {
@Override
- public void translate(Writer writer) throws IOException {
- try {
- QueryResult.serialize(nodeInfo, new StreamResult(writer), props, new Configuration());
- } catch (TransformerException e) {
- throw new IOException(e);
- }
+ public void translate(Writer writer) throws TransformerException {
+ QueryResult.serialize(nodeInfo, new StreamResult(writer), props, new Configuration());
}
};
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -27,6 +27,7 @@
import com.metamatrix.cache.CacheConfiguration;
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.CacheConfiguration.Policy;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
public class DQPContextCache implements Serializable{
@@ -54,7 +55,7 @@
try {
this.cache.removeChild(this.processIdentifier);
} catch(IllegalStateException e) {
- LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, e, e.getMessage());
+ LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
}
}
@@ -74,7 +75,7 @@
}
}
} catch(IllegalStateException e) {
- LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, e, e.getMessage());
+ LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
}
}
@@ -94,7 +95,7 @@
}
}
} catch(IllegalStateException e) {
- LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, e, e.getMessage());
+ LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
}
}
@@ -110,7 +111,7 @@
scopeNode.removeChild(session);
}
} catch(IllegalStateException e) {
- LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, e, e.getMessage());
+ LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
}
}
@@ -128,7 +129,7 @@
scopeNode.removeChild(id.toUpperCase());
}
} catch(IllegalStateException e) {
- LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, e, e.getMessage());
+ LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
}
}
}
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -1,115 +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.dqp.internal.datamgr;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorCapabilities;
-
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-
-/**
- * Utility to convert a ConnectorCapabilities class into a Map of
- * capabilities information that can be passed through the system.
- */
-public class CapabilitiesConverter {
-
- private CapabilitiesConverter() {
- }
-
- public static SourceCapabilities convertCapabilities(ConnectorCapabilities srcCaps) {
- return convertCapabilities(srcCaps, null, false);
- }
-
- public static BasicSourceCapabilities convertCapabilities(ConnectorCapabilities srcCaps, String connectorID, boolean isXa) {
- BasicSourceCapabilities tgtCaps = new BasicSourceCapabilities();
-
- tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, srcCaps.supportsSelectExpression());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, srcCaps.supportsSelectDistinct());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, srcCaps.supportsAliasedGroup());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, srcCaps.supportsInnerJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, srcCaps.supportsSelfJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, srcCaps.supportsOuterJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, srcCaps.supportsFullOuterJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, srcCaps.supportsInlineViews());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, srcCaps.supportsCompareCriteriaEquals());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, srcCaps.supportsCompareCriteriaOrdered());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE, srcCaps.supportsLikeCriteria());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, srcCaps.supportsLikeCriteriaEscapeCharacter());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN, srcCaps.supportsInCriteria());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, srcCaps.supportsInCriteriaSubquery());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_ISNULL, srcCaps.supportsIsNullCriteria());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_OR, srcCaps.supportsOrCriteria());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_NOT, srcCaps.supportsNotCriteria());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_EXISTS, srcCaps.supportsExistsCriteria());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, srcCaps.supportsQuantifiedCompareCriteriaSome());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, srcCaps.supportsQuantifiedCompareCriteriaAll());
- tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY, srcCaps.supportsOrderBy());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, srcCaps.supportsAggregatesSum());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, srcCaps.supportsAggregatesAvg());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, srcCaps.supportsAggregatesMin());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, srcCaps.supportsAggregatesMax());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, srcCaps.supportsAggregatesCount());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, srcCaps.supportsAggregatesCountStar());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, srcCaps.supportsAggregatesDistinct());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, srcCaps.supportsScalarSubqueries());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, srcCaps.supportsCorrelatedSubqueries());
- tgtCaps.setCapabilitySupport(Capability.QUERY_CASE, srcCaps.supportsCaseExpressions());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, srcCaps.supportsSearchedCaseExpressions());
- tgtCaps.setCapabilitySupport(Capability.QUERY_UNION, srcCaps.supportsUnions());
- tgtCaps.setCapabilitySupport(Capability.QUERY_INTERSECT, srcCaps.supportsIntersect());
- tgtCaps.setCapabilitySupport(Capability.QUERY_EXCEPT, srcCaps.supportsExcept());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, srcCaps.supportsSetQueryOrderBy());
- tgtCaps.setCapabilitySupport(Capability.BULK_UPDATE , srcCaps.supportsBulkUpdate());
- tgtCaps.setCapabilitySupport(Capability.BATCHED_UPDATES, srcCaps.supportsBatchedUpdates());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, srcCaps.supportsFunctionsInGroupBy());
- tgtCaps.setCapabilitySupport(Capability.ROW_LIMIT, srcCaps.supportsRowLimit());
- tgtCaps.setCapabilitySupport(Capability.ROW_OFFSET, srcCaps.supportsRowOffset());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, srcCaps.useAnsiJoin());
- tgtCaps.setCapabilitySupport(Capability.REQUIRES_CRITERIA, srcCaps.requiresCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_GROUP_BY, srcCaps.supportsGroupBy());
- tgtCaps.setCapabilitySupport(Capability.QUERY_HAVING, srcCaps.supportsHaving());
- tgtCaps.setCapabilitySupport(Capability.INSERT_WITH_QUERYEXPRESSION, srcCaps.supportsInsertWithQueryExpression());
- tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY_UNRELATED, srcCaps.supportsOrderByUnrelated());
-
- List functions = srcCaps.getSupportedFunctions();
- if(functions != null && functions.size() > 0) {
- Iterator iter = functions.iterator();
- while(iter.hasNext()) {
- String func = (String) iter.next();
- tgtCaps.setFunctionSupport(func.toLowerCase(), true);
- }
- }
-
- tgtCaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(srcCaps.getMaxInCriteriaSize()));
- tgtCaps.setSourceProperty(Capability.CONNECTOR_ID, connectorID);
- tgtCaps.setSourceProperty(Capability.MAX_QUERY_FROM_GROUPS, new Integer(srcCaps.getMaxFromGroups()));
- tgtCaps.setSourceProperty(Capability.TRANSACTIONS_XA, isXa);
- tgtCaps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, srcCaps.getSupportedJoinCriteria());
- return tgtCaps;
- }
-
-}
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java (from rev 1958, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -0,0 +1,114 @@
+/*
+ * 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.dqp.internal.datamgr.impl;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.connector.api.ConnectorCapabilities;
+
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
+
+/**
+ * Utility to convert a ConnectorCapabilities class into a Map of
+ * capabilities information that can be passed through the system.
+ */
+public class CapabilitiesConverter {
+
+ private CapabilitiesConverter() {
+ }
+
+ public static SourceCapabilities convertCapabilities(ConnectorCapabilities srcCaps) {
+ return convertCapabilities(srcCaps, null, false);
+ }
+
+ public static BasicSourceCapabilities convertCapabilities(ConnectorCapabilities srcCaps, String connectorID, boolean isXa) {
+ BasicSourceCapabilities tgtCaps = new BasicSourceCapabilities();
+
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, srcCaps.supportsSelectExpression());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, srcCaps.supportsSelectDistinct());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, srcCaps.supportsAliasedGroup());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, srcCaps.supportsInnerJoins());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, srcCaps.supportsSelfJoins());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, srcCaps.supportsOuterJoins());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, srcCaps.supportsFullOuterJoins());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, srcCaps.supportsInlineViews());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, srcCaps.supportsCompareCriteriaEquals());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, srcCaps.supportsCompareCriteriaOrdered());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE, srcCaps.supportsLikeCriteria());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, srcCaps.supportsLikeCriteriaEscapeCharacter());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN, srcCaps.supportsInCriteria());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, srcCaps.supportsInCriteriaSubquery());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_ISNULL, srcCaps.supportsIsNullCriteria());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_OR, srcCaps.supportsOrCriteria());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_NOT, srcCaps.supportsNotCriteria());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_EXISTS, srcCaps.supportsExistsCriteria());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, srcCaps.supportsQuantifiedCompareCriteriaSome());
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, srcCaps.supportsQuantifiedCompareCriteriaAll());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY, srcCaps.supportsOrderBy());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, srcCaps.supportsAggregatesSum());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, srcCaps.supportsAggregatesAvg());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, srcCaps.supportsAggregatesMin());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, srcCaps.supportsAggregatesMax());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, srcCaps.supportsAggregatesCount());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, srcCaps.supportsAggregatesCountStar());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, srcCaps.supportsAggregatesDistinct());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, srcCaps.supportsScalarSubqueries());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, srcCaps.supportsCorrelatedSubqueries());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_CASE, srcCaps.supportsCaseExpressions());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, srcCaps.supportsSearchedCaseExpressions());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_UNION, srcCaps.supportsUnions());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_INTERSECT, srcCaps.supportsIntersect());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_EXCEPT, srcCaps.supportsExcept());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, srcCaps.supportsSetQueryOrderBy());
+ tgtCaps.setCapabilitySupport(Capability.BULK_UPDATE , srcCaps.supportsBulkUpdate());
+ tgtCaps.setCapabilitySupport(Capability.BATCHED_UPDATES, srcCaps.supportsBatchedUpdates());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, srcCaps.supportsFunctionsInGroupBy());
+ tgtCaps.setCapabilitySupport(Capability.ROW_LIMIT, srcCaps.supportsRowLimit());
+ tgtCaps.setCapabilitySupport(Capability.ROW_OFFSET, srcCaps.supportsRowOffset());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, srcCaps.useAnsiJoin());
+ tgtCaps.setCapabilitySupport(Capability.REQUIRES_CRITERIA, srcCaps.requiresCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_GROUP_BY, srcCaps.supportsGroupBy());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_HAVING, srcCaps.supportsHaving());
+ tgtCaps.setCapabilitySupport(Capability.INSERT_WITH_QUERYEXPRESSION, srcCaps.supportsInsertWithQueryExpression());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY_UNRELATED, srcCaps.supportsOrderByUnrelated());
+
+ List functions = srcCaps.getSupportedFunctions();
+ if(functions != null && functions.size() > 0) {
+ Iterator iter = functions.iterator();
+ while(iter.hasNext()) {
+ String func = (String) iter.next();
+ tgtCaps.setFunctionSupport(func.toLowerCase(), true);
+ }
+ }
+
+ tgtCaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(srcCaps.getMaxInCriteriaSize()));
+ tgtCaps.setSourceProperty(Capability.CONNECTOR_ID, connectorID);
+ tgtCaps.setSourceProperty(Capability.MAX_QUERY_FROM_GROUPS, new Integer(srcCaps.getMaxFromGroups()));
+ tgtCaps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, srcCaps.getSupportedJoinCriteria());
+ return tgtCaps;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -36,9 +36,6 @@
import org.jboss.managed.api.annotation.ManagementComponent;
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.Connector;
import org.teiid.connector.api.ConnectorCapabilities;
@@ -49,14 +46,12 @@
import org.teiid.connector.metadata.runtime.MetadataFactory;
import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.dqp.internal.cache.DQPContextCache;
-import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
-import org.teiid.dqp.internal.process.StatsCapturingWorkManager;
import org.teiid.logging.api.CommandLogMessage;
import org.teiid.logging.api.CommandLogMessage.Event;
import org.teiid.security.SecurityHelper;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
@@ -255,7 +250,7 @@
String userName = qr.getWorkContext().getUserName();
String transactionID = null;
if ( qr.isTransactional() ) {
- transactionID = qr.getTransactionContext().getXid().toString();
+ transactionID = qr.getTransactionContext().getTransactionId();
}
String modelName = qr.getModelName();
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -44,13 +44,12 @@
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import org.teiid.logging.api.CommandLogMessage.Event;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.TupleBuffer;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.message.AtomicRequestID;
@@ -110,20 +109,12 @@
this.connector = manager.getConnector();
this.connectorEnv = connector.getConnectorEnvironment();
- try {
- VDBMetaData vdb = requestMsg.getWorkContext().getVDB();
- this.queryMetadata = vdb.getAttachment(QueryMetadataInterface.class);
- this.queryMetadata = new TempMetadataAdapter(this.queryMetadata, new TempMetadataStore());
-
- if (requestMsg.isTransactional()){
- if (this.connectorEnv.isXaCapable()) {
- this.securityContext.setTransactional(true);
- } else if (!this.connectorEnv.isImmutable() && requestMsg.getCommand().updatingModelCount(queryMetadata) > 0) {
- throw new ConnectorException(DQPPlugin.Util.getString("ConnectorWorker.transactionNotSupported")); //$NON-NLS-1$
- }
- }
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
+ VDBMetaData vdb = requestMsg.getWorkContext().getVDB();
+ this.queryMetadata = vdb.getAttachment(QueryMetadataInterface.class);
+ this.queryMetadata = new TempMetadataAdapter(this.queryMetadata, new TempMetadataStore());
+
+ if (requestMsg.isTransactional() && this.connectorEnv.isXaCapable()) {
+ this.securityContext.setTransactional(true);
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -112,12 +112,12 @@
if (!ignoreDone) {
throw new IllegalStateException("More work is not valid once DONE"); //$NON-NLS-1$
}
- LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, new Object[] {this, "ignoring more work, since the work item is done"}); //$NON-NLS-1$
+ LogManager.logDetail(com.metamatrix.common.log.LogConstants.CTX_DQP, new Object[] {this, "ignoring more work, since the work item is done"}); //$NON-NLS-1$
}
}
private void logTrace(String msg) {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, new Object[] {this, msg, this.threadState});
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, new Object[] {this, msg, this.threadState});
}
protected abstract void process();
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -234,7 +234,7 @@
// Clear the cacheKeyDone
this.rowCount = 0;
// Log status
- LogManager.logInfo(com.metamatrix.common.util.LogConstants.CTX_DQP, DQPPlugin.Util.getString("CodeTableCache.Cleared_code_tables", removedTables, removedRecords)); //$NON-NLS-1$
+ LogManager.logInfo(com.metamatrix.common.log.LogConstants.CTX_DQP, DQPPlugin.Util.getString("CodeTableCache.Cleared_code_tables", removedTables, removedRecords)); //$NON-NLS-1$
}
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -55,9 +55,9 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -75,6 +75,7 @@
import com.metamatrix.dqp.service.BufferService;
import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.service.TransactionContext.Scope;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.tempdata.TempTableStoreImpl;
@@ -247,8 +248,8 @@
req.setCommand(holder.requestMsg.getCommandString());
req.setProcessingTime(holder.getProcessingTimestamp());
- if (holder.getTransactionContext() != null && holder.getTransactionContext().getXid() != null) {
- req.setTransactionId(holder.getTransactionContext().getXid().toString());
+ if (holder.getTransactionContext() != null && holder.getTransactionContext().getTransactionType() != Scope.NONE) {
+ req.setTransactionId(holder.getTransactionContext().getTransactionId());
}
for (DataTierTupleSource conInfo : holder.getConnectorRequests()) {
@@ -568,8 +569,8 @@
RequestID rID = new RequestID(workContext.getConnectionID(), msg.getExecutionId());
String txnID = null;
TransactionContext tc = workItem.getTransactionContext();
- if (tc != null && tc.getXid() != null) {
- txnID = tc.getXid().toString();
+ if (tc != null && tc.getTransactionType() != Scope.NONE) {
+ txnID = tc.getTransactionId();
}
String appName = workContext.getAppName();
// Log to request log
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -26,7 +26,6 @@
import java.util.List;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -52,8 +51,8 @@
// Data state
private ConnectorWork cwi;
- private int index = 0;
- private int rowsProcessed = 0;
+ private int index;
+ private int rowsProcessed;
private AtomicResultsMessage arm;
private boolean closed;
@@ -95,11 +94,11 @@
}
void open() throws MetaMatrixComponentException, MetaMatrixProcessingException {
- Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
try {
if (this.cwi == null) {
this.cwi = this.dataMgr.executeRequest(aqr, this.connectorName);
- workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
+ Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
+ workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
}
receiveResults(this.cwi.execute());
} catch (ConnectorException e) {
@@ -132,21 +131,21 @@
}
}
- void exceptionOccurred(Exception exception, boolean removeState) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ void exceptionOccurred(ConnectorException exception, boolean removeState) throws MetaMatrixComponentException, MetaMatrixProcessingException {
if (removeState) {
fullyCloseSource();
}
if(workItem.requestMsg.supportsPartialResults()) {
AtomicResultsMessage emptyResults = new AtomicResultsMessage(new List[0], null);
- emptyResults.setWarnings(Arrays.asList(exception));
+ emptyResults.setWarnings(Arrays.asList((Exception)exception));
emptyResults.setFinalRow(this.rowsProcessed);
receiveResults(arm);
} else {
- if (exception instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)exception;
+ if (exception.getCause() instanceof MetaMatrixComponentException) {
+ throw (MetaMatrixComponentException)exception.getCause();
}
- if (exception instanceof MetaMatrixProcessingException) {
- throw (MetaMatrixProcessingException)exception;
+ if (exception.getCause() instanceof MetaMatrixProcessingException) {
+ throw (MetaMatrixProcessingException)exception.getCause();
}
throw new MetaMatrixComponentException(exception);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -75,7 +75,7 @@
chunk = stream.getNextChunk();
shouldClose = chunk.isLast();
} catch (MetaMatrixComponentException e) {
- LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
+ LogManager.logWarning(com.metamatrix.common.log.LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
ex = e;
} catch (IOException e) {
ex = e;
@@ -92,15 +92,19 @@
}
if (shouldClose) {
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException e) {
- LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
+ close();
+ }
+ }
+
+ void close() {
+ try {
+ if (stream != null) {
+ stream.close();
}
- parent.removeLobStream(streamRequestId);
- }
+ } catch (IOException e) {
+ LogManager.logWarning(com.metamatrix.common.log.LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
+ }
+ parent.removeLobStream(streamRequestId);
}
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -136,7 +136,7 @@
if (prepPlan == null) {
//if prepared plan does not exist, create one
prepPlan = new PreparedPlan();
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, new Object[] { "Query does not exist in cache: ", sqlQuery}); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, new Object[] { "Query does not exist in cache: ", sqlQuery}); //$NON-NLS-1$
}
ProcessorPlan cachedPlan = prepPlan.getPlan();
@@ -151,7 +151,7 @@
this.prepPlanCache.put(id, this.context.isSessionFunctionEvaluated(), prepPlan);
}
} else {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
processPlan = cachedPlan.clone();
//already in cache. obtain the values from cache
analysisRecord = prepPlan.getAnalysisRecord();
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,9 +22,8 @@
package org.teiid.dqp.internal.process;
+import java.sql.Connection;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
@@ -43,9 +42,9 @@
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.id.IDGenerator;
import com.metamatrix.core.id.IntegerIDFactory;
@@ -57,6 +56,7 @@
import com.metamatrix.dqp.service.AuthorizationService;
import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.service.TransactionContext.Scope;
import com.metamatrix.jdbc.api.ExecutionProperties;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -71,6 +71,7 @@
import com.metamatrix.query.processor.QueryProcessor;
import com.metamatrix.query.processor.TempTableDataManager;
import com.metamatrix.query.processor.xml.XMLPlan;
+import com.metamatrix.query.processor.xml.XMLPostProcessor;
import com.metamatrix.query.processor.xquery.XQueryPlan;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.rewriter.QueryRewriter;
@@ -85,6 +86,7 @@
import com.metamatrix.query.sql.lang.XQuery;
import com.metamatrix.query.sql.symbol.Constant;
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;
import com.metamatrix.query.util.CommandContext;
@@ -126,7 +128,6 @@
protected AnalysisRecord analysisRecord;
protected CommandContext context;
protected QueryProcessor processor;
- protected List schemas;
protected TransactionContext transactionContext;
protected ConnectorManagerRepository connectorManagerRepo;
@@ -322,7 +323,7 @@
}
}
- protected void createProcessor(Command processingCommand) throws MetaMatrixComponentException {
+ private void createProcessor() throws MetaMatrixComponentException {
TransactionContext tc = null;
@@ -335,16 +336,20 @@
}
// If local or global transaction is not started.
- if (tc == null || tc.getXid() == null) {
+ if (tc == null || tc.getTransactionType() != Scope.NONE) {
boolean startAutoWrapTxn = false;
if(ExecutionProperties.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){
startAutoWrapTxn = true;
- } else if ( processingCommand.updatingModelCount(metadata) > 1) {
- if (ExecutionProperties.TXN_WRAP_DETECT.equals(requestMsg.getTxnAutoWrapMode())){
- startAutoWrapTxn = true;
- }
+ } else if (ExecutionProperties.TXN_WRAP_DETECT.equals(requestMsg.getTxnAutoWrapMode())){
+ boolean transactionalRead = requestMsg.getTransactionIsolation() == Connection.TRANSACTION_REPEATABLE_READ
+ || requestMsg.getTransactionIsolation() == Connection.TRANSACTION_SERIALIZABLE;
+ if (!transactionalRead && userCommand instanceof StoredProcedure && ((StoredProcedure)userCommand).getUpdateCount() == 0) {
+ startAutoWrapTxn = false;
+ } else {
+ startAutoWrapTxn = processPlan.requiresTransaction(transactionalRead);
+ }
}
if (startAutoWrapTxn) {
@@ -464,53 +469,6 @@
}
}
- private void setSchemasForXMLPlan(Command command, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryMetadataException {
-
- XMLPlan xmlPlan = null;
-
- if(processPlan instanceof XMLPlan) {
- xmlPlan = (XMLPlan)processPlan;
- }else if(processPlan instanceof XQueryPlan) {
- ((XQueryPlan)processPlan).setXMLFormat(requestMsg.getXMLFormat());
- }else if(command instanceof StoredProcedure) {
- Collection childPlans = processPlan.getChildPlans();
- if(!childPlans.isEmpty()) {
- ProcessorPlan plan = (ProcessorPlan)childPlans.iterator().next();
- //check the last child plan of this procedure plan
- Collection procChildPlans = plan.getChildPlans();
- if(procChildPlans.size() > 0) {
- Iterator iter = procChildPlans.iterator();
- ProcessorPlan lastPlan = null;
- while(iter.hasNext()) {
- lastPlan = (ProcessorPlan) iter.next();
- }
- if(lastPlan instanceof XMLPlan) {
- xmlPlan = (XMLPlan)lastPlan;
- }
- }
- }
- }
-
- if (xmlPlan == null) {
- return;
- }
-
- // Set the post-processing options on the plan
- boolean shouldValidate = requestMsg.getValidationMode();
-
- xmlPlan.setShouldValidate(shouldValidate);
- xmlPlan.setStylesheet(requestMsg.getStyleSheet());
- xmlPlan.setXMLFormat(requestMsg.getXMLFormat());
-
- // if the validation/schema mode is set to true look up the schema in runtime metadata
- if (shouldValidate) {
- this.schemas = metadata.getXMLSchemas(xmlPlan.getDocumentGroup().getMetadataID());
- // set the schema into the plan
- xmlPlan.setXMLSchemas(schemas);
- }
- }
-
private void createAnalysisRecord(Command command) {
Option option = command.getOption();
boolean getPlan = requestMsg.getShowPlan();
@@ -532,12 +490,37 @@
generatePlan();
+ postProcessXML();
+
validateAccess(userCommand);
- setSchemasForXMLPlan(userCommand, metadata);
-
- createProcessor(userCommand);
+ createProcessor();
}
+
+ private void postProcessXML() {
+ boolean alreadyFormatted = false;
+ if (requestMsg.getXMLFormat() != null) {
+ if(processPlan instanceof XQueryPlan) {
+ ((XQueryPlan)processPlan).setXMLFormat(requestMsg.getXMLFormat());
+ alreadyFormatted = true;
+ } else if (processPlan instanceof XMLPlan) {
+ ((XMLPlan)processPlan).setXMLFormat(requestMsg.getXMLFormat());
+ alreadyFormatted = true;
+ }
+ }
+ boolean xml = alreadyFormatted
+ || (processPlan.getOutputElements().size() == 1 && DataTypeManager.DefaultDataClasses.XML.equals(((SingleElementSymbol)processPlan.getOutputElements().get(0)).getType()));
+
+ if (xml && ((!alreadyFormatted && requestMsg.getXMLFormat() != null) || requestMsg.getStyleSheet() != null)) {
+ XMLPostProcessor postProcessor = new XMLPostProcessor(processPlan);
+ postProcessor.setStylesheet(requestMsg.getStyleSheet());
+ if (!alreadyFormatted) {
+ postProcessor.setXMLFormat(requestMsg.getXMLFormat());
+ }
+ this.processPlan = postProcessor;
+ }
+ this.context.setValidateXML(requestMsg.getValidationMode());
+ }
public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws MetaMatrixProcessingException, MetaMatrixComponentException {
boolean isRootXQuery = recursionGroup == null && commandContext.getCallStackDepth() == 0 && userCommand instanceof XQuery;
@@ -570,7 +553,6 @@
}
protected void validateAccess(Command command) throws QueryValidatorException, MetaMatrixComponentException {
- // See if entitlement checking is turned on
AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.authService, this.workContext.getVDB());
validateWithVisitor(visitor, this.metadata, command);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -25,8 +25,6 @@
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -45,9 +43,9 @@
import com.metamatrix.common.buffer.TupleBuffer;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.log.MessageLevel;
@@ -120,7 +118,7 @@
private int begin;
private int end;
private TupleBatch savedBatch;
- private Map<Integer, LobWorkItem> lobStreams = Collections.synchronizedMap(new HashMap<Integer, LobWorkItem>(4));
+ private Map<Integer, LobWorkItem> lobStreams = new ConcurrentHashMap<Integer, LobWorkItem>(4);
/**The time when command begins processing on the server.*/
private long processingTimestamp = System.currentTimeMillis();
@@ -313,6 +311,10 @@
this.resultsBuffer = null;
this.processor = null;
+
+ for (LobWorkItem lobWorkItem : this.lobStreams.values()) {
+ lobWorkItem.close();
+ }
}
if (this.transactionState == TransactionState.ACTIVE) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -44,8 +44,8 @@
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.NamedThreadFactory;
import com.metamatrix.query.QueryPlugin;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -522,11 +522,7 @@
txnImpl.setAssociatedSession(Long.parseLong(transactionContext.getThreadId()));
txnImpl.setCreatedTime(transactionContext.getCreationTime());
txnImpl.setScope(transactionContext.getTransactionType().toString());
- if (transactionContext.getXid() != null) {
- txnImpl.setId(transactionContext.getXid().toString());
- } else {
- txnImpl.setId(transactionContext.getTransaction().toString());
- }
+ txnImpl.setId(transactionContext.getTransactionId());
result.add(txnImpl);
}
return result;
Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -992,7 +992,11 @@
*/
public String getCharacterVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
try {
- return ObjectConverterUtil.convertToString(new ByteArrayInputStream(getBinaryVDBResource(resourcePath)));
+ byte[] bytes = getBinaryVDBResource(resourcePath);
+ if (bytes == null) {
+ return null;
+ }
+ return ObjectConverterUtil.convertToString(new ByteArrayInputStream(bytes));
} catch (IOException e) {
throw new MetaMatrixComponentException(e);
}
Modified: trunk/engine/src/main/java/org/teiid/security/roles/AuthorizationPermissionsImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/security/roles/AuthorizationPermissionsImpl.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/security/roles/AuthorizationPermissionsImpl.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -31,8 +31,8 @@
import org.teiid.security.SecurityPlugin;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
/**
* This class represents a heterogeneous set of AuthorizationPermission instances. Like the AuthorizationPermission
Modified: trunk/engine/src/main/java/org/teiid/security/roles/AuthorizationPolicyFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/security/roles/AuthorizationPolicyFactory.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/security/roles/AuthorizationPolicyFactory.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -49,8 +49,8 @@
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
Modified: trunk/engine/src/main/java/org/teiid/security/roles/BasicAuthorizationPermission.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/security/roles/BasicAuthorizationPermission.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/main/java/org/teiid/security/roles/BasicAuthorizationPermission.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -24,8 +24,8 @@
import org.teiid.security.SecurityPlugin;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
/**
* A BasicAuthorizationPermission defines access permissions for Metadata resources (i.e., MetadataID instances).
Modified: trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,8 +22,7 @@
package com.metamatrix.common.buffer.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.RandomAccessFile;
@@ -37,6 +36,7 @@
import com.metamatrix.common.buffer.FileStore;
import com.metamatrix.common.buffer.StorageManager;
import com.metamatrix.core.util.UnitTestUtil;
+
public class TestFileStorageManager {
public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles, String dir) throws MetaMatrixComponentException {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -250,8 +250,6 @@
ProcessorPlan plan = TestOptimizer.helpPlan(testCase.userQuery, metadata, null, capFinder, new String[] {testCase.optimizedQuery}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testAliasCreationWithInlineView() {
@@ -262,8 +260,6 @@
metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
}
@Test public void testAliasPreservationWithInlineView() {
@@ -274,8 +270,6 @@
metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS q1"}, true); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
}
/**
@@ -305,8 +299,6 @@
0, // Sort
0 // UnionAll
});
-
- checkSubPlanCount(plan, 0);
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -465,10 +465,6 @@
checkNodeTypes(plan, new int[] {expectedCount}, new Class[] {DependentJoin.class});
}
- public static void checkSubPlanCount(ProcessorPlan plan, int expectedCount) {
- assertEquals("Checking plan count", expectedCount, plan.getChildPlans().size()); //$NON-NLS-1$
- }
-
public static FakeMetadataFacade example1() {
// Create models
FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
@@ -764,8 +760,6 @@
new String[] {"SELECT pm1.g1.e1, e2, pm1.g1.e3, e4 FROM pm1.g1"} ); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
}
@Test public void testSelectStarPhysical() {
@@ -4764,7 +4758,7 @@
caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- ProcessorPlan plan = helpPlan(sql,
+ RelationalPlan plan = (RelationalPlan)helpPlan(sql,
FakeMetadataFactory.exampleBQTCached(),
null, capFinder,
new String[] {"SELECT bqt1.smalla.datevalue, bqt1.smalla.intkey, bqt1.smalla.stringkey, bqt1.smalla.objectvalue FROM bqt1.smalla WHERE (bqt1.smalla.intkey = 46) AND (bqt1.smalla.stringkey = '46')"}, //$NON-NLS-1$
@@ -4787,9 +4781,7 @@
0 // UnionAll
});
- Collection subplans = plan.getChildPlans();
- assertEquals(1, subplans.size());
- ProcessorPlan subplan = (ProcessorPlan) subplans.iterator().next();
+ ProcessorPlan subplan = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(((SelectNode)plan.getRootNode().getChildren()[0]).getCriteria()).get(0).getCommand().getProcessorPlan();
// Collect atomic queries
Set<String> actualQueries = getAtomicQueries(subplan);
@@ -5701,8 +5693,6 @@
null, capFinder,
new String[] { "SELECT e1 FROM pm1.g1 WHERE pm1.g1.e1 IN (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g1.e1 = '2')" }, SHOULD_SUCCEED); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
}
/*
@@ -5725,8 +5715,6 @@
metadata, null, capFinder, new String[] {"SELECT g_0.e1, g_2.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND (g_0.e2 = g_1.e2) AND (g_0.e1 = g_2.e1) AND (g_0.e2 IN (SELECT g_4.e2 FROM pm1.g1 AS g_4))"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
}
/**
@@ -5856,8 +5844,6 @@
0, // Sort
0 // UnionAll
});
-
- checkSubPlanCount(plan, 1);
}
/*
@@ -6007,8 +5993,6 @@
null, capFinder,
new String[] { "SELECT g1__1.e1 FROM pm1.g1 AS g1__1 LEFT OUTER JOIN pm1.g1 AS g1__2 ON g1__2.e1 = g1__1.e1 AND g1__2.e1 = (SELECT MAX(pm1.g1.e1) FROM pm1.g1 WHERE pm1.g1.e1 = g1__2.e1)" }, SHOULD_SUCCEED); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
}
@Test public void testCase4263b() {
@@ -6043,8 +6027,6 @@
0, // Sort
0 // UnionAll
});
-
- checkSubPlanCount(plan, 1);
}
@Test public void testCase4279() throws Exception {
@@ -6065,8 +6047,6 @@
null, capFinder,
new String[] { "SELECT CASE WHEN g_0.e1 = 'S' THEN 'Pay' WHEN g_0.e1 = 'P' THEN 'Rec' ELSE g_0.e1 END, CASE WHEN g_1.e1 = 'S' THEN 'Pay' WHEN g_1.e1 = 'P' THEN 'Rec' ELSE g_1.e1 END, g_0.e2, g_1.e2 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g1 AS g_1 ON g_0.e2 = g_1.e2 AND g_1.e2 = 1 WHERE g_0.e2 = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
}
@Test public void testCase4312() {
@@ -6241,7 +6221,6 @@
0, // Sort
0 // UnionAll
});
- checkSubPlanCount(plan, 1);
}
/**
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptionalJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptionalJoins.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptionalJoins.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -35,8 +35,6 @@
new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinNode1_1() {
@@ -59,8 +57,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinNode2() {
@@ -97,8 +93,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinNode4() {
@@ -148,8 +142,6 @@
new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinNode11() {
@@ -157,8 +149,6 @@
new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinNode12() {
@@ -166,8 +156,6 @@
new String[] {"SELECT pm1.g3.e1 FROM pm1.g3"} ); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinNode13() {
@@ -190,8 +178,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
/**
@@ -217,8 +203,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinNode15() {
@@ -226,8 +210,6 @@
new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinNode16() {
@@ -250,8 +232,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinNode17() {
@@ -274,8 +254,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinWithIntersection() throws Exception {
@@ -305,8 +283,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
/**
@@ -332,8 +308,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
/**
@@ -359,8 +333,6 @@
0, // Sort
1 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinWithCompoundCriteria() {
@@ -383,8 +355,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinWithDupRemoval() {
@@ -407,8 +377,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
/**
@@ -455,8 +423,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
/**
@@ -484,8 +450,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinWithoutHint_union() {
@@ -510,8 +474,6 @@
0, // Sort
1 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
@Test public void testOptionalJoinWithOrderedLimit() {
@@ -536,8 +498,6 @@
0, // Sort
0 // UnionAll
});
-
- TestOptimizer.checkSubPlanCount(plan, 0);
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -40,7 +40,6 @@
ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
new String[] { "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- TestOptimizer.checkSubPlanCount(plan, 0);
}
/**
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -266,8 +266,6 @@
0, // Sort
0 // UnionAll
});
-
- checkSubPlanCount(plan, 1);
}
@Test public void testCorrelatedSubquery2() {
@@ -352,7 +350,6 @@
0, // Sort
0 // UnionAll
});
- checkSubPlanCount(plan, 1);
}
@Test public void testCorrelatedSubqueryInTransformation2() {
@@ -602,9 +599,6 @@
0, // Sort
0 // UnionAll
});
-
- checkSubPlanCount(plan, 1);
-
}
/**
@@ -715,8 +709,6 @@
null, capFinder,
new String[] { "SELECT g_0.e1, (convert((SELECT MAX(g_1.e1) FROM pm1.g1 AS g_1), integer) + 1) FROM pm1.g1 AS g_0" }, SHOULD_SUCCEED); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestNameInSourceResolverVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestNameInSourceResolverVisitor.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestNameInSourceResolverVisitor.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -169,10 +169,6 @@
return 0;
}
- public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException {
- return 0;
- }
-
public void acceptVisitor(LanguageVisitor visitor) {
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -146,12 +146,4 @@
return new HashMap();
}
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getChildPlans()
- * @since 4.2
- */
- public Collection getChildPlans() {
- return Collections.EMPTY_LIST;
- }
-
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,10 +22,11 @@
package com.metamatrix.query.processor;
+import static org.junit.Assert.*;
+
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.*;
import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -35,6 +36,8 @@
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.optimizer.TestOptimizer;
+import com.metamatrix.query.processor.proc.CreateCursorResultSetInstruction;
+import com.metamatrix.query.processor.proc.ProcedurePlan;
import com.metamatrix.query.processor.proc.TestProcedureProcessor;
import com.metamatrix.query.processor.relational.DependentProcedureExecutionNode;
import com.metamatrix.query.processor.relational.RelationalNode;
@@ -259,8 +262,6 @@
ProcessorPlan plan = TestOptimizer.helpPlan(userQuery, FakeMetadataFactory.example1Cached(),
new String[] {} );
- TestOptimizer.checkSubPlanCount(plan, 1);
-
RelationalPlan rplan = (RelationalPlan)plan;
RelationalNode root = rplan.getRootNode();
@@ -277,8 +278,12 @@
assertEquals(inputCriteria, dep.getInputCriteria().toString());
- plan = (ProcessorPlan)((ProcessorPlan)plan.getChildPlans().iterator().next()).getChildPlans().iterator().next();
+ ProcedurePlan pp = (ProcedurePlan)dep.getProcessorPlan();
+ CreateCursorResultSetInstruction ccrsi = (CreateCursorResultSetInstruction)pp.getOriginalProgram().getInstructionAt(0);
+
+ plan = ccrsi.getCommand();
+
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
TestOptimizer.checkAtomicQueries(new String[] {atomicQuery}, plan);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -163,9 +163,6 @@
assertNotNull("Output elements of process plan are null", process.getOutputElements()); //$NON-NLS-1$
- // verify we can get child plans for any plan with no problem
- process.getChildPlans();
-
return process;
} catch (MetaMatrixComponentException e) {
throw new RuntimeException(e);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/TestSqlEval.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/TestSqlEval.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/TestSqlEval.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -40,6 +40,7 @@
import com.metamatrix.query.processor.QueryProcessor;
import com.metamatrix.query.processor.TestProcessor;
import com.metamatrix.query.processor.xml.TestXMLProcessor;
+import com.metamatrix.query.processor.xquery.SqlEval;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.util.CommandContext;
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -27,7 +27,6 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -60,7 +59,6 @@
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.QueryProcessor;
import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.processor.program.Program;
import com.metamatrix.query.processor.xml.TestXMLPlanningEnhancements;
import com.metamatrix.query.processor.xml.TestXMLProcessor;
import com.metamatrix.query.resolver.QueryResolver;
@@ -98,11 +96,7 @@
if ( capabilitiesFinder == null ) capabilitiesFinder = new DefaultCapabilitiesFinder();
ProcessorPlan plan = QueryOptimizer.optimizePlan(userCommand, metadata, null, capabilitiesFinder, analysisRecord, null);
- // verify we can get child plans for any plan with no problem
- plan.getChildPlans();
-
return plan;
-
} finally {
if(DEBUG) {
System.out.println(analysisRecord.getDebugLog());
@@ -2307,16 +2301,6 @@
}
/**
- * previously the following would break with an npe
- *
- * Now it will not and the rewriter should remove empty loops, where this was happening
- */
- @Test public void testGetChildPlans() {
- Program program = new Program();
- assertEquals(Collections.EMPTY_LIST, program.getChildPlans());
- }
-
- /**
* wraps {@link TestXMLPlanningEnhancements.testNested2WithContextCriteria5d1} in a procedure
*/
@Test public void testXMLWithExternalCriteria() throws Exception {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLPlanningEnhancements.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLPlanningEnhancements.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLPlanningEnhancements.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -331,7 +331,7 @@
FakeDataManager dataMgr = TestXMLProcessor.exampleDataManagerNested(metadata);
String expectedDoc = TestXMLProcessor.readFile("TestXMLPlanningEnhancements-testMappingClassWithStoredProcedureAndCriteria.xml"); //$NON-NLS-1$
- XMLPlan plan = TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc18a where supplierID<56", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ XMLPlan plan = (XMLPlan)TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc18a where supplierID<56", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
Map stats = XMLProgramUtil.getProgramStats(plan.getOriginalProgram());
assertNull(stats.get(ExecStagingTableInstruction.class));
@@ -383,7 +383,7 @@
String expectedDoc = TestXMLProcessor.readFile("TestXMLProcessor-FullSuppliers.xml"); //$NON-NLS-1$
- XMLPlan plan = TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ XMLPlan plan = (XMLPlan)TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
//check for staging; one for staging and for unloading
Map stats = XMLProgramUtil.getProgramStats(plan.getOriginalProgram());
@@ -404,7 +404,7 @@
String expectedDoc = TestXMLProcessor.readFile("TestXMLProcessor-FullSuppliers.xml"); //$NON-NLS-1$
- XMLPlan plan = TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ XMLPlan plan = (XMLPlan)TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
//check for no staging
Map stats = XMLProgramUtil.getProgramStats(plan.getOriginalProgram());
@@ -417,7 +417,7 @@
String expectedDoc = TestXMLProcessor.readFile("TestXMLProcessor-FullSuppliers.xml"); //$NON-NLS-1$
- XMLPlan plan = TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9 OPTION NOCACHE", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ XMLPlan plan = (XMLPlan)TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9 OPTION NOCACHE", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
//check for no staging
Map stats = XMLProgramUtil.getProgramStats(plan.getOriginalProgram());
@@ -430,13 +430,13 @@
String expectedDoc = TestXMLProcessor.readFile("TestXMLProcessor-FullSuppliers.xml"); //$NON-NLS-1$
- XMLPlan plan = TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9 OPTION NOCACHE XMLTEST.SUPPLIERS", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ XMLPlan plan = (XMLPlan)TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9 OPTION NOCACHE XMLTEST.SUPPLIERS", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
//check for no staging by the mapping class name
Map stats = XMLProgramUtil.getProgramStats(plan.getOriginalProgram());
assertNull(stats.get(ExecStagingTableInstruction.class));
- plan = TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9 OPTION NOCACHE XMLTEST.SUPPLIERS", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ plan = (XMLPlan)TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.doc9 OPTION NOCACHE XMLTEST.SUPPLIERS", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
//check for no staging by the alias mapping class name
stats = XMLProgramUtil.getProgramStats(plan.getOriginalProgram());
@@ -450,7 +450,7 @@
String expectedDoc = TestXMLProcessor.readFile("TestXMLProcessor-FullSuppliers.xml"); //$NON-NLS-1$
- XMLPlan xmlPlan = TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.docJoin", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ XMLPlan xmlPlan = (XMLPlan)TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.docJoin", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
Map stats = XMLProgramUtil.getProgramStats(xmlPlan.getOriginalProgram());
List list = (List)stats.get(ExecSqlInstruction.class);
@@ -490,7 +490,7 @@
String expectedDoc = TestXMLProcessor.readFile("TestXMLProcessor-FullSuppliers.xml"); //$NON-NLS-1$
- XMLPlan xmlPlan = TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.docJoin", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ XMLPlan xmlPlan = (XMLPlan)TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.docJoin", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
Map stats = XMLProgramUtil.getProgramStats(xmlPlan.getOriginalProgram());
List list = (List)stats.get(ExecSqlInstruction.class);
@@ -528,7 +528,7 @@
String expectedDoc = TestXMLProcessor.readFile("TestXMLProcessor-OnlySupplier51.xml"); //$NON-NLS-1$
- XMLPlan xmlPlan = TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.docJoin where context(Supplier, SupplierID) = 51", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ XMLPlan xmlPlan = (XMLPlan)TestXMLProcessor.helpTestProcess("SELECT * FROM xmltest.docJoin where context(Supplier, SupplierID) = 51", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
//check for staging; one for staging and for unloading - only two pairs are expected
Map stats = XMLProgramUtil.getProgramStats(xmlPlan.getOriginalProgram());
assertEquals(4, ((List)stats.get(ExecStagingTableInstruction.class)).size());
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -26,6 +26,7 @@
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -33,7 +34,8 @@
import java.util.Map;
import java.util.StringTokenizer;
-import org.junit.Ignore;
+import javax.xml.transform.OutputKeys;
+
import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -73,6 +75,7 @@
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.processor.BatchCollector;
import com.metamatrix.query.processor.FakeDataManager;
+import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.QueryProcessor;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.rewriter.QueryRewriter;
@@ -83,6 +86,7 @@
import com.metamatrix.query.unittest.FakeMetadataObject;
import com.metamatrix.query.unittest.FakeMetadataStore;
import com.metamatrix.query.util.CommandContext;
+import com.metamatrix.query.util.XMLFormatConstants;
/**
* Tests XML processing, which involves XMLPlanner making a ProcessorPlan
@@ -2933,16 +2937,16 @@
return command;
}
- static XMLPlan helpTestProcess(String sql, String expectedDoc, FakeMetadataFacade metadata, FakeDataManager dataMgr) throws Exception{
+ static ProcessorPlan helpTestProcess(String sql, String expectedDoc, FakeMetadataFacade metadata, FakeDataManager dataMgr) throws Exception{
return helpTestProcess(sql, expectedDoc, metadata, dataMgr, true, MetaMatrixComponentException.class, null);
}
- static XMLPlan helpTestProcess(String sql, String expectedDoc, FakeMetadataFacade metadata, FakeDataManager dataMgr, final boolean shouldSucceed, Class expectedException, final String shouldFailMsg) throws Exception{
+ static ProcessorPlan helpTestProcess(String sql, String expectedDoc, FakeMetadataFacade metadata, FakeDataManager dataMgr, final boolean shouldSucceed, Class expectedException, final String shouldFailMsg) throws Exception{
return helpTestProcess(sql, expectedDoc, metadata, dataMgr, shouldSucceed, expectedException, shouldFailMsg, new DefaultCapabilitiesFinder());
}
- static XMLPlan helpTestProcess(String sql, String expectedDoc, FakeMetadataFacade metadata, FakeDataManager dataMgr, final boolean shouldSucceed, Class expectedException, final String shouldFailMsg, CapabilitiesFinder capFinder) throws Exception{
+ static ProcessorPlan helpTestProcess(String sql, String expectedDoc, FakeMetadataFacade metadata, FakeDataManager dataMgr, final boolean shouldSucceed, Class expectedException, final String shouldFailMsg, CapabilitiesFinder capFinder) throws Exception{
Command command = helpGetCommand(sql, metadata);
if (shouldSucceed){
@@ -2950,15 +2954,12 @@
AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
CommandContext planningContext = new CommandContext(); //this should be the same as the processing context, but that's not easy to do
- XMLPlan plan = (XMLPlan)QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, planningContext);
+ ProcessorPlan plan = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, planningContext);
if(DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
- // Verify we can get the child plans without error
- plan.getChildPlans();
-
// Process twice, to test reset and clone methods
for (int i=1; i<=2; i++) {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
@@ -2988,7 +2989,7 @@
//Test reset, clone methods
if (i==1) {
plan.reset();
- plan = (XMLPlan)plan.clone();
+ plan = plan.clone();
}
}
return plan;
@@ -2996,7 +2997,7 @@
Exception expected = null;
AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
try{
- XMLPlan plan = (XMLPlan)QueryOptimizer.optimizePlan(command, metadata, null, new DefaultCapabilitiesFinder(), analysisRecord, null);
+ ProcessorPlan plan = QueryOptimizer.optimizePlan(command, metadata, null, new DefaultCapabilitiesFinder(), analysisRecord, null);
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
@@ -3044,8 +3045,15 @@
System.out.println(analysisRecord.getDebugLog());
}
- BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
+ helpTestProcess(expectedDocs, dataMgr, plan);
+ }
+
+ private void helpTestProcess(String[] expectedDocs, FakeDataManager dataMgr,
+ ProcessorPlan plan) throws MetaMatrixComponentException,
+ MetaMatrixProcessingException, SQLException {
+ BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
+ context.setProcessDebug(DEBUG);
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
@@ -3067,7 +3075,7 @@
compareDocuments(expectedDocs[i], actualDoc);
}
tupleBuffer.remove();
- }
+ }
// =============================================================================================
// T E S T S
@@ -4620,7 +4628,7 @@
" </Catalog>\r\n" + //$NON-NLS-1$
"</Catalogs>\r\n\r\n"; //$NON-NLS-1$
- XMLPlan plan = helpTestProcess("SELECT * FROM xmltest.doc9 WHERE context(SupplierID, SupplierID)='52'", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ XMLPlan plan = (XMLPlan)helpTestProcess("SELECT * FROM xmltest.doc9 WHERE context(SupplierID, SupplierID)='52'", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
// check the staging base line (unknown cost)
// one for staging and for unloading
@@ -11842,7 +11850,9 @@
}
- @Ignore("stored procedure wrapper removal has been disabled")
+ /**
+ * Also tests the logic of the {@link XMLPostProcessor}
+ */
@Test public void testProcedureAndXML() throws Exception {
FakeMetadataFacade metadata = exampleMetadataCached();
FakeDataManager dataMgr = exampleDataManager(metadata);
@@ -11867,7 +11877,32 @@
" </Catalog>\r\n" + //$NON-NLS-1$
"</Catalogs>\r\n\r\n"; //$NON-NLS-1$
- helpTestProcess("exec xmltest.vsp1()", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ ProcessorPlan plan = helpTestProcess("exec xmltest.vsp1()", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
+ plan.reset();
+ XMLPostProcessor postProcessor = new XMLPostProcessor(plan);
+ postProcessor.setXMLFormat(XMLFormatConstants.XML_TREE_FORMAT);
+ postProcessor.setStylesheet("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"@*|node()\"><xsl:copy><xsl:apply-templates select=\"@*|node()\"/></xsl:copy></xsl:template><xsl:template match=\"Quantity\"/></xsl:stylesheet>");
+ expectedDoc =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + //$NON-NLS-1$
+ "<Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" + //$NON-NLS-1$
+ " <Catalog>\r\n" + //$NON-NLS-1$
+ " <Items>\r\n" + //$NON-NLS-1$
+ " <Item ItemID=\"001\">\r\n" + //$NON-NLS-1$
+ " <Name>Lamp</Name>\r\n" + //$NON-NLS-1$
+ " \r\n" + //$NON-NLS-1$
+ " </Item>\r\n" + //$NON-NLS-1$
+ " <Item ItemID=\"002\">\r\n" + //$NON-NLS-1$
+ " <Name>Screwdriver</Name>\r\n" + //$NON-NLS-1$
+ " \r\n" + //$NON-NLS-1$
+ " </Item>\r\n" + //$NON-NLS-1$
+ " <Item ItemID=\"003\">\r\n" + //$NON-NLS-1$
+ " <Name>Goat</Name>\r\n" + //$NON-NLS-1$
+ " \r\n" + //$NON-NLS-1$
+ " </Item>\r\n" + //$NON-NLS-1$
+ " </Items>\r\n" + //$NON-NLS-1$
+ " </Catalog>\r\n" + //$NON-NLS-1$
+ "</Catalogs>\r\n\r\n"; //$NON-NLS-1$
+ helpTestProcess(new String[] {expectedDoc}, dataMgr, postProcessor); //$NON-NLS-1$
}
/**
Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -52,7 +52,6 @@
import com.metamatrix.query.function.SystemFunctionManager;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.parser.QueryParser;
@@ -2275,87 +2274,6 @@
QueryResolver.resolveCommand(command, FakeMetadataFactory.exampleBQTCached());
}
- @Test public void testCommandUpdatingCount1() throws Exception{
- Command command = helpResolve("SELECT * FROM pm1.g1 as x, pm1.g1 as y"); //$NON-NLS-1$
- assertEquals(0, command.updatingModelCount(metadata));
- }
-
- @Test public void testCommandUpdatingCount2() throws Exception{
- Command command = helpResolve("SELECT * FROM doc1"); //$NON-NLS-1$
- assertEquals(0, command.updatingModelCount(metadata));
- }
-
- @Test public void testCommandUpdatingCount5() throws Exception{
- Command command = helpResolve("SELECT pm1.g1.e1 FROM pm1.g1 UNION SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY e1"); //$NON-NLS-1$
- assertEquals(0, command.updatingModelCount(metadata));
- }
-
- /** case 3955 */
- @Test public void testCommandUpdatingCountPhysicalInsert() throws Exception{
- Command command = helpResolve("INSERT INTO pm1.g1 (e2) VALUES (666) "); //$NON-NLS-1$
- assertEquals(1, command.updatingModelCount(metadata));
- }
-
- /** case 3955 */
- @Test public void testCommandUpdatingCountVirtualInsert() throws Exception{
- Command command = helpResolve("INSERT INTO vm1.g1 (e2) VALUES (666) "); //$NON-NLS-1$
- assertEquals(2, command.updatingModelCount(metadata));
- }
-
- /** case 3955 */
- @Test public void testCommandUpdatingCountPhysicalUpdate() throws Exception{
- Command command = helpResolve("UPDATE pm1.g1 SET e2=667 WHERE e2=666"); //$NON-NLS-1$
- assertEquals(1, command.updatingModelCount(metadata));
- }
-
- /** case 3955 */
- @Test public void testCommandUpdatingCountVirtualUpdate() throws Exception{
- Command command = helpResolve("UPDATE vm1.g1 SET e2=667 WHERE e2=666"); //$NON-NLS-1$
- assertEquals(2, command.updatingModelCount(metadata));
- }
-
- /** case 3955 */
- @Test public void testCommandUpdatingCountPhysicalDelete() throws Exception{
- Command command = helpResolve("DELETE FROM pm1.g1 WHERE e2 = 666 "); //$NON-NLS-1$
- assertEquals(1, command.updatingModelCount(metadata));
- }
-
- /** case 3955 */
- @Test public void testCommandUpdatingCountVirtualDelete() throws Exception{
- Command command = helpResolve("DELETE FROM vm1.g37 WHERE e2 = 666 "); //$NON-NLS-1$
- assertEquals(2, command.updatingModelCount(metadata));
- }
-
- @Test public void testCommandUpdatingCountEmbeddedExecs() throws Exception {
- Command command = helpResolve("SELECT * FROM pm1.g1 WHERE e1 IN ((select e1 from (EXEC pm1.sp1()) x), (select e1 from (EXEC pm1.sp2(1)) x))"); //$NON-NLS-1$
-
- assertEquals(2, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
- }
-
- @Test public void testCommandUpdatingCountEmbeddedExec() throws Exception {
- Command command = helpResolve("SELECT * FROM pm1.g1 WHERE e1 IN (select e1 from (EXEC pm1.sp1()) x)"); //$NON-NLS-1$
-
- assertEquals(2, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
- }
-
- @Test public void testCommandUpdatingCountFromMetadata() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject proc = metadata.getStore().findObject("pm1.sp1", FakeMetadataObject.PROCEDURE); //$NON-NLS-1$
- proc.putProperty(FakeMetadataObject.Props.UPDATE_COUNT, new Integer(0));
-
- Command command = QueryParser.getQueryParser().parseCommand("EXEC pm1.sp1()"); //$NON-NLS-1$
- QueryResolver.resolveCommand(command, metadata);
- assertEquals(0, command.updatingModelCount(metadata));
-
- command = QueryParser.getQueryParser().parseCommand("select * from pm1.sp1"); //$NON-NLS-1$
- QueryResolver.resolveCommand(command, metadata);
- assertEquals(0, command.updatingModelCount(metadata));
-
- command = QueryParser.getQueryParser().parseCommand("select * from pm1.g1 where e1 in (select e1 from (exec pm1.sp1()) x)"); //$NON-NLS-1$
- QueryResolver.resolveCommand(command, metadata);
- assertEquals(0, command.updatingModelCount(metadata));
- }
-
@Test public void testParameterError() throws Exception {
helpResolveException("EXEC pm1.sp2(1, 2)", metadata, "Error Code:ERR.015.008.0007 Message:Incorrect number of parameters specified on the stored procedure pm1.sp2 - expected 1 but got 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestBatchedUpdateCommand.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestBatchedUpdateCommand.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestBatchedUpdateCommand.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -1,172 +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.query.sql.lang;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.query.metadata.BasicQueryMetadata;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-
-
-/**
- * @since 4.3
- */
-public class TestBatchedUpdateCommand extends TestCase{
- public TestBatchedUpdateCommand(String name) {
- super(name);
- }
-
- private Delete getDeleteCommand() {
- Delete delete = new Delete();
- GroupSymbol group = new GroupSymbol("m.g");//$NON-NLS-1$
- group.setMetadataID("g1"); //$NON-NLS-1$
- delete.setGroup(group);
- Option option = new Option();
- option.setShowPlan(true);
- delete.setOption(option);
- return delete;
- }
-
- private Insert getInsertCommand() {
- Insert insert = new Insert();
- GroupSymbol group = new GroupSymbol("m.g");//$NON-NLS-1$
- group.setMetadataID("g2"); //$NON-NLS-1$
- insert.setGroup(group);
- List vars = new ArrayList();
- vars.add(new ElementSymbol("a")); //$NON-NLS-1$
- insert.setVariables(vars);
- List values = new ArrayList();
- values.add(new Reference(0));
- insert.setValues(values);
- Option option = new Option();
- option.setShowPlan(true);
- insert.setOption(option);
- return insert;
- }
-
- private Update getUpdateCommand() {
- Update update = new Update();
- GroupSymbol group = new GroupSymbol("m.g");//$NON-NLS-1$
- group.setMetadataID("g3"); //$NON-NLS-1$
- update.setGroup(group);
- return update;
- }
-
- private Query getSelectCommand() {
- GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
- g.setMetadataID("2");//$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- AliasSymbol as = new AliasSymbol("myA", new ElementSymbol("a")); //$NON-NLS-1$ //$NON-NLS-2$
- Select select = new Select();
- select.addSymbol(as);
- select.addSymbol(new ElementSymbol("b")); //$NON-NLS-1$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- return query;
- }
-
- private Query getSelectIntoCommand() {
- GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
- Into into = new Into();
- into.setGroup(new GroupSymbol("intoGroup"));//$NON-NLS-1$
-
- AliasSymbol as = new AliasSymbol("myA", new ElementSymbol("a")); //$NON-NLS-1$ //$NON-NLS-2$
- Select select = new Select();
- select.addSymbol(as);
- select.addSymbol(new ElementSymbol("b")); //$NON-NLS-1$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
- query.setInto(into);
-
- return query;
- }
-
- class FakeMetadataInterface extends BasicQueryMetadata{
- public Object getModelID(Object groupID) {
- if("g1".equals(groupID)) {//$NON-NLS-1$
- return "1";//$NON-NLS-1$
- }
- if("g2".equals(groupID)) {//$NON-NLS-1$
- return "1";//$NON-NLS-1$
- }
- if("g3".equals(groupID)) {//$NON-NLS-1$
- return "2";//$NON-NLS-1$
- }
- return null;
- }
- }
-
- public void testBatchedUpdateCount1() throws Exception{
- ArrayList commands = new ArrayList();
- commands.add(getDeleteCommand());
- commands.add(getInsertCommand());
- BatchedUpdateCommand command = new BatchedUpdateCommand(commands);
- assertEquals(command.updatingModelCount(new FakeMetadataInterface()), 1);
- }
-
- public void testBatchedUpdateCount2() throws Exception {
- ArrayList commands = new ArrayList();
- commands.add(getDeleteCommand());
- commands.add(getSelectCommand());
- BatchedUpdateCommand command = new BatchedUpdateCommand(commands);
- assertEquals(command.updatingModelCount(new FakeMetadataInterface()), 1);
- }
-
- public void testBatchedUpdateCount3() throws Exception {
- ArrayList commands = new ArrayList();
- commands.add(getInsertCommand());
- commands.add(getSelectCommand());
- BatchedUpdateCommand command = new BatchedUpdateCommand(commands);
- assertEquals(command.updatingModelCount(new FakeMetadataInterface()), 1);
- }
-
- public void testBatchedUpdateCount4() throws Exception {
- ArrayList commands = new ArrayList();
- commands.add(getSelectIntoCommand());
- BatchedUpdateCommand command = new BatchedUpdateCommand(commands);
- assertEquals(command.updatingModelCount(new FakeMetadataInterface()), 2);
- }
-
- public void testBatchedUpdateCount5() throws Exception{
- ArrayList commands = new ArrayList();
- commands.add(getDeleteCommand());
- commands.add(getUpdateCommand());
- BatchedUpdateCommand command = new BatchedUpdateCommand(commands);
- assertEquals(command.updatingModelCount(new FakeMetadataInterface()), 2);
- }
-}
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,10 +22,10 @@
package com.metamatrix.query.sql.symbol;
+import junit.framework.TestCase;
+
import org.teiid.connector.language.SQLReservedWords;
-import junit.framework.TestCase;
-
import com.metamatrix.core.util.UnitTestUtil;
public class TestAggregateSymbol extends TestCase {
Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -41,7 +41,6 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.vdb.ModelType;
import com.metamatrix.dqp.message.ParameterInfo;
-import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingAttribute;
import com.metamatrix.query.mapping.xml.MappingDocument;
Copied: trunk/engine/src/test/java/com/metamatrix/query/util (from rev 1965, trunk/engine/src/test/java/com/metamatrix/common/util)
Modified: trunk/engine/src/test/java/com/metamatrix/query/util/TestPermutation.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/util/TestPermutation.java 2010-03-15 21:54:11 UTC (rev 1965)
+++ trunk/engine/src/test/java/com/metamatrix/query/util/TestPermutation.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -20,13 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.common.util;
+package com.metamatrix.query.util;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
+import com.metamatrix.query.util.Permutation;
+
import junit.framework.TestCase;
/**
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -29,6 +29,7 @@
import javax.transaction.xa.Xid;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorEnvironment;
@@ -124,7 +125,7 @@
assertEquals(1, results.getWarnings().size());
}
-
+ @Ignore
@Test public void testIsImmutablePropertySucceeds() throws Exception {
/*
* Setup:
@@ -152,6 +153,7 @@
new ConnectorWorkItem(requestMsg, cm);
}
+ @Ignore
@Test(expected=ConnectorException.class) public void testIsImmutablePropertyFails() throws Exception {
/*
* Setup:
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -32,6 +32,7 @@
import org.mockito.Mockito;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryParserException;
@@ -52,7 +53,6 @@
import com.metamatrix.query.processor.FakeDataManager;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -246,18 +246,12 @@
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
workContext.getSession().setSessionId(conn);
- PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache) {
- @Override
- protected void createProcessor(Command processingCommand)
- throws MetaMatrixComponentException {
-
- }
- };
+ PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache);
ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
- serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, null, null, DEBUG, null, workContext, 101024,repo);
+ serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), null, DEBUG, null, workContext, 101024,repo);
serverRequest.setMetadata(capFinder, metadata, null);
serverRequest.processRequest();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -23,9 +23,7 @@
package org.teiid.dqp.internal.process;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
-import java.util.List;
import junit.framework.TestCase;
@@ -47,9 +45,7 @@
import com.metamatrix.query.processor.FakeDataManager;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
import com.metamatrix.query.util.ContextProperties;
@@ -68,19 +64,6 @@
super(name);
}
- public void testGetSchemasForValidation() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject doc1 = metadata.getStore().findObject("xmltest.doc1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- List<String> schemas = Arrays.asList("a.xsd", "b.xsd"); //$NON-NLS-1$ //$NON-NLS-2$
- doc1.putProperty(FakeMetadataObject.Props.XML_SCHEMAS, schemas);
- RequestMessage message = new RequestMessage("select * from xmltest.doc1"); //$NON-NLS-1$
- message.setValidationMode(true);
- DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
- Request request = helpProcessMessage(message, null, workContext);
- assertEquals(schemas, request.schemas);
- }
-
-
/**
* Test Request.validateEntitlement().
* Make sure that this can be called both before and after metadata is initialized.
Modified: trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -35,7 +35,6 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.common.types.DataTypeManager;
@@ -61,7 +60,6 @@
vdb.addModel(buildModel("x1"));
TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null);
- DQPWorkContext context = FakeMetadataFactory.buildWorkContext(tm, vdb);
try {
tm.getStoredProcedureInfoForProcedure("y"); //$NON-NLS-1$
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -68,8 +68,8 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.client.ExceptionUtil;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.client.DQP;
@@ -114,14 +114,14 @@
}
public void start() {
- dqpCore.setTransactionService((TransactionService)LogManager.createLoggingProxy(com.metamatrix.common.util.LogConstants.CTX_TXN_LOG, transactionServerImpl, new Class[] {TransactionService.class}, MessageLevel.DETAIL));
+ dqpCore.setTransactionService((TransactionService)LogManager.createLoggingProxy(com.metamatrix.common.log.LogConstants.CTX_TXN_LOG, transactionServerImpl, new Class[] {TransactionService.class}, MessageLevel.DETAIL));
// create the necessary services
createClientServices();
- this.csr.registerClientService(ILogon.class, logon, com.metamatrix.common.util.LogConstants.CTX_SESSION);
- this.csr.registerClientService(DQP.class, proxyService(DQP.class, this.dqpCore), com.metamatrix.common.util.LogConstants.CTX_DQP);
- this.csr.registerClientService(Admin.class, proxyService(Admin.class, admin), com.metamatrix.common.util.LogConstants.CTX_ADMIN_API);
+ this.csr.registerClientService(ILogon.class, logon, com.metamatrix.common.log.LogConstants.CTX_SESSION);
+ this.csr.registerClientService(DQP.class, proxyService(DQP.class, this.dqpCore), com.metamatrix.common.log.LogConstants.CTX_DQP);
+ this.csr.registerClientService(Admin.class, proxyService(Admin.class, admin), com.metamatrix.common.log.LogConstants.CTX_ADMIN_API);
if (this.jdbcSocketConfiguration.isEnabled()) {
this.jdbcSocket = new SocketTransport(this.jdbcSocketConfiguration, csr);
@@ -134,11 +134,11 @@
if (this.adminSocketConfiguration.isEnabled()) {
this.adminSocket = new SocketTransport(this.adminSocketConfiguration, csr);
this.adminSocket.start();
- LogManager.logInfo(com.metamatrix.common.util.LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid Admin", (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ LogManager.logInfo(com.metamatrix.common.log.LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid Admin", (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
} else {
- LogManager.logInfo(com.metamatrix.common.util.LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_not_enabled", "admin connections")); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logInfo(com.metamatrix.common.log.LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_not_enabled", "admin connections")); //$NON-NLS-1$ //$NON-NLS-2$
}
- LogManager.logInfo(com.metamatrix.common.util.LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("engine_started", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
+ LogManager.logInfo(com.metamatrix.common.log.LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("engine_started", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
}
public void stop() {
@@ -159,7 +159,7 @@
this.adminSocket.stop();
this.adminSocket = null;
}
- LogManager.logInfo(com.metamatrix.common.util.LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("engine_stopped", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
+ LogManager.logInfo(com.metamatrix.common.log.LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("engine_stopped", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
}
private void createClientServices() {
Modified: trunk/metadata/src/main/java/org/teiid/internal/core/index/Index.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/Index.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/Index.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -11,7 +11,6 @@
*******************************************************************************/
package org.teiid.internal.core.index;
-import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -73,13 +73,19 @@
this.store = new MetadataStore();
ArrayList<Index> tmp = new ArrayList<Index>();
for (VirtualFile f : indexFiles) {
- tmp.add( new Index(f, true) );
+ Index index = new Index(f, true);
+ index.setDoCache(true);
+ tmp.add(index);
}
this.indexes = tmp.toArray(new Index[tmp.size()]);
getDatatypeCache();
getModels();
getTables();
getProcedures();
+ //force close, since we cached the index files
+ for (Index index : tmp) {
+ index.close();
+ }
}
return store;
}
@@ -360,14 +366,6 @@
return patternStr;
}
- /**
- * @see com.metamatrix.modeler.core.index.IndexSelector#getIndexes()
- * @since 4.2
- */
- public synchronized Index[] getIndexes() {
- return this.indexes;
- }
-
/**
* Return all index file records that match the specified entity name
* @param indexName
@@ -492,10 +490,10 @@
private IEntryResult[] queryIndex(char recordType, final char[] pattern, boolean isPrefix, boolean isCaseSensitive, boolean returnFirstMatch) {
// The the index file name for the record type
final String indexName = SimpleIndexUtil.getIndexFileNameForRecordType(recordType);
- Index[] search = SimpleIndexUtil.getIndexes(indexName, this.getIndexes());
+ Index[] search = SimpleIndexUtil.getIndexes(indexName, this.indexes);
try {
- return SimpleIndexUtil.queryIndex(null, search, pattern, isPrefix, isCaseSensitive, returnFirstMatch);
+ return SimpleIndexUtil.queryIndex(search, pattern, isPrefix, isCaseSensitive, returnFirstMatch);
} catch (MetaMatrixCoreException e) {
throw new MetaMatrixRuntimeException(e);
}
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -22,7 +22,6 @@
package org.teiid.metadata.index;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -32,21 +31,12 @@
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.StringUtil;
/**
* IndexUtil
*/
public class SimpleIndexUtil {
- public static interface ProgressMonitor {
-
- public void beginTask(String name, int totalWork);
-
- public void worked(int work);
- }
-
//############################################################################################################################
//# Constants #
//############################################################################################################################
@@ -57,20 +47,6 @@
//# Indexing Methods #
//############################################################################################################################
- public static String getIndexFilePath(final String indexDirectoryPath, final String indexFileName) {
- StringBuffer sb = new StringBuffer(100);
- sb.append(indexDirectoryPath);
- if (!indexDirectoryPath.endsWith(File.separator)) {
- sb.append(File.separator);
- }
- sb.append(indexFileName);
- return sb.toString();
- }
-
- //############################################################################################################################
- //# Methods to query indexes #
- //############################################################################################################################
-
/**
* Return all index file records that match the specified record prefix
* or pattern. The pattern can be constructed from any combination of characters
@@ -84,19 +60,12 @@
* @return results
* @throws MetamatrixCoreException
*/
- public static IEntryResult[] queryIndex(ProgressMonitor monitor, final Index[] indexes, final char[] pattern, final boolean isPrefix, final boolean isCaseSensitive, final boolean returnFirstMatch) throws MetaMatrixCoreException {
+ public static IEntryResult[] queryIndex(final Index[] indexes, final char[] pattern, final boolean isPrefix, final boolean isCaseSensitive, final boolean returnFirstMatch) throws MetaMatrixCoreException {
final List<IEntryResult> queryResult = new ArrayList<IEntryResult>();
- if ( monitor != null ) {
- monitor.beginTask( null, indexes.length );
- }
try {
for (int i = 0; i < indexes.length; i++) {
- if ( monitor != null ) {
- monitor.worked( 1 );
- }
-
IEntryResult[] partialResults = null;
if(isPrefix) {
// Query based on prefix. This uses a fast binary search
@@ -178,68 +147,6 @@
//############################################################################################################################
/**
- * Return true if the specifed index file exists on the file system
- * otherwise return false.
- */
- public static boolean indexFileExists(final String indexFilePath) {
- if (indexFilePath == null) {
- return false;
- }
- String filePath = indexFilePath.replace(FileUtils.SEPARATOR, File.separatorChar);
- final File indexFile = new File(filePath);
- return indexFileExists(indexFile);
- }
-
- /**
- * Return true if the specifed index file exists on the file system
- * otherwise return false.
- */
- public static boolean indexFileExists(final File indexFile) {
- if ( !indexFile.isDirectory() && indexFile.exists() ) {
- return isIndexFile(indexFile.getName());
- }
- return false;
- }
-
- /**
- * Return true if the specifed index file represents a known index file
- * on the file system otherwise return false.
- */
- public static boolean isModelIndex(final String indexFileName) {
- if (!isIndexFile(indexFileName)) {
- return false;
- }
- return !IndexConstants.INDEX_NAME.isKnownIndex(indexFileName);
- }
-
- /**
- * Return true if the specifed index file represents a index file
- * on the file system otherwise return false.
- */
- public static boolean isIndexFile(final String indexFileName) {
- if (!StringUtil.isEmpty(indexFileName)) {
- String extension = FileUtils.getExtension(indexFileName);
- if(extension != null ) {
- if( extension.equals(IndexConstants.INDEX_EXT) || extension.equals(IndexConstants.SEARCH_INDEX_EXT)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Return true if the specifed index file represents a index file
- * on the file system otherwise return false.
- */
- public static boolean isIndexFile(final File indexFile) {
- if (indexFile != null && indexFile.isFile()) {
- return isIndexFile(indexFile.getName());
- }
- return false;
- }
-
- /**
* Return an array of indexes given a indexName.
* @param indexName The shortName of the index file
* @param selector The indexSelector to lookup indexes
@@ -298,48 +205,6 @@
case MetadataConstants.RECORD_TYPE.FILE: return IndexConstants.INDEX_NAME.FILES_INDEX;
}
throw new IllegalArgumentException("Unkown record type " + recordType);
- }
-
- /**
- * Return the name of the index file to use for the specified record type, applies only for sever and vdb
- * index files.
- * @param recordType
- * @return
- */
- public static String getRecordTypeForIndexFileName(final String indexName) {
- char recordType;
- if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.COLUMNS_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.COLUMN;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.TABLES_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.TABLE;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.MODELS_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.MODEL;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.DATATYPES_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.DATATYPE;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.VDBS_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.VDB_ARCHIVE;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.ANNOTATION_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.ANNOTATION;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.PROPERTIES_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.PROPERTY;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.SELECT_TRANSFORM_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.SELECT_TRANSFORM;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.INSERT_TRANSFORM_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.INSERT_TRANSFORM;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.UPDATE_TRANSFORM_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.UPDATE_TRANSFORM;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.DELETE_TRANSFORM_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.DELETE_TRANSFORM;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.PROC_TRANSFORM_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.PROC_TRANSFORM;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.MAPPING_TRANSFORM_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.MAPPING_TRANSFORM;
- } else if(indexName.equalsIgnoreCase(IndexConstants.INDEX_NAME.FILES_INDEX)) {
- recordType = MetadataConstants.RECORD_TYPE.FILE;
- } else {
- return null;
- }
- return StringUtil.Constants.EMPTY_STRING + recordType;
}
}
Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -28,7 +28,9 @@
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
@@ -73,6 +75,18 @@
}
});
+ List<VirtualFile> files = vdbFile.getChildrenRecursively(new VirtualFileFilter() {
+ @Override
+ public boolean accepts(VirtualFile file) {
+ return !file.getName().endsWith(IndexConstants.NAME_DELIM_CHAR+IndexConstants.INDEX_EXT);
+ }
+ });
+
+ Map<VirtualFile, Boolean> vdbFiles = new HashMap<VirtualFile, Boolean>();
+ for (VirtualFile virtualFile : files) {
+ vdbFiles.put(virtualFile, Boolean.TRUE);
+ }
+
IndexMetadataFactory imf = new IndexMetadataFactory();
for (VirtualFile f: children) {
imf.addIndexFile(f);
@@ -83,7 +97,7 @@
methods = FunctionMetadataReader.loadFunctionMethods(udfFile.openStream());
}
- vdbmetadata = new TransformationMetadata(null, new CompositeMetadataStore(Arrays.asList(imf.getMetadataStore())), null, methods);
+ vdbmetadata = new TransformationMetadata(null, new CompositeMetadataStore(Arrays.asList(imf.getMetadataStore())), vdbFiles, methods);
VDB_CACHE.put(vdbURL, vdbmetadata);
return vdbmetadata;
} catch (URISyntaxException e) {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -30,8 +30,8 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.CoreConstants;
public class DynamicVDBDeployer extends AbstractVFSParsingDeployer<VDBMetaData> {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -51,8 +51,8 @@
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.runtime.RuntimePlugin;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.query.function.metadata.FunctionMethod;
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -51,8 +51,8 @@
import org.teiid.runtime.RuntimePlugin;
import org.xml.sax.SAXException;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.core.vdb.VdbConstants;
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -37,9 +37,9 @@
import org.teiid.metadata.TransformationMetadata;
import org.teiid.runtime.RuntimePlugin;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.CoreConstants;
import com.metamatrix.vdb.runtime.VDBKey;
Modified: trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -98,24 +98,24 @@
public static Set<String> getContexts(){
HashSet<String> contexts = new HashSet<String>();
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_DQP);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_CONNECTOR);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_BUFFER_MGR);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_TXN_LOG);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_COMMANDLOGGING);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_AUDITLOGGING);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_SESSION);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_AUTHORIZATION);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_MEMBERSHIP);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_TRANSPORT);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_ADMIN_API);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_QUERY_PLANNER);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_RUNTIME);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_DQP);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_CONNECTOR);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_TXN_LOG);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_COMMANDLOGGING);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_AUDITLOGGING);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_SESSION);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_AUTHORIZATION);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_MEMBERSHIP);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_TRANSPORT);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_ADMIN_API);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_QUERY_PLANNER);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_RUNTIME);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_FUNCTION_TREE);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_QUERY_RESOLVER);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_XML_PLANNER);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_XML_PLAN);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_FUNCTION_TREE);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_QUERY_RESOLVER);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_XML_PLANNER);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_XML_PLAN);
contexts.add("com.arjuna"); //$NON-NLS-1$
contexts.add("org.jboss"); //$NON-NLS-1$
Modified: trunk/runtime/src/main/java/org/teiid/services/AuthorizationServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/AuthorizationServiceImpl.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/services/AuthorizationServiceImpl.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -136,7 +136,7 @@
SessionToken caller = getSession();
- LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_AUTHORIZATION, new Object[]{"getInaccessibleResources(", caller, ", ", contextName, ", ", requests, ")"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ LogManager.logDetail(com.metamatrix.common.log.LogConstants.CTX_AUTHORIZATION, new Object[]{"getInaccessibleResources(", caller, ", ", contextName, ", ", requests, ")"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
List<String> resources = new ArrayList<String>();
if (requests != null && ! requests.isEmpty()) {
@@ -148,7 +148,7 @@
// Audit - request
AuditMessage msg = new AuditMessage( contextName, "getInaccessibleResources-request", caller.getUsername(), resources.toArray(new String[resources.size()])); //$NON-NLS-1$
- LogManager.log(MessageLevel.INFO, com.metamatrix.common.util.LogConstants.CTX_AUDITLOGGING, msg);
+ LogManager.log(MessageLevel.INFO, com.metamatrix.common.log.LogConstants.CTX_AUDITLOGGING, msg);
if (isEntitled()){
return Collections.EMPTY_LIST;
@@ -173,10 +173,10 @@
if (results.isEmpty()) {
msg = new AuditMessage( contextName, "getInaccessibleResources-granted all", caller.getUsername(), resources.toArray(new String[resources.size()])); //$NON-NLS-1$
- LogManager.log(MessageLevel.INFO, com.metamatrix.common.util.LogConstants.CTX_AUDITLOGGING, msg);
+ LogManager.log(MessageLevel.INFO, com.metamatrix.common.log.LogConstants.CTX_AUDITLOGGING, msg);
} else {
msg = new AuditMessage( contextName, "getInaccessibleResources-denied", caller.getUsername(), resources.toArray(new String[resources.size()])); //$NON-NLS-1$
- LogManager.log(MessageLevel.INFO, com.metamatrix.common.util.LogConstants.CTX_AUDITLOGGING, msg);
+ LogManager.log(MessageLevel.INFO, com.metamatrix.common.log.LogConstants.CTX_AUDITLOGGING, msg);
}
return results;
}
@@ -386,7 +386,7 @@
protected boolean isEntitled(){
if (DQPWorkContext.getWorkContext().getSubject() == null) {
- LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_AUTHORIZATION,new Object[]{ "Automatically entitling principal", DQPWorkContext.getWorkContext().getSessionToken().getUsername()}); //$NON-NLS-1$
+ LogManager.logDetail(com.metamatrix.common.log.LogConstants.CTX_AUTHORIZATION,new Object[]{ "Automatically entitling principal", DQPWorkContext.getWorkContext().getSessionToken().getUsername()}); //$NON-NLS-1$
return true;
}
return false;
@@ -455,7 +455,7 @@
@Override
public boolean isCallerInRole(String roleName) throws AuthorizationMgmtException {
- LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_AUTHORIZATION, new Object[]{"isCallerInRole(", getSession(), roleName, ")"}); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_AUTHORIZATION, new Object[]{"isCallerInRole(", getSession(), roleName, ")"}); //$NON-NLS-1$ //$NON-NLS-2$
return hasPolicy(RolePermissionFactory.getRealm(), roleName);
}
Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -54,8 +54,8 @@
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.dqp.service.SessionService;
import com.metamatrix.platform.security.api.SessionToken;
Modified: trunk/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -42,8 +42,8 @@
import org.teiid.security.Credentials;
import org.teiid.security.SecurityHelper;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
/**
* This class serves as the primary implementation of the
Modified: trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -56,8 +56,8 @@
import com.metamatrix.common.comm.platform.CommPlatformPlugin;
import com.metamatrix.common.comm.platform.socket.ObjectChannel;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
/**
* Main class for creating Netty Nio Channels
Modified: trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -40,8 +40,8 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.comm.api.Message;
import com.metamatrix.common.comm.platform.socket.client.ServiceInvocationStruct;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.client.ResultsFuture;
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -33,8 +33,8 @@
import com.metamatrix.common.comm.platform.CommPlatformPlugin;
import com.metamatrix.common.comm.platform.socket.Handshake;
import com.metamatrix.common.comm.platform.socket.ObjectChannel;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.common.util.crypto.Cryptor;
import com.metamatrix.common.util.crypto.DhKeyGenerator;
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -33,9 +33,9 @@
import org.teiid.transport.ChannelListener.ChannelListenerFactory;
import com.metamatrix.common.comm.platform.socket.ObjectChannel;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.NamedThreadFactory;
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketTransport.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketTransport.java 2010-03-16 20:22:54 UTC (rev 1969)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketTransport.java 2010-03-16 21:23:22 UTC (rev 1970)
@@ -23,8 +23,8 @@
import org.teiid.runtime.RuntimePlugin;
+import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
/**
* This class starts a Socket for DQP connections and listens on the port and hands out the connections to the
14 years, 9 months
teiid SVN: r1969 - trunk/test-integration/db.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-03-16 16:22:54 -0400 (Tue, 16 Mar 2010)
New Revision: 1969
Modified:
trunk/test-integration/db/
Log:
adding svn.ignore to .classpath and .project
Property changes on: trunk/test-integration/db
___________________________________________________________________
Name: svn:ignore
- target
.settings
bin
+ target
.settings
bin
.project
.classpath
14 years, 9 months
teiid SVN: r1968 - trunk/test-integration/db.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-03-16 16:19:48 -0400 (Tue, 16 Mar 2010)
New Revision: 1968
Removed:
trunk/test-integration/db/.classpath
trunk/test-integration/db/.project
Log:
.class and .project files are not supported
Deleted: trunk/test-integration/db/.classpath
===================================================================
--- trunk/test-integration/db/.classpath 2010-03-16 19:05:16 UTC (rev 1967)
+++ trunk/test-integration/db/.classpath 2010-03-16 20:19:48 UTC (rev 1968)
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" path="resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
Deleted: trunk/test-integration/db/.project
===================================================================
--- trunk/test-integration/db/.project 2010-03-16 19:05:16 UTC (rev 1967)
+++ trunk/test-integration/db/.project 2010-03-16 20:19:48 UTC (rev 1968)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>db</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- </natures>
-</projectDescription>
14 years, 9 months