[teiid-commits] teiid SVN: r2116 - in trunk: connector-api/src/main/java/org/teiid/connector/metadata/runtime and 35 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue May 11 17:47:59 EDT 2010


Author: shawkins
Date: 2010-05-11 17:47:57 -0400 (Tue, 11 May 2010)
New Revision: 2116

Removed:
   trunk/engine/src/main/java/com/metamatrix/api/exception/query/
   trunk/engine/src/main/java/com/metamatrix/cache/Cache.java
   trunk/engine/src/main/java/com/metamatrix/cache/CacheConfiguration.java
   trunk/engine/src/main/java/com/metamatrix/cache/CacheFactory.java
   trunk/engine/src/main/java/com/metamatrix/cache/CacheListener.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/BlockedException.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/FileStore.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/IndexedTupleSource.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBatch.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleSource.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/
   trunk/engine/src/main/java/com/metamatrix/dqp/DQPPlugin.java
   trunk/engine/src/main/java/com/metamatrix/dqp/message/
   trunk/engine/src/main/java/com/metamatrix/dqp/service/
   trunk/engine/src/main/java/com/metamatrix/internal/core/xml/
   trunk/engine/src/main/java/com/metamatrix/query/QueryPlugin.java
   trunk/engine/src/main/java/com/metamatrix/query/analysis/
   trunk/engine/src/main/java/com/metamatrix/query/eval/
   trunk/engine/src/main/java/com/metamatrix/query/execution/
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java
   trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java
   trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java
   trunk/engine/src/main/java/com/metamatrix/query/function/aggregate/
   trunk/engine/src/main/java/com/metamatrix/query/function/metadata/
   trunk/engine/src/main/java/com/metamatrix/query/function/source/
   trunk/engine/src/main/java/com/metamatrix/query/mapping/relational/
   trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/
   trunk/engine/src/main/java/com/metamatrix/query/metadata/
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandPlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/QueryOptimizer.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/OptimizerRule.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RuleStack.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xquery/
   trunk/engine/src/main/java/com/metamatrix/query/parser/
   trunk/engine/src/main/java/com/metamatrix/query/processor/BatchCollector.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/BatchIterator.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/CollectionTupleSource.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorDataManager.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/TempTableDataManager.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/batch/
   trunk/engine/src/main/java/com/metamatrix/query/processor/proc/
   trunk/engine/src/main/java/com/metamatrix/query/processor/program/
   trunk/engine/src/main/java/com/metamatrix/query/processor/relational/
   trunk/engine/src/main/java/com/metamatrix/query/processor/xml/
   trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/
   trunk/engine/src/main/java/com/metamatrix/query/report/
   trunk/engine/src/main/java/com/metamatrix/query/resolver/CommandResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/VariableResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/
   trunk/engine/src/main/java/com/metamatrix/query/resolver/util/
   trunk/engine/src/main/java/com/metamatrix/query/rewriter/
   trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageObject.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageVisitor.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/
   trunk/engine/src/main/java/com/metamatrix/query/sql/navigator/
   trunk/engine/src/main/java/com/metamatrix/query/sql/proc/
   trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/
   trunk/engine/src/main/java/com/metamatrix/query/sql/util/
   trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/
   trunk/engine/src/main/java/com/metamatrix/query/tempdata/
   trunk/engine/src/main/java/com/metamatrix/query/util/
   trunk/engine/src/main/java/com/metamatrix/query/validator/
Modified:
   trunk/connector-api/src/main/java/org/teiid/connector/DataPlugin.java
   trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
   trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
   trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
   trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecutionFactory.java
   trunk/connector-api/src/main/java/org/teiid/resource/cci/DataNotAvailableException.java
   trunk/connector-api/src/main/java/org/teiid/resource/cci/TypeFacility.java
   trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java
   trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/ldap/LDAPPlugin.java
   trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesForceManagedConnectionFactory.java
   trunk/connectors/connector-text/src/main/java/org/teiid/resource/adapter/file/FileConnectionImpl.java
   trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooPlugin.java
   trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionFactory.java
   trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCMetdataProcessor.java
   trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java
   trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeConnection.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TranslationHelper.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestEscapeSyntaxModifier.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
   trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPPlugin.java
   trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestIQueryToLdapSearchParser.java
   trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/MetadataProcessor.java
   trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForcePlugin.java
   trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors/TestVisitors.java
   trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextConnectionImpl.java
   trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextPlugin.java
   trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestMultiFileTextSynchExecution.java
   trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnector.java
   trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextSynchExecution.java
   trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/Util.java
Log:
TEIID-918 changing package to org.teiid and removing metamatrix from class names

Modified: trunk/connector-api/src/main/java/org/teiid/connector/DataPlugin.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/DataPlugin.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connector-api/src/main/java/org/teiid/connector/DataPlugin.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -23,8 +23,9 @@
 package org.teiid.connector;
 
 import java.util.ResourceBundle;
-import com.metamatrix.core.BundleUtil;
 
+import org.teiid.core.BundleUtil;
+
 public class DataPlugin { // extends Plugin {
 
     public static final String PLUGIN_ID = "org.teiid.connector" ; //$NON-NLS-1$

Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -28,8 +28,9 @@
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
 
-import com.metamatrix.core.util.EquivalenceUtil;
+import org.teiid.core.util.EquivalenceUtil;
 
+
 /**
  * AbstractMetadataRecord
  */

Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -29,10 +29,10 @@
 import java.util.Properties;
 
 import org.teiid.connector.DataPlugin;
+import org.teiid.core.id.UUIDFactory;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.cci.TypeFacility;
 
-import com.metamatrix.core.id.UUIDFactory;
 
 /**
  * Allows connectors to build metadata for use by the engine.

Modified: trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -72,9 +72,9 @@
 import org.teiid.connector.language.SortSpecification.Ordering;
 import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
 import org.teiid.connector.visitor.framework.AbstractLanguageVisitor;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.StringUtil;
 
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.StringUtil;
 
 /**
  * Creates a SQL string for a LanguageObject subtree. Instances of this class

Modified: trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecutionFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecutionFactory.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecutionFactory.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -12,6 +12,9 @@
 import org.teiid.connector.language.LanguageFactory;
 import org.teiid.connector.language.QueryExpression;
 import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.core.TeiidException;
+import org.teiid.core.util.ReflectionHelper;
+import org.teiid.core.util.StringUtil;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.cci.ConnectorCapabilities;
 import org.teiid.resource.cci.Execution;
@@ -23,9 +26,6 @@
 import org.teiid.resource.cci.UpdateExecution;
 import org.teiid.resource.spi.BasicManagedConnectionFactory;
 
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.core.util.StringUtil;
 
 public class BasicExecutionFactory implements ExecutionFactory {
 
@@ -122,7 +122,7 @@
 	    		return expectedType.cast(defaultClass.newInstance());
 	    	}
 	    	return expectedType.cast(ReflectionHelper.create(className, ctorObjs, Thread.currentThread().getContextClassLoader()));
-		} catch (MetaMatrixCoreException e) {
+		} catch (TeiidException e) {
 			throw new ConnectorException(e);
 		} catch (IllegalAccessException e) {
 			throw new ConnectorException(e);

Modified: trunk/connector-api/src/main/java/org/teiid/resource/cci/DataNotAvailableException.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/DataNotAvailableException.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connector-api/src/main/java/org/teiid/resource/cci/DataNotAvailableException.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -21,13 +21,13 @@
  */
 package org.teiid.resource.cci;
 
-import com.metamatrix.core.MetaMatrixRuntimeException;
+import org.teiid.core.TeiidRuntimeException;
 
 /**
  * Used by asynch connectors to indicate data is not available 
  * and results should be polled for after the given delay.
  */
-public class DataNotAvailableException extends MetaMatrixRuntimeException {
+public class DataNotAvailableException extends TeiidRuntimeException {
 
 	private static final long serialVersionUID = 5569111182915674334L;
 

Modified: trunk/connector-api/src/main/java/org/teiid/resource/cci/TypeFacility.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/TypeFacility.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connector-api/src/main/java/org/teiid/resource/cci/TypeFacility.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -26,10 +26,11 @@
 import java.util.Date;
 import java.util.TimeZone;
 
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.JDBCSQLTypeInfo;
-import com.metamatrix.common.util.TimestampWithTimezone;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.JDBCSQLTypeInfo;
+import org.teiid.core.util.TimestampWithTimezone;
 
+
 /**
  */
 public class TypeFacility {

Modified: trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -36,10 +36,10 @@
 import javax.resource.spi.ValidatingManagedConnectionFactory;
 import javax.security.auth.Subject;
 
+import org.teiid.core.TeiidException;
+import org.teiid.core.util.ReflectionHelper;
 import org.teiid.resource.ConnectorException;
 
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ReflectionHelper;
 
 public abstract class BasicManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation, ValidatingManagedConnectionFactory {
 
@@ -95,7 +95,7 @@
 	    		return expectedType.cast(defaultClass.newInstance());
 	    	}
 	    	return expectedType.cast(ReflectionHelper.create(className, ctorObjs, Thread.currentThread().getContextClassLoader()));
-		} catch (MetaMatrixCoreException e) {
+		} catch (TeiidException e) {
 			throw new ConnectorException(e);
 		} catch (IllegalAccessException e) {
 			throw new ConnectorException(e);

Modified: trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/ldap/LDAPPlugin.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/ldap/LDAPPlugin.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/ldap/LDAPPlugin.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -23,8 +23,9 @@
 
 import java.util.ResourceBundle;
 
-import com.metamatrix.core.BundleUtil;
+import org.teiid.core.BundleUtil;
 
+
 /**
  * LDAPPlugin
  */

Modified: trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesForceManagedConnectionFactory.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesForceManagedConnectionFactory.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesForceManagedConnectionFactory.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -26,10 +26,10 @@
 
 import javax.resource.ResourceException;
 
+import org.teiid.core.TeiidRuntimeException;
 import org.teiid.resource.spi.BasicConnectionFactory;
 import org.teiid.resource.spi.BasicManagedConnectionFactory;
 
-import com.metamatrix.core.MetaMatrixRuntimeException;
 
 public class SalesForceManagedConnectionFactory extends BasicManagedConnectionFactory {
 	private static final long serialVersionUID = 5298591275313314698L;
@@ -47,7 +47,7 @@
 	}
 	public void setUsername(String username) {
 		if (username.trim().length() == 0) {
-			throw new MetaMatrixRuntimeException("Name can not be null");
+			throw new TeiidRuntimeException("Name can not be null");
 		}
 		this.username = username;
 	}
@@ -71,7 +71,7 @@
 		try {
 			this.URL = new URL(uRL);
 		} catch (MalformedURLException e) {
-			throw new MetaMatrixRuntimeException("URL Supplied is not valid URL"+ e.getMessage());
+			throw new TeiidRuntimeException("URL Supplied is not valid URL"+ e.getMessage());
 		}
 	}
 	

Modified: trunk/connectors/connector-text/src/main/java/org/teiid/resource/adapter/file/FileConnectionImpl.java
===================================================================
--- trunk/connectors/connector-text/src/main/java/org/teiid/resource/adapter/file/FileConnectionImpl.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/connector-text/src/main/java/org/teiid/resource/adapter/file/FileConnectionImpl.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -26,10 +26,10 @@
 
 import javax.resource.ResourceException;
 
+import org.teiid.core.util.FileUtils;
 import org.teiid.resource.adapter.FileConnection;
 import org.teiid.resource.spi.BasicConnection;
 
-import com.metamatrix.core.util.FileUtils;
 
 /**
  * TODO: consider using VFS 

Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooPlugin.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooPlugin.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooPlugin.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -23,9 +23,10 @@
 package org.teiid.resource.adapter.yahoo;
 
 import java.util.ResourceBundle;
-import com.metamatrix.core.BundleUtil;
 
+import org.teiid.core.BundleUtil;
 
+
 public class YahooPlugin { 
     public static final String PLUGIN_ID = "org.teiid.resource.adapter.yahoo" ; //$NON-NLS-1$
 	public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$

Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionFactory.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionFactory.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -32,6 +32,10 @@
 import org.teiid.connector.language.QueryExpression;
 import org.teiid.connector.metadata.runtime.MetadataFactory;
 import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.core.TeiidException;
+import org.teiid.core.util.PropertiesUtils;
+import org.teiid.core.util.ReflectionHelper;
+import org.teiid.core.util.StringUtil;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.adapter.BasicExecutionFactory;
 import org.teiid.resource.cci.ConnectorCapabilities;
@@ -43,10 +47,6 @@
 import org.teiid.resource.cci.UpdateExecution;
 import org.teiid.translator.jdbc.Translator;
 
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.core.util.StringUtil;
 
 /**
  * JDBC implementation of Connector interface.
@@ -78,7 +78,7 @@
 	        		this.sqlTranslator = (Translator)ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader());
 	        	}
 	            sqlTranslator.initialize(this);
-	        } catch (MetaMatrixCoreException e) {
+	        } catch (TeiidException e) {
 	            throw new ConnectorException(e);
 			}
 		}

Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCMetdataProcessor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCMetdataProcessor.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCMetdataProcessor.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -42,12 +42,12 @@
 import org.teiid.connector.metadata.runtime.Table;
 import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
 import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
+import org.teiid.core.util.StringUtil;
 import org.teiid.logging.LogManager;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.cci.TypeFacility;
 import org.teiid.translator.jdbc.JDBCPlugin;
 
-import com.metamatrix.core.util.StringUtil;
 
 /**
  * Reads from {@link DatabaseMetaData} and creates metadata through the {@link MetadataFactory}.

Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -25,9 +25,10 @@
 package org.teiid.translator.jdbc;
 
 import java.util.ResourceBundle;
-import com.metamatrix.core.BundleUtil;
 
+import org.teiid.core.BundleUtil;
 
+
 public class JDBCPlugin { 
 
     public static final String PLUGIN_ID = "org.teiid.translator.jdbc" ; //$NON-NLS-1$

Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -52,6 +52,7 @@
 import org.teiid.connector.language.Literal;
 import org.teiid.connector.language.SetQuery;
 import org.teiid.connector.language.Argument.Direction;
+import org.teiid.core.util.ReflectionHelper;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.resource.ConnectorException;
@@ -62,7 +63,6 @@
 import org.teiid.resource.cci.SourceSystemFunctions;
 import org.teiid.resource.cci.TypeFacility;
 
-import com.metamatrix.core.util.ReflectionHelper;
 
 /**
  * Base class for creating source SQL queries and retrieving results.

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeConnection.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeConnection.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeConnection.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -25,8 +25,9 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import com.metamatrix.core.util.SimpleMock;
+import org.teiid.core.util.SimpleMock;
 
+
 /**
  * FakeConnection for unit testing
  */

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TranslationHelper.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TranslationHelper.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TranslationHelper.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -31,6 +31,9 @@
 
 import org.mockito.Mockito;
 import org.teiid.connector.language.Command;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.function.metadata.FunctionMetadataReader;
+import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.cci.ExecutionContext;
 import org.teiid.translator.jdbc.TranslatedCommand;
@@ -38,9 +41,6 @@
 
 import com.metamatrix.cdk.api.TranslationUtility;
 import com.metamatrix.cdk.unittest.FakeTranslationFactory;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.function.metadata.FunctionMetadataReader;
-import com.metamatrix.query.function.metadata.FunctionMethod;
 
 public class TranslationHelper {
 	
@@ -66,7 +66,7 @@
 				Collection <FunctionMethod> methods = FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream());
 				util.setUDF(methods);
 			} catch (IOException e) {
-				throw new MetaMatrixRuntimeException("failed to load UDF"); //$NON-NLS-1$
+				throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
 			}
     	}
         return util.parseCommand(sql);        

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestEscapeSyntaxModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestEscapeSyntaxModifier.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestEscapeSyntaxModifier.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -26,15 +26,15 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.teiid.cdk.CommandBuilder;
 import org.teiid.connector.language.Function;
 import org.teiid.connector.language.Literal;
 import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.query.unittest.TimestampUtil;
 import org.teiid.translator.jdbc.EscapeSyntaxModifier;
 
 import junit.framework.TestCase;
 
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.query.unittest.TimestampUtil;
 
 /**
  */

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -33,6 +33,7 @@
 import org.teiid.connector.language.LanguageFactory;
 import org.teiid.connector.language.Literal;
 import org.teiid.connector.language.NamedTable;
+import org.teiid.query.unittest.TimestampUtil;
 import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
 import org.teiid.resource.cci.SourceSystemFunctions;
 import org.teiid.resource.cci.TypeFacility;
@@ -40,7 +41,6 @@
 import org.teiid.translator.jdbc.SQLConversionVisitor;
 import org.teiid.translator.jdbc.Translator;
 
-import com.metamatrix.query.unittest.TimestampUtil;
 
 /**
  */

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -32,12 +32,12 @@
 import org.teiid.connector.language.Expression;
 import org.teiid.connector.language.Function;
 import org.teiid.connector.language.LanguageFactory;
+import org.teiid.query.unittest.TimestampUtil;
 import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
 import org.teiid.resource.cci.TypeFacility;
 import org.teiid.translator.jdbc.SQLConversionVisitor;
 import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
 
-import com.metamatrix.query.unittest.TimestampUtil;
 
 /**
  */

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -28,6 +28,7 @@
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.teiid.connector.language.Command;
+import org.teiid.core.util.UnitTestUtil;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
 import org.teiid.resource.adapter.jdbc.TranslationHelper;
@@ -37,7 +38,6 @@
 
 import com.metamatrix.cdk.api.TranslationUtility;
 import com.metamatrix.cdk.unittest.FakeTranslationFactory;
-import com.metamatrix.core.util.UnitTestUtil;
 
 /**
  */

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -30,12 +30,12 @@
 import org.teiid.connector.language.Function;
 import org.teiid.connector.language.LanguageFactory;
 import org.teiid.connector.language.Literal;
+import org.teiid.query.unittest.TimestampUtil;
 import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
 import org.teiid.resource.cci.SourceSystemFunctions;
 import org.teiid.translator.jdbc.SQLConversionVisitor;
 import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
 
-import com.metamatrix.query.unittest.TimestampUtil;
 
 /**
  */

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -30,11 +30,11 @@
 import org.teiid.connector.language.Function;
 import org.teiid.connector.language.LanguageFactory;
 import org.teiid.connector.language.Literal;
+import org.teiid.query.unittest.TimestampUtil;
 import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
 import org.teiid.translator.jdbc.SQLConversionVisitor;
 import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
 
-import com.metamatrix.query.unittest.TimestampUtil;
 
 /**
  */

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -34,13 +34,13 @@
 import org.teiid.connector.language.Expression;
 import org.teiid.connector.language.Function;
 import org.teiid.connector.language.LanguageFactory;
+import org.teiid.query.unittest.TimestampUtil;
 import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
 import org.teiid.resource.cci.TypeFacility;
 import org.teiid.translator.jdbc.SQLConversionVisitor;
 import org.teiid.translator.jdbc.Translator;
 import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
 
-import com.metamatrix.query.unittest.TimestampUtil;
 
 /**
  */

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -28,15 +28,21 @@
 
 import org.junit.Before;
 import org.junit.Test;
+import org.teiid.cdk.CommandBuilder;
 import org.teiid.connector.language.Command;
 import org.teiid.connector.metadata.runtime.Column;
 import org.teiid.connector.metadata.runtime.MetadataStore;
 import org.teiid.connector.metadata.runtime.Schema;
 import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.UnitTestUtil;
 import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
 import org.teiid.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
 import org.teiid.metadata.CompositeMetadataStore;
 import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.RealMetadataFactory;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
 import org.teiid.resource.adapter.jdbc.TranslationHelper;
@@ -45,13 +51,7 @@
 import org.teiid.translator.jdbc.Translator;
 import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
 
-import com.metamatrix.cdk.CommandBuilder;
 import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.RealMetadataFactory;
 
 public class TestOracleTranslator {
 	

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -31,17 +31,17 @@
 import org.teiid.connector.metadata.runtime.MetadataStore;
 import org.teiid.connector.metadata.runtime.Schema;
 import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.core.types.DataTypeManager;
 import org.teiid.metadata.CompositeMetadataStore;
 import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.unittest.RealMetadataFactory;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
 import org.teiid.resource.adapter.jdbc.TranslationHelper;
 import org.teiid.translator.jdbc.sqlserver.SQLServerSQLTranslator;
 
 import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.RealMetadataFactory;
 
 /**
  */

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -34,13 +34,13 @@
 import org.teiid.connector.language.Function;
 import org.teiid.connector.language.LanguageFactory;
 import org.teiid.connector.language.Literal;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.unittest.TimestampUtil;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
 import org.teiid.translator.jdbc.SQLConversionVisitor;
 import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
 
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.unittest.TimestampUtil;
 
 /**
  */

Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPPlugin.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPPlugin.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPPlugin.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -23,8 +23,9 @@
 
 import java.util.ResourceBundle;
 
-import com.metamatrix.core.BundleUtil;
+import org.teiid.core.BundleUtil;
 
+
 /**
  * LDAPPlugin
  */

Modified: trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestIQueryToLdapSearchParser.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestIQueryToLdapSearchParser.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -33,6 +33,7 @@
 
 import junit.framework.TestCase;
 
+import org.teiid.cdk.CommandBuilder;
 import org.teiid.connector.language.Command;
 import org.teiid.connector.language.Select;
 import org.teiid.connector.metadata.runtime.Column;
@@ -41,18 +42,17 @@
 import org.teiid.connector.metadata.runtime.Schema;
 import org.teiid.connector.metadata.runtime.Table;
 import org.teiid.connector.metadata.runtime.Column.SearchType;
+import org.teiid.core.types.DataTypeManager;
 import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
 import org.teiid.metadata.CompositeMetadataStore;
 import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.unittest.RealMetadataFactory;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.adapter.ldap.IQueryToLdapSearchParser;
 import org.teiid.resource.adapter.ldap.LDAPExecutionFactory;
 import org.teiid.resource.adapter.ldap.LDAPSearchDetails;
 
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.RealMetadataFactory;
 
 /** 
  * Test IQueryToLdapSearchParser.  

Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/MetadataProcessor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/MetadataProcessor.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/MetadataProcessor.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -12,11 +12,11 @@
 import org.teiid.connector.metadata.runtime.Table;
 import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
 import org.teiid.connector.metadata.runtime.Column.SearchType;
+import org.teiid.core.types.DataTypeManager;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.resource.ConnectorException;
 
-import com.metamatrix.common.types.DataTypeManager;
 import com.sforce.soap.partner.ChildRelationship;
 import com.sforce.soap.partner.DescribeGlobalResult;
 import com.sforce.soap.partner.DescribeGlobalSObjectResult;

Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForcePlugin.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForcePlugin.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForcePlugin.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -23,8 +23,9 @@
 
 import java.util.ResourceBundle;
 
-import com.metamatrix.core.BundleUtil;
+import org.teiid.core.BundleUtil;
 
+
 /**
  * For logging purposes
  */

Modified: trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors/TestVisitors.java
===================================================================
--- trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors/TestVisitors.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors/TestVisitors.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -33,15 +33,15 @@
 import org.teiid.connector.metadata.runtime.Schema;
 import org.teiid.connector.metadata.runtime.Table;
 import org.teiid.connector.metadata.runtime.Column.SearchType;
+import org.teiid.core.types.DataTypeManager;
 import org.teiid.metadata.CompositeMetadataStore;
 import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.unittest.RealMetadataFactory;
 import org.teiid.resource.adapter.salesforce.execution.visitors.JoinQueryVisitor;
 import org.teiid.resource.adapter.salesforce.execution.visitors.SelectVisitor;
 
 import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.RealMetadataFactory;
 
 public class TestVisitors {
 

Modified: trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextConnectionImpl.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextConnectionImpl.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextConnectionImpl.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -38,12 +38,12 @@
 import java.util.Map;
 import java.util.Properties;
 
+import org.teiid.core.util.StringUtil;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.resource.ConnectorException;
 import org.teiid.resource.adapter.FileConnection;
 
-import com.metamatrix.core.util.StringUtil;
 
 
 /**

Modified: trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextPlugin.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextPlugin.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextPlugin.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -23,8 +23,9 @@
 package org.teiid.resource.adapter.text;
 
 import java.util.ResourceBundle;
-import com.metamatrix.core.BundleUtil;
 
+import org.teiid.core.BundleUtil;
+
 public class TextPlugin { 
 
     public static final String PLUGIN_ID = "org.teiid.resource.adapter.text" ; //$NON-NLS-1$

Modified: trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestMultiFileTextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestMultiFileTextSynchExecution.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestMultiFileTextSynchExecution.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -29,10 +29,10 @@
 
 import junit.framework.TestCase;
 
+import org.teiid.query.unittest.TimestampUtil;
 import org.teiid.resource.ConnectorException;
 
 import com.metamatrix.cdk.api.ConnectorHost;
-import com.metamatrix.query.unittest.TimestampUtil;
 
 public class TestMultiFileTextSynchExecution extends TestCase {
 	private static final String BAD_COUNT_FILE = "MultiParts/columCntMissMatchOption/testMultiDescriptorDelimited.txt"; //$NON-NLS-1$

Modified: trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnector.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnector.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnector.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -32,9 +32,9 @@
 import org.teiid.connector.metadata.runtime.Datatype;
 import org.teiid.connector.metadata.runtime.MetadataFactory;
 import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.core.types.DataTypeManager;
 import org.teiid.resource.cci.MetadataProvider;
 
-import com.metamatrix.common.types.DataTypeManager;
 
 /**
  */

Modified: trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextSynchExecution.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextSynchExecution.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -25,10 +25,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.teiid.query.unittest.TimestampUtil;
+
 import junit.framework.TestCase;
 
 import com.metamatrix.cdk.api.ConnectorHost;
-import com.metamatrix.query.unittest.TimestampUtil;
 
 /**
  * TODO: test cancel

Modified: trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/Util.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/Util.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/Util.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -36,17 +36,17 @@
 import org.teiid.connector.metadata.runtime.MetadataStore;
 import org.teiid.connector.metadata.runtime.Schema;
 import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.FileUtils;
+import org.teiid.core.util.UnitTestUtil;
 import org.teiid.metadata.CompositeMetadataStore;
 import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.unittest.RealMetadataFactory;
 import org.teiid.resource.adapter.FileConnection;
 
 import com.metamatrix.cdk.api.ConnectorHost;
 import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.RealMetadataFactory;
 
 @SuppressWarnings("nls")
 public class Util {

Deleted: trunk/engine/src/main/java/com/metamatrix/cache/Cache.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/cache/Cache.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/cache/Cache.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,160 +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.cache;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-
-/**
- * Abstraction over cache providers
- */
-public interface Cache<K, V>  {
-	
-	public enum Type {  REGISTRY("Registry"), //$NON-NLS-1$ 
-						SESSION("Session"), //$NON-NLS-1$ 
-						SESSION_MONITOR("Session-Monitor"), //$NON-NLS-1$ 
-						AUTHORIZATION_POLICY("Authorization-Policy"), //$NON-NLS-1$ 
-						AUTHORIZATION_PRINCIPAL("Auhtorization-Principal"), //$NON-NLS-1$ 
-						RESULTSET("ResultSet"), //$NON-NLS-1$
-						VDBMETADATA("VdbMetadata"), //$NON-NLS-1$
-						VDBMODELS("VdbModels"), //$NON-NLS-1$
-						SCOPED_CACHE("Scoped-Cache"); //$NON-NLS-1$
-		
-		private String location;
-		
-		Type(String location){
-			this.location = location;
-		}
-		
-		public String location() {
-			return this.location;
-		}
-	}
-	
-   /**
-    * Retrieves the value for the given Key 
-    *
-    * @param key key under which value is to be retrieved.
-    * @return returns data held under specified key in cache
-    */
-	V get(K key);
-	
-   /**
-    * Associates the specified value with the specified key this cache.
-    * If the cache previously contained a mapping for this key, the old value is replaced by the specified value.
-    *
-    * @param key   key with which the specified value is to be associated.
-    * @param value value to be associated with the specified key.
-    * @return previous value associated with specified key, or <code>null</code> if there was no mapping for key.
-    *    	A <code>null</code> return can also indicate that the key previously associated <code>null</code> with the specified key, 
-    *    	if the implementation supports null values.
-    */
-	V put(K key, V value);
-	
-   /**
-    * Removes the value for this key from a Cache.
-    * Returns the value to which the Key previously associated , or
-    * <code>null</code> if the Key contained no mapping.
-    *
-    * @param key key whose mapping is to be removed
-    * @return previous value associated with specified Node's key
-    */	
-	V remove(K key);
-	
-	/**
-	 * Size of the cache 
-	 * @return number of items in this cache
-	 */
-	int size();
-	
-	
-   /**
-    * Returns a {@link Set} containing the data in this Cache
-    *
-    * @return a {@link Set} containing the data in this Cache.  If there is no data, 
-    * an empty {@link Set} is returned.  The {@link Set} returned is always immutable.
-    */
-	Set<K> keySet();
-	
-	/**
-	 * Removes all the keys and their values from the Cache
-	 */
-	void clear();
-	   
-	/**
-	 * Listener to get the updates on this Cache
-	 * @param listener
-	 */
-	void addListener(CacheListener listener);
-	
-	/**
-	 * Remove Listener to stop the updates on this Cache
-	 * @param listener
-	 */
-	void removeListener();
-	
-	/**
-     * Returns a {@link Collection} containing the data in this Cache
-     *
-     * @return a {@link Collection} containing the data in this Cache.  If there is no data, 
-     * an empty {@link Collection} is returned.
-     */
-	Collection<V> values();
-	
-	
-	/** 
-	 * Add a child node to the current cache node
-	 * @param name - name of the child
-	 * @return Cache instance.
-	 */
-	Cache addChild(String name);
-	
-	/**
-	 * Get the child cache node from the current node
-	 * @param name
-	 * @return null if not found
-	 */
-	Cache getChild(String name);
-	
-	/**
-	 * Destroys the child from the current node; no-op if node not found
-	 * @param name
-	 * @return true if removed; false otherwise
-	 */
-	boolean removeChild(String name);
-	
-	
-	/**
-	 * Get child nodes under this cache node. If none found empty set is returned
-	 * @return
-	 */
-	List<Cache> getChildren();
-	
-	/**
-	 * Name of the cache node
-	 * @return
-	 */
-	String getName();
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/cache/CacheConfiguration.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/cache/CacheConfiguration.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/cache/CacheConfiguration.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,56 +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.cache;
-
-public class CacheConfiguration {
-	
-	public static CacheConfiguration DEFAULT = new CacheConfiguration(Policy.LRU, 60*60, 100); // 1 hours with 100 nodes.
-		
-	public enum Policy {
-		LRU,  // Least Recently Used
-		FIFO, // First in First Out
-		LFU;  // Least frequently Used
-	}
-	
-	private Policy policy;
-	private int maxage;
-	private int maxnodes;
-	
-	public CacheConfiguration(Policy policy, int maxAgeInSeconds, int maxNodes) {
-		this.policy = policy;
-		this.maxage = maxAgeInSeconds;
-		this.maxnodes = maxNodes;
-	}
-	
-	public Policy getPolicy() {
-		return this.policy;
-	}
-	
-	public int getMaxAgeInSeconds(){
-		return maxage;
-	}
-	
-	public int getMaxNodes() {
-		return this.maxnodes;
-	}
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/cache/CacheFactory.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/cache/CacheFactory.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/cache/CacheFactory.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,39 +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.cache;
-
-public interface CacheFactory {
-	
-	/**
-	 * Create / Get the cache for the give type use
-	 * @param type cache type
-	 * @param config configuration setup for the cache
-	 * @return
-	 */
-	<K,V> Cache<K, V> get(Cache.Type type, CacheConfiguration config);
-
-	/**
-	 * Destroy the cache factory and any caches underneath.
-	 */
-	void destroy();
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/cache/CacheListener.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/cache/CacheListener.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/cache/CacheListener.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,30 +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.cache;
-
-/**
- * Listener for the cache events like add,update delete
- */
-public interface CacheListener {
-	void cacheChanged();
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -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 com.metamatrix.common.buffer;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-
-public interface BatchManager {
-	
-	public interface ManagedBatch {
-		
-		TupleBatch getBatch(boolean cache, String[] types) throws MetaMatrixComponentException;
-		
-		void remove();
-		
-	}
-	
-	ManagedBatch createManagedBatch(TupleBatch batch) throws MetaMatrixComponentException;
-	
-	void remove();
-	
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/BlockedException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/BlockedException.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/BlockedException.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,43 +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.common.buffer;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-
-/**
- * This exception is thrown if the buffer manager blocks waiting on input during
- * processing.  This is an indication that more data will be available, but is 
- * not currently available.
- */
-public class BlockedException extends MetaMatrixComponentException {
-
-    public static final BlockedException INSTANCE = new BlockedException();
-
-    /**
-     * No-arg costructor required by Externalizable semantics
-     */
-    public BlockedException() {
-        super();
-    }
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,116 +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.common.buffer;
-
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-
-/**
- * The buffer manager controls how memory is used and how data flows through 
- * the system.  It uses {@link StorageManager storage managers}
- * to retrieve data, store data, and 
- * transfer data.  The buffer manager has algorithms that tell it when and 
- * how to store data.  The buffer manager should also be aware of memory 
- * management issues.
- */
-public interface BufferManager extends StorageManager {
-	
-	public enum TupleSourceType {
-		/**
-		 * Indicates that a tuple source is use during query processing as a 
-		 * temporary results.
-		 */
-		PROCESSOR,
-		/**
-		 * Indicates that a tuple source represents a query's final results.
-		 */
-		FINAL
-	}
-	
-	public enum BufferReserveMode {
-		WAIT,
-		FORCE,
-		NO_WAIT
-	}
-
-	public static int DEFAULT_CONNECTOR_BATCH_SIZE = 1024;
-	public static int DEFAULT_PROCESSOR_BATCH_SIZE = 512;
-	public static int DEFAULT_MAX_PROCESSING_BATCHES = 128;
-	
-	/**
-	 * This is the maximum number of batch columns used for processing.
-	 * See {@link #reserveBuffers(int, boolean)}
-	 */
-	public static int DEFAULT_RESERVE_BUFFERS = 16384;
-	
-    /**
-     * Get the batch size to use during query processing.  
-     * @return Batch size (# of rows)
-     */
-    int getProcessorBatchSize();
-
-    /**
-     * Get the batch size to use when reading data from a connector.  
-     * @return Batch size (# of rows)
-     */
-    int getConnectorBatchSize();
-    
-	TupleBuffer createTupleBuffer(List elements, String groupName, TupleSourceType tupleSourceType) 
-    throws MetaMatrixComponentException;
-	
-	/**
-	 * Return the maximum number of batches that can be temporarily held potentially 
-	 * across even a blocked exception.
-	 * @return
-	 */
-    int getMaxProcessingBatchColumns();
-    
-    /**
-     * Creates a new {@link FileStore}.  See {@link FileStore#setCleanupReference(Object)} to
-     * automatically cleanup the underlying resources.
-     * @param name
-     * @return
-     */
-    FileStore createFileStore(String name);
-    
-    /**
-     * Reserve up to count buffers for use.
-     * @param count
-     * @param mode
-     * @return
-     */
-    int reserveBuffers(int count, BufferReserveMode mode);
-    
-    /**
-     * Releases the buffers reserved by a call to {@link BufferManager#reserveBuffers(int, boolean)}
-     * @param count
-     */
-    void releaseBuffers(int count);
-    
-    /**
-     * Get the size estimate for the given schema.
-     */
-    int getSchemaSize(List elements);
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/FileStore.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/FileStore.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/FileStore.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,244 +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.common.buffer;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.ref.PhantomReference;
-import java.lang.ref.ReferenceQueue;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.IdentityHashMap;
-import java.util.Set;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-
-public abstract class FileStore {
-	
-	private static ReferenceQueue<Object> QUEUE = new ReferenceQueue<Object>();
-	private static final Set<PhantomReference<Object>> REFERENCES = Collections.newSetFromMap(new IdentityHashMap<PhantomReference<Object>, Boolean>());
-	
-	/**
-	 * A customized buffered stream with an exposed buffer
-	 */
-	public final class FileStoreOutputStream extends OutputStream {
-		
-		private byte[] buffer;
-		private int count;
-		private boolean bytesWritten;
-		
-		public FileStoreOutputStream(int size) {
-			this.buffer = new byte[size];
-		}
-		
-		@Override
-		public void write(int b) throws IOException {
-			write(new byte[b], 0, 1);
-		}
-
-		@Override
-		public void write(byte[] b, int off, int len) throws IOException {
-			if (len > buffer.length) {
-				flushBuffer();
-				writeDirect(b, off, len);
-				return;
-			}
-			int bufferedLength = Math.min(len, buffer.length - count);
-			if (count < buffer.length) {
-				System.arraycopy(b, off, buffer, count, bufferedLength);
-				count += bufferedLength;
-				if (bufferedLength == len) {
-					return;
-				}
-			}
-			flushBuffer();
-			System.arraycopy(b, off + bufferedLength, buffer, count, len - bufferedLength);
-			count += len - bufferedLength;
-		}
-
-		private void writeDirect(byte[] b, int off, int len) throws IOException {
-			try {
-				FileStore.this.write(b, off, len);
-				bytesWritten = true;
-			} catch (MetaMatrixComponentException e) {
-				throw new IOException(e);
-			}
-		}
-
-		public void flushBuffer() throws IOException {
-			if (count > 0) {
-				writeDirect(buffer, 0, count);
-				count = 0;
-			}
-		}
-		
-		public boolean bytesWritten() {
-			return bytesWritten;
-		}
-		
-	    public byte toByteArray()[] {
-	        return Arrays.copyOf(buffer, count);
-	    }
-		
-		@Override
-		public void close() throws IOException {
-			if (bytesWritten) {
-				flushBuffer();
-			}
-		}
-		
-	}
-
-	static class CleanupReference extends PhantomReference<Object> {
-		
-		private FileStore store;
-		
-		public CleanupReference(Object referent, FileStore store) {
-			super(referent, QUEUE);
-			this.store = store;
-		}
-		
-		public void cleanup() {
-			try {
-				this.store.remove();
-			} finally {
-				this.clear();
-			}
-		}
-	}
-	
-	private boolean removed;
-	private long len;
-	
-	public void setCleanupReference(Object o) {
-		REFERENCES.add(new CleanupReference(o, this));
-		for (int i = 0; i < 10; i++) {
-			CleanupReference ref = (CleanupReference)QUEUE.poll();
-			if (ref == null) {
-				break;
-			}
-			ref.cleanup();
-			REFERENCES.remove(ref);
-		}
-	}
-	
-	public synchronized long getLength() {
-		return len;
-	}
-		
-	public int read(long fileOffset, byte[] b, int offSet, int length)
-			throws MetaMatrixComponentException {
-		if (removed) {
-			throw new MetaMatrixComponentException("already removed"); //$NON-NLS-1$
-		}
-		return readDirect(fileOffset, b, offSet, length);
-	}
-	
-	protected abstract int readDirect(long fileOffset, byte[] b, int offSet, int length)
-			throws MetaMatrixComponentException;
-
-	public void readFully(long fileOffset, byte[] b, int offSet, int length) throws MetaMatrixComponentException {
-        int n = 0;
-    	do {
-    	    int count = this.read(fileOffset + n, b, offSet + n, length - n);
-    	    if (count < 0) {
-    	    	throw new MetaMatrixComponentException("not enough bytes available"); //$NON-NLS-1$
-    	    }
-    	    n += count;
-    	} while (n < length);
-	}
-	
-	public void write(byte[] bytes) throws MetaMatrixComponentException {
-		write(bytes, 0, bytes.length);
-	}
-
-	public synchronized long write(byte[] bytes, int offset, int length) throws MetaMatrixComponentException {
-		if (removed) {
-			throw new MetaMatrixComponentException("already removed"); //$NON-NLS-1$
-		}
-		writeDirect(bytes, offset, length);
-		long result = len;
-		len += length;		
-		return result;
-	}
-
-	protected abstract void writeDirect(byte[] bytes, int offset, int length) throws MetaMatrixComponentException;
-
-	public void remove() {
-		if (!this.removed) {
-			this.removed = true;
-			this.removeDirect();
-		}
-	}
-	
-	protected abstract void removeDirect();
-	
-	public InputStream createInputStream(final long start) {
-		return new InputStream() {
-			private long offset = start;
-			
-			@Override
-			public int read() throws IOException {
-				throw new UnsupportedOperationException("buffered reading must be used"); //$NON-NLS-1$
-			}
-			
-			@Override
-			public int read(byte[] b, int off, int len) throws IOException {
-				try {
-					int bytes = FileStore.this.read(offset, b, off, len);
-					if (bytes != -1) {
-						this.offset += bytes;
-					}
-					return bytes;
-				} catch (MetaMatrixComponentException e) {
-					throw new IOException(e);
-				}
-			}
-		};
-	}
-	
-	public OutputStream createOutputStream() {
-		return new OutputStream() {
-			
-			@Override
-			public void write(int b) throws IOException {
-				throw new UnsupportedOperationException("buffered reading must be used"); //$NON-NLS-1$
-			}
-			
-			@Override
-			public void write(byte[] b, int off, int len) throws IOException {
-				try {
-					FileStore.this.write(b, off, len);
-				} catch (MetaMatrixComponentException e) {
-					throw new IOException(e);
-				}
-			}
-		};
-	}
-	
-	public  FileStoreOutputStream createOutputStream(int maxMemorySize) {
-		return new FileStoreOutputStream(maxMemorySize);
-	}
-	
-}
\ No newline at end of file

Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/IndexedTupleSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/IndexedTupleSource.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/IndexedTupleSource.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,60 +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.common.buffer;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-
-public interface IndexedTupleSource extends TupleSource {
-
-	/**
-	 * @return true if there are more tuples
-	 * @throws MetaMatrixComponentException
-	 * @throws MetaMatrixProcessingException
-	 */
-	boolean hasNext() throws MetaMatrixComponentException, MetaMatrixProcessingException;
-
-	/**
-	 * Save the current position that can be restored with a call to {@link #reset()}
-	 */
-	void mark();
-
-	/**
-	 * Restore the previous mark and set the mark back to the first position.
-	 */
-	void reset();
-
-	/**
-	 * Set the tuple source position
-	 * @param position
-	 */
-	void setPosition(int position);
-	
-	/**
-	 * Get the current position.  The position is 1 based and reports the position of the
-	 * tuple that will be retrieved with a call to {@link TupleSource#nextTuple()}
-	 * @return
-	 */
-	int getCurrentIndex();
-	
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,33 +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.common.buffer;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-
-public interface StorageManager {
-
-	void initialize() throws MetaMatrixComponentException;
-
-	FileStore createFileStore(String name);
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBatch.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBatch.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBatch.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,184 +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.common.buffer;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.List;
-
-import org.teiid.client.BatchSerializer;
-
-
-/**
- * Represents a set of indexed tuples.  The {@link #getBeginRow beginning row}
- * is the first row contained in this batch; if it equals "1" then it is the
- * first row of the tuple source, otherwise this is a batch of intermediate
- * tuples.  The {@link #getEndRow ending row} is the last row contained in 
- * this tuple batch; it is equal to the beginning row plus the 
- * {@link #getRowCount number of rows} contained in this batch, minus one.
- * This object is immutable and Serializable;
- */
-public class TupleBatch implements Externalizable {
-	
-	private static final long serialVersionUID = 6304443387337336957L;
-	
-	private int rowOffset;    
-    private List[] tuples;
-    
-    // Optional state
-    private boolean terminationFlag = false;
-    
-    /**
-     * Contains ordered data types of each of the columns in the batch. Although it is not serialized,
-     * this array is a serialization aid and must be set before serialization and deserialization using
-     * the setDataTypes method. 
-     */
-    private transient String[] types;
-    
-    /** Required to honor Externalizable contract */
-    public TupleBatch() {
-    }
-    
-    /**
-     * Constructor
-     * @param beginRow indicates the row of the tuple source which is the
-     * first row contained in this batch
-     * @param tuples array of List objects, each of which is
-     * a single tuple
-     */
-    public TupleBatch(int beginRow, List[] tuples) {
-        this.rowOffset = beginRow;
-        this.tuples = tuples;
-    }
-
-    /**
-     * Constructor
-     * @param beginRow indicates the row of the tuple source which is the
-     * first row contained in this batch
-     * @param listOfTupleLists List containing List objects, each of which is
-     * a single tuple
-     */
-    public TupleBatch(int beginRow, List listOfTupleLists) {
-        this.rowOffset = beginRow;
-        this.tuples = (List[]) listOfTupleLists.toArray(new List[listOfTupleLists.size()]);
-    }
-
-    /**
-     * Return the number of the first row of the tuple source that is
-     * contained in this batch (one-based).
-     * @return the first row contained in this tuple batch
-     */
-    public int getBeginRow() {
-        return rowOffset;
-    }
-    
-    /**
-     * Return number of the last row of the tuple source that is contained in 
-     * this batch (one-based).
-     * @return the last row contained in this tuple batch
-     */
-    public int getEndRow() {
-        return rowOffset + tuples.length - 1;
-    }
-    
-    /**
-     * Return the number of rows contained in this tuple batch
-     * @return the number of rows contained in this tuple batch
-     */
-    public int getRowCount() {
-        return tuples.length;
-    }
-        
-    /**
-     * Return the tuple at the given index (one-based).
-     * @return the tuple at the given index
-     */
-    public List getTuple(int rowIndex) {
-        return tuples[rowIndex-rowOffset];
-    }
-    
-    /**
-     * Get all tuples 
-     * @return All tuples
-     */
-    public List[] getAllTuples() { 
-        return tuples;    
-    }
-
-    /**
-     * Check whether this batch is the last in a series of batches.
-     * @return True if this batch is last
-     */
-    public boolean getTerminationFlag() {
-        return this.terminationFlag;    
-    }
-    
-    /**
-     * Set whether this batch is the last in a series of batches.
-     * @param terminationFlag True if last
-     */
-    public void setTerminationFlag(boolean terminationFlag) {
-        this.terminationFlag = terminationFlag;    
-    }
-    
-    public String[] getDataTypes() {
-		return types;
-	}
-    
-    public void setDataTypes(String[] types) {
-        this.types = types;
-    }
-    
-    public boolean containsRow(int row) {
-    	return rowOffset <= row && getEndRow() >= row;
-    }
-    
-    /**
-     * Return a String describing this object
-     * @param String representation of this TupleBatch
-     */
-    public String toString() {
-        StringBuffer s = new StringBuffer();
-        s.append("TupleBatch; beginning row="); //$NON-NLS-1$
-        s.append(rowOffset);
-        s.append(", number of rows="); //$NON-NLS-1$
-        s.append(tuples.length);
-        s.append(", lastBatch="); //$NON-NLS-1$
-        s.append(this.terminationFlag);
-        return s.toString();
-    }
-
-    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        rowOffset = in.readInt();
-        terminationFlag = in.readBoolean();
-        tuples = BatchSerializer.readBatch(in, types);
-    }
-    public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(rowOffset);
-        out.writeBoolean(terminationFlag);
-        BatchSerializer.writeBatch(out, types, tuples);
-    }
-}
-

Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,415 +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.common.buffer;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.logging.MessageLevel;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.query.sql.symbol.Expression;
-
-public class TupleBuffer {
-	
-	class TupleSourceImpl implements IndexedTupleSource {
-	    private int currentRow = 1;
-	    private int mark = 1;
-		private List<?> currentTuple;
-		private TupleBatch batch;
-
-	    @Override
-	    public int getCurrentIndex() {
-	    	return this.currentRow;
-	    }
-
-	    @Override
-	    public List getSchema(){
-	        return schema;
-	    }
-
-	    @Override
-	    public List<?> nextTuple()
-	    throws MetaMatrixComponentException{
-	    	List<?> result = null;
-	    	if (currentTuple != null){
-				result = currentTuple;
-				currentTuple = null;
-	    	} else {
-	    		result = getCurrentTuple();
-	    	} 
-	    	if (result != null) {
-	    		currentRow++;
-	    	}
-	        return result;
-	    }
-
-		private List<?> getCurrentTuple() throws MetaMatrixComponentException,
-				BlockedException {
-			if (currentRow <= rowCount) {
-				//if (forwardOnly) {
-					if (batch == null || !batch.containsRow(currentRow)) {
-						batch = getBatch(currentRow);
-					}
-					return batch.getTuple(currentRow);
-				//} 
-				//TODO: determine if we should directly hold a soft reference here
-				//return getRow(currentRow);
-			}
-			batch = null;
-			if(isFinal) {
-	            return null;
-	        } 
-	        throw BlockedException.INSTANCE;
-		}
-
-	    @Override
-	    public void closeSource() {
-	    	batch = null;
-	        mark = 1;
-	        reset();
-	    }
-	    
-	    @Override
-		public boolean hasNext() throws MetaMatrixComponentException {
-	        if (this.currentTuple != null) {
-	            return true;
-	        }
-	        
-	        this.currentTuple = getCurrentTuple();
-			return this.currentTuple != null;
-		}
-
-		@Override
-		public void reset() {
-			this.setPosition(mark);
-			this.mark = 1;
-		}
-
-	    @Override
-	    public void mark() {
-	        this.mark = currentRow;
-	    }
-
-	    @Override
-	    public void setPosition(int position) {
-	        if (this.currentRow != position) {
-		        this.currentRow = position;
-		        this.currentTuple = null;
-	        }
-	    }
-	    
-	    @Override
-	    public int available() {
-	    	return rowCount - currentRow + 1;
-	    }
-	}
-	
-    /**
-     * Gets the data type names for each of the input expressions, in order.
-     * @param expressions List of Expressions
-     * @return
-     * @since 4.2
-     */
-    public static String[] getTypeNames(List expressions) {
-    	if (expressions == null) {
-    		return null;
-    	}
-        String[] types = new String[expressions.size()];
-        for (ListIterator i = expressions.listIterator(); i.hasNext();) {
-            Expression expr = (Expression)i.next();
-            types[i.previousIndex()] = DataTypeManager.getDataTypeName(expr.getType());
-        }
-        return types;
-    }
-
-	private static final AtomicLong LOB_ID = new AtomicLong();
-	
-	//construction state
-	private BatchManager manager;
-	private String tupleSourceID;
-	private List<?> schema;
-	private String[] types;
-	private int batchSize;
-	
-	private int rowCount;
-	private boolean isFinal;
-    private TreeMap<Integer, BatchManager.ManagedBatch> batches = new TreeMap<Integer, BatchManager.ManagedBatch>();
-	private ArrayList<List<?>> batchBuffer;
-	private boolean removed;
-	private boolean forwardOnly;
-
-    //lob management
-    private Map<String, Streamable<?>> lobReferences; //references to contained lobs
-    private boolean lobs = true;
-	
-	public TupleBuffer(BatchManager manager, String id, List<?> schema, int batchSize) {
-		this.manager = manager;
-		this.tupleSourceID = id;
-		this.schema = schema;
-		this.types = getTypeNames(schema);
-		this.batchSize = batchSize;
-		if (types != null) {
-			int i = 0;
-		    for (i = 0; i < types.length; i++) {
-		        if (DataTypeManager.isLOB(types[i]) || types[i] == DataTypeManager.DefaultDataTypes.OBJECT) {
-		        	break;
-		        }
-		    }
-		    if (i == types.length) {
-		    	lobs = false;
-		    }
-        }
-	}
-	
-	public void addTuple(List<?> tuple) throws MetaMatrixComponentException {
-		if (lobs) {
-			correctLobReferences(new List[] {tuple});
-		}
-		this.rowCount++;
-		if (batchBuffer == null) {
-			batchBuffer = new ArrayList<List<?>>(batchSize/4);
-		}
-		batchBuffer.add(tuple);
-		if (batchBuffer.size() == batchSize) {
-			saveBatch(false, false);
-		}
-	}
-	
-	/**
-	 * Adds the given batch preserving row offsets.
-	 * @param batch
-	 * @throws MetaMatrixComponentException
-	 */
-	public void addTupleBatch(TupleBatch batch, boolean save) throws MetaMatrixComponentException {
-		setRowCount(batch.getBeginRow() - 1); 
-		if (save) {
-			for (List<?> tuple : batch.getAllTuples()) {
-				addTuple(tuple);
-			}
-		}
-	}
-
-	public void setRowCount(int rowCount)
-			throws MetaMatrixComponentException {
-		assert this.rowCount <= rowCount;
-		if (this.rowCount != rowCount) {
-			saveBatch(false, true);
-			this.rowCount = rowCount;
-		}
-	}
-	
-	public void purge() {
-		if (this.batchBuffer != null) {
-			this.batchBuffer.clear();
-		}
-		for (BatchManager.ManagedBatch batch : this.batches.values()) {
-			batch.remove();
-		}
-		this.batches.clear();
-	}
-	
-	/**
-	 * Force the persistence of any rows held in memory.
-	 * @throws MetaMatrixComponentException
-	 */
-	public void saveBatch() throws MetaMatrixComponentException {
-		this.saveBatch(false, false);
-	}
-
-	void saveBatch(boolean finalBatch, boolean force) throws MetaMatrixComponentException {
-		Assertion.assertTrue(!this.isRemoved());
-		if (batchBuffer == null || batchBuffer.isEmpty() || (!force && batchBuffer.size() < Math.max(1, batchSize / 32))) {
-			return;
-		}
-        TupleBatch writeBatch = new TupleBatch(rowCount - batchBuffer.size() + 1, batchBuffer);
-        if (finalBatch) {
-        	writeBatch.setTerminationFlag(true);
-        }
-        writeBatch.setDataTypes(types);
-		BatchManager.ManagedBatch mbatch = manager.createManagedBatch(writeBatch);
-		this.batches.put(writeBatch.getBeginRow(), mbatch);
-        batchBuffer = null;
-	}
-	
-	public void close() throws MetaMatrixComponentException {
-		saveBatch(true, false);
-		this.isFinal = true;
-	}
-	
-	/**
-	 * Get the batch containing the given row.
-	 * NOTE: the returned batch may be empty or may begin with a row other
-	 * than the one specified.
-	 * @param row
-	 * @return
-	 * @throws MetaMatrixComponentException
-	 */
-	public TupleBatch getBatch(int row) throws MetaMatrixComponentException {
-		TupleBatch result = null;
-		if (row > rowCount) {
-			result = new TupleBatch(rowCount + 1, new List[] {});
-		} else if (this.batchBuffer != null && row > rowCount - this.batchBuffer.size()) {
-			result = new TupleBatch(rowCount - this.batchBuffer.size() + 1, batchBuffer);
-			if (forwardOnly) {
-				this.batchBuffer = null;
-			}
-		} else {
-			if (this.batchBuffer != null && !this.batchBuffer.isEmpty()) {
-				//this is just a sanity check to ensure we're not holding too many
-				//hard references to batches.
-				saveBatch(isFinal, false);
-			}
-			Map.Entry<Integer, BatchManager.ManagedBatch> entry = batches.floorEntry(row);
-			Assertion.isNotNull(entry);
-			BatchManager.ManagedBatch batch = entry.getValue();
-	    	result = batch.getBatch(!forwardOnly, types);
-	    	if (lobs && result.getDataTypes() == null) {
-		        correctLobReferences(result.getAllTuples());
-	    	}
-	    	result.setDataTypes(types);
-	    	if (forwardOnly) {
-				batches.remove(entry.getKey());
-			}
-		}
-		if (isFinal && result.getEndRow() == rowCount) {
-			result.setTerminationFlag(true);
-		}
-		return result;
-	}
-	
-	public void remove() {
-		if (!removed) {
-			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
-	            LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Removing TupleBuffer:", this.tupleSourceID); //$NON-NLS-1$
-	        }
-			this.batchBuffer = null;
-			purge();
-			this.manager.remove();
-			removed = true;
-		}
-	}
-	
-	public int getRowCount() {
-		return rowCount;
-	}
-	
-	public boolean isFinal() {
-		return isFinal;
-	}
-	
-	public void setFinal(boolean isFinal) {
-		this.isFinal = isFinal;
-	}
-	
-	public List<?> getSchema() {
-		return schema;
-	}
-	
-	public int getBatchSize() {
-		return batchSize;
-	}
-	
-	public void setBatchSize(int batchSize) {
-		this.batchSize = batchSize;
-	}
-	    
-    public Streamable<?> getLobReference(String id) throws MetaMatrixComponentException {
-    	Streamable<?> lob = null;
-    	if (this.lobReferences != null) {
-    		lob = this.lobReferences.get(id);
-    	}
-    	if (lob == null) {
-    		throw new MetaMatrixComponentException(DQPPlugin.Util.getString("ProcessWorker.wrongdata")); //$NON-NLS-1$
-    	}
-    	return lob;
-    }
-    
-    /**
-     * If a tuple batch is being added with Lobs, then references to
-     * the lobs will be held on the {@link TupleSourceInfo} 
-     * @param batch
-     * @throws MetaMatrixComponentException 
-     */
-    @SuppressWarnings("unchecked")
-	private void correctLobReferences(List[] rows) throws MetaMatrixComponentException {
-        int columns = schema.size();
-        // walk through the results and find all the lobs
-        for (int row = 0; row < rows.length; row++) {
-            for (int col = 0; col < columns; col++) {                                                
-                Object anObj = rows[row].get(col);
-                
-                if (!(anObj instanceof Streamable<?>)) {
-                	continue;
-                }
-                Streamable lob = (Streamable)anObj;                  
-                String id = lob.getReferenceStreamId();
-            	if (id == null) {
-            		id = String.valueOf(LOB_ID.getAndIncrement());
-            		lob.setReferenceStreamId(id);
-            	}
-            	if (this.lobReferences == null) {
-            		this.lobReferences = Collections.synchronizedMap(new HashMap<String, Streamable<?>>());
-            	}
-            	this.lobReferences.put(id, lob);
-                if (lob.getReference() == null) {
-                	lob.setReference(getLobReference(lob.getReferenceStreamId()).getReference());
-                }
-            }
-        }
-    }
-    
-    public void setForwardOnly(boolean forwardOnly) {
-		this.forwardOnly = forwardOnly;
-	}
-    
-	/**
-	 * Create a new iterator for this buffer
-	 * @return
-	 */
-	public IndexedTupleSource createIndexedTupleSource() {
-		return new TupleSourceImpl();
-	}
-	
-	@Override
-	public String toString() {
-		return this.tupleSourceID;
-	}
-	
-	public boolean isRemoved() {
-		return removed;
-	}
-	
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleSource.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleSource.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,66 +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.common.buffer;
-
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-
-/**
- * <p>A cursored source of tuples.  The implementation will likely be closely
- * bound to a {@link BufferManager} implementation - it will work with it
- * to use {@link TupleBatch TupleBatches} behind the scenes.</p>
- */
-public interface TupleSource {
-
-    /**
-     * Returns the List of ElementSymbol describing the Tuple Source
-     * @return the List of elements describing the Tuple Source
-     */
-	List<SingleElementSymbol> getSchema();
-	
-    /**
-     * Returns the next tuple
-     * @return the next tuple (a List object), or <code>null</code> if
-     * there are no more tuples.
-     * @throws MetaMatrixComponentException indicating a non-business
-     * exception such as a communication exception, or other such
-     * nondeterministic exception
-     */
-	List<?> nextTuple()
-		throws MetaMatrixComponentException, MetaMatrixProcessingException;
-	
-    /**
-     * Closes the Tuple Source.  
-     */    
-	void closeSource();
-	
-	/**
-	 * Returns an estimate of the number of rows that can be read without blocking.
-	 * @return
-	 */
-	int available();
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/DQPPlugin.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/DQPPlugin.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/DQPPlugin.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,38 +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.dqp;
-
-import java.util.ResourceBundle;
-
-import com.metamatrix.core.BundleUtil;
-
-/**
- * DQPPlugin
- */
-public class DQPPlugin {
-
-    public static final String PLUGIN_ID = "com.metamatrix.dqp" ; //$NON-NLS-1$
-	public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,
-	                                                     PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/QueryPlugin.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/QueryPlugin.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,43 +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;
-
-import java.util.ResourceBundle;
-import com.metamatrix.core.BundleUtil;
-
-/**
- * QueryPlugin
- * <p>
- * Used here in <code>query</code> to have access to the new logging framework for <code>LogManager</code>.
- * </p>
- */
-public class QueryPlugin { // extends Plugin {
-
-	/**
-	 * The plug-in identifier of this plugin (value <code>"com.metamatrix.common"</code>).
-	 */
-	public static final String PLUGIN_ID = "com.metamatrix.query"; //$NON-NLS-1$
-
-	public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,
-	                                                     PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,278 +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.function;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-/**
- * The FunctionDescriptor describes a particular function instance enough
- * that the function library can retrieve a function instance based on the 
- * descriptor.
- */
-public class FunctionDescriptor implements Serializable, Cloneable {
-	
-	private static final boolean ALLOW_NAN_INFINITY = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.allowNanInfinity", false); //$NON-NLS-1$
-	
-	private String name;
-    private int pushdown;
-	private Class[] types;
-	private Class returnType;	
-	private int hash;
-    private boolean requiresContext;
-    private boolean nullDependent;
-    private int deterministic;
-    
-    // This is transient as it would be useless to invoke this method in 
-    // a different VM.  This function descriptor can be used to look up 
-    // the real VM descriptor for execution.
-    private transient Method invocationMethod;
-	
-    FunctionDescriptor() {
-    }
-    
-    /** 
-     * Construct a function descriptor with all the info
-     * @param name Name of function
-     * @param types Types of the arguments
-     * @param returnType Type of the return 
-     * @param invocationMethod Reflection method used to invoke the function
-     * @param requiresContext during execution requires command context to be pushed into method as first argument
-     */
-	FunctionDescriptor(String name, int pushdown, Class[] types, Class returnType, Method invocationMethod, boolean requiresContext, boolean nullDependent, int deterministic) {
-		Assertion.isNotNull(name);
-		Assertion.isNotNull(types);
-		Assertion.isNotNull(returnType);
-		
-		this.name = name;
-        this.pushdown = pushdown;
-		this.types = types;
-		this.returnType = returnType;
-        this.invocationMethod = invocationMethod;
-        this.requiresContext = requiresContext;
-        this.nullDependent = nullDependent;
-        this.deterministic = deterministic;
-		
-		// Compute hash code
-		hash = HashCodeUtil.hashCode(0, name);
-		for(int i=0; i<types.length; i++) {
-			hash = HashCodeUtil.hashCode(hash, types[i]);
-		}
-	}
-
-	public String getName() {
-		return this.name;				
-	}
-    
-    public int getPushdown() {
-        return this.pushdown;
-    }
-    
-    void setPushdown(int pushdown) {
-        this.pushdown = pushdown;
-    }
-	
-	public Class[] getTypes() {
-		return this.types;
-	}
-	
-	public Class getReturnType() {
-		return this.returnType;
-	}		
-	
-    Method getInvocationMethod() {
-        return this.invocationMethod;
-    }
-       
-    public boolean requiresContext() {
-        return this.requiresContext;
-    }
-    
-	public int hashCode() { 
-		return this.hash;
-	}
-	
-	public boolean equals(Object obj) {
-		if(obj == this) {
-			return true;
-		}
-		
-		if(obj == null || !(obj instanceof FunctionDescriptor)) {
-			return false;			
-		}	
-		FunctionDescriptor other = (FunctionDescriptor) obj;
-		
-		// Compare names
-		if(! this.getName().equals(other.getName())) {
-			return false;
-		}
-        
-        // Compare arg types
-		Class[] thisTypes = this.getTypes();
-		Class[] otherTypes = other.getTypes();
-		if(thisTypes.length != otherTypes.length) {
-			return false;
-		}
-		for(int i=0; i<thisTypes.length; i++) { 
-			if(! thisTypes[i].equals(otherTypes[i])) {
-				return false;
-			}
-		}
-        
-        if (this.nullDependent != other.isNullDependent()) {
-            return false;
-        }
-        
-        if (this.deterministic != other.deterministic) {
-            return false;
-        }
-		 
-		// Must be a match
-		return true;
-	}
-	
-	public String toString() {
-		StringBuffer str = new StringBuffer(this.name);
-		str.append("("); //$NON-NLS-1$
-		for(int i=0; i<types.length; i++) {
-			if(types[i] != null) { 
-				str.append(types[i].getName());
-			} else {
-				str.append("null"); //$NON-NLS-1$
-			}		
-			if(i<(types.length-1)) {
-				str.append(", "); //$NON-NLS-1$
-			}
-		}
-		str.append(") : "); //$NON-NLS-1$
-        if(returnType == null) { 
-            str.append("null"); //$NON-NLS-1$
-        } else {    
-    		str.append(returnType.getName());
-        }    
-		return str.toString();
-	}
-
-    public boolean isNullDependent() {
-        return nullDependent;
-    }
-    
-    public int getDeterministic() {
-        return deterministic;
-    }
-
-    void setDeterministic(int deterministic) {
-        this.deterministic = deterministic;
-    }
-    
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new MetaMatrixRuntimeException(e);
-        }
-    }
-
-    void setReturnType(Class returnType) {
-        this.returnType = returnType;
-    }
-    
-    
-	/**
-	 * Invoke the function described in the function descriptor, using the
-	 * values provided.  Return the result of the function.
-	 * @param fd Function descriptor describing the name and types of the arguments
-	 * @param values Values that should match 1-to-1 with the types described in the
-	 * function descriptor
-	 * @return Result of invoking the function
-	 */
-	public Object invokeFunction(Object[] values) throws FunctionExecutionException {
-
-        if (!isNullDependent()) {
-        	for (int i = 0; i < values.length; i++) {
-				if (values[i] == null) {
-					return null;
-				}
-			}
-        }
-
-        // If descriptor is missing invokable method, find this VM's descriptor
-        // give name and types from fd
-        Method method = getInvocationMethod();
-        if(method == null) {
-        	throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0002, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0002, getName()));
-        }
-        
-        if (getDeterministic() >= FunctionMethod.SESSION_DETERMINISTIC && values.length > 0 && values[0] instanceof CommandContext) {
-        	CommandContext cc = (CommandContext)values[0];
-        	cc.setSessionFunctionEvaluated(true);
-        }
-        
-        // Invoke the method and return the result
-        try {
-        	if (method.isVarArgs()) {
-        		int i = method.getParameterTypes().length;
-        		Object[] newValues = Arrays.copyOf(values, i);
-        		newValues[i - 1] = Arrays.copyOfRange(values, i - 1, values.length);
-        		values = newValues;
-        	}
-            Object result = method.invoke(null, values);
-            if (!ALLOW_NAN_INFINITY) {
-        		if (result instanceof Double) {
-	            	Double floatVal = (Double)result;
-	            	if (Double.isInfinite(floatVal) || Double.isNaN(floatVal)) {
-	            		throw new FunctionExecutionException(new ArithmeticException("Infinite or invalid result"), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName())); //$NON-NLS-1$
-	            	}
-	            } else if (result instanceof Float) {
-	            	Float floatVal = (Float)result;
-	            	if (Float.isInfinite(floatVal) || Float.isNaN(floatVal)) {
-	            		throw new FunctionExecutionException(new ArithmeticException("Infinite or invalid result"), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName())); //$NON-NLS-1$
-	            	}
-	            }
-        	}
-            result = DataTypeManager.convertToRuntimeType(result);
-            result = DataTypeManager.transformValue(result, getReturnType());
-            return result;
-        } catch(InvocationTargetException e) {
-            throw new FunctionExecutionException(e.getTargetException(), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName()));
-        } catch(IllegalAccessException e) {
-            throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0004, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0004, method.toString()));
-        } catch (TransformationException e) {
-        	throw new FunctionExecutionException(e, e.getMessage());
-		}
-	}    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,282 +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.function;
-
-import java.io.Serializable;
-import java.util.*;
-
-import org.teiid.connector.language.SQLReservedWords;
-
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.function.metadata.*;
-
-/**
- * The FunctionForm class represents a particular form of a function signature.
- * It is different from the FunctionMethod class because it ignores type 
- * information and instead differentiates function signatures based on their
- * function name and the names of the arguments.
- */
-public class FunctionForm implements Serializable, Comparable {
-
-    private String name;
-    private String description;
-    private String category;
-    private List inputParamNames;
-    private List inputParamDescs;
-    private String outputParamName;
-    private String outputParamDesc;
-    
-    /** 
-     * Construct a function form by pulling all info from a FunctionMethod.  Because
-     * a FunctionForm is only created from a <b>validated</b> method, we can assume
-     * many things, such as that function name, type, category are non-null.
-     * @param method FunctionMethod to build form from
-     */
-    public FunctionForm(FunctionMethod method) { 
-        Assertion.isNotNull(method);
-
-        // Get function stuff
-        this.name = method.getName().toUpperCase();
-        this.description = method.getDescription();
-        this.category = method.getCategory().toUpperCase();
-        
-        // Get input parameter stuff
-        FunctionParameter[] inputParams = method.getInputParameters();
-        if(inputParams == null) { 
-            inputParamNames = new ArrayList(0);
-            inputParamDescs = new ArrayList(0);
-        } else {
-            inputParamNames = new ArrayList(inputParams.length);
-            inputParamDescs = new ArrayList(inputParams.length);
-            
-            for(int i=0; i<inputParams.length; i++) { 
-                inputParamNames.add(inputParams[i].getName().toUpperCase());
-                inputParamDescs.add(inputParams[i].getDescription());
-            }
-        }
-        
-        // Get output parameter stuff
-        FunctionParameter outParam = method.getOutputParameter();
-        this.outputParamName = outParam.getName().toUpperCase();
-        this.outputParamDesc = outParam.getDescription();
-    }
-    
-    /**
-     * Get name of function.
-     * @return Name
-     */
-    public String getName() { 
-        return this.name;
-    }        
-    
-    /**
-     * Get description of function.
-     * @return Description
-     */
-    public String getDescription() {
-        return this.description;
-    }
-
-    /**
-     * Get category.
-     * @return Category
-     */
-    public String getCategory() {
-        return this.category;
-    }
-    
-    /**
-     * Get list of argument names.
-     * @return List of argument names ({@link java.lang.String})
-     */
-    public List getArgNames() { 
-        return this.inputParamNames;
-    }
-
-    /**
-     * Get argument name at index.
-     * @param index Index to use
-     * @return Argument name at index
-     */
-    public String getArgName(int index) { 
-        return (String) this.inputParamNames.get(index);
-    }
-
-    /**
-     * Get list of argument descriptions.
-     * @return List of argument descriptions ({@link java.lang.String})
-     */
-    public List getArgDescriptions() { 
-        return this.inputParamDescs;
-    }
-    
-    /**
-     * Get argument description at index.
-     * @param index Index to use
-     * @return Argument description at index
-     */
-    public String getArgDescription(int index) { 
-        return (String) this.inputParamDescs.get(index);
-    }
-
-    /**
-     * Get name of return parameter
-     * @return Name of return parameter
-     */
-    public String getReturnName() { 
-        return this.outputParamName;
-    }
-    
-    /**
-     * Get description of return parameter
-     * @return Description of return parameter
-     */
-    public String getReturnDescription() { 
-        return this.outputParamDesc;
-    }
-    
-    /**
-     * Get display string for this function form     
-     * @return Display version of this function form
-     */
-    public String getDisplayString() { 
-        StringBuffer str = new StringBuffer();
-        
-		if(name.equalsIgnoreCase(FunctionLibrary.CAST)) { 
-			str.append(name);
-			str.append("("); //$NON-NLS-1$
-			str.append(inputParamNames.get(0));
-			if(name.equalsIgnoreCase(FunctionLibrary.CONVERT) || name.equalsIgnoreCase(FunctionLibrary.CAST)) {
-				str.append(", "); //$NON-NLS-1$
-			} else {
-				str.append(" "); //$NON-NLS-1$
-				str.append(SQLReservedWords.AS);
-				str.append(" "); //$NON-NLS-1$
-			}	
-			str.append(inputParamNames.get(1));
-			str.append(")"); //$NON-NLS-1$
-										
-		} else if(name.equals("+") || name.equals("-") || name.equals("*") || name.equals("/") || name.equals("||")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-			str.append("("); //$NON-NLS-1$
-            str.append(inputParamNames.get(0));
-            str.append(name);
-            str.append(inputParamNames.get(1));
-			str.append(")"); //$NON-NLS-1$
-		} else {
-			str.append(name);
-			str.append("("); //$NON-NLS-1$
-
-            if(inputParamNames.size() > 0) { 
-                Iterator iter = inputParamNames.iterator();
-                str.append(iter.next());
-                while(iter.hasNext()) { 
-                    str.append(", "); //$NON-NLS-1$
-                    str.append(iter.next());
-                }
-            }
-		
-			str.append(")"); //$NON-NLS-1$
-		}
-			
-		return str.toString();
-    }        
-
-    /** 
-     * String representation of the function form for debugging purposes.
-     * @return String representation
-     */
-    public String toString() { 
-        return this.getDisplayString();
-    }
-    
-    /**
-     * Return hash code based on the name and input parameter names
-     * @return Hash code
-     */
-    public int hashCode() {
-        return HashCodeUtil.hashCode(name.hashCode(), inputParamNames.hashCode());   
-    }
-    
-    /**
-     * Compare this function form with another based on the name and 
-     * argument names.
-     * @param obj Other object
-     */
-    public boolean equals(Object obj) { 
-        if(obj == this) { 
-            return true;
-        } else if(obj == null || !(obj instanceof FunctionForm)) { 
-            return false;
-        } else {
-            FunctionForm other = (FunctionForm) obj;
-            return other.getName().equals(getName()) && 
-                   other.getArgNames().equals(getArgNames());
-        }
-    }
-    
-    /**
-     * Implements Comparable interface so that this object can be compared to 
-     * other FunctionForm objects and ordered alphabetically.
-     * @param obj Other object
-     * @return 1 if other > this, 0 if other == this, -1 if other < this
-     */
-    public int compareTo(Object obj) {
-        if(obj == this) { 
-            return 0;
-        } else if(obj == null) { 
-            // Should never happen, but sort nulls low
-            return -1;
-        } else {
-            // may throw ClassCastException - this is expected for compareTo()
-            FunctionForm other = (FunctionForm) obj;
-            
-            int compare = this.getName().compareTo( other.getName() );
-            if(compare != 0) { 
-                return compare;
-            }
-                
-            // Look further into arg names to compare as names are ==
-            List otherArgs = other.getArgNames();
-            List myArgs = this.getArgNames();
-            
-            // Compare # of args first
-            if(myArgs.size() < otherArgs.size()) { 
-                return -1;
-            } else if(myArgs.size() > otherArgs.size()) { 
-                return 1;
-            } // else continue    
-
-            // Same # of args
-            for(int i=0; i < myArgs.size(); i++) { 
-                compare = ((String)myArgs.get(i)).compareTo( ((String)otherArgs.get(i)) );
-                if(compare != 0) { 
-                    return compare;
-                }
-            }
-            
-            // Same
-            return 0;                
-        }
-    }
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,337 +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.function;
-
-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;
-
-
-/**
- * The function library is the primary way for the system to find out what
- * functions are available, resolve function signatures, and invoke system
- * and user-defined functions.
- */
-public class FunctionLibrary {
-
-	// Special type conversion functions
-	public static final String CONVERT = "convert"; //$NON-NLS-1$
-	public static final String CAST = "cast"; //$NON-NLS-1$
-
-    // Special lookup function
-    public static final String LOOKUP = "lookup"; //$NON-NLS-1$
-
-    // Special user function
-    public static final String USER = "user"; //$NON-NLS-1$
-    // Special environment variable lookup function
-    public static final String ENV = "env"; //$NON-NLS-1$
-    
-    // Special pseudo-functions only for XML queries
-    public static final String CONTEXT = "context"; //$NON-NLS-1$
-    public static final String ROWLIMIT = "rowlimit"; //$NON-NLS-1$
-    public static final String ROWLIMITEXCEPTION = "rowlimitexception"; //$NON-NLS-1$
-    
-    // Misc.
-    public static final String DECODESTRING = "decodestring"; //$NON-NLS-1$
-    public static final String DECODEINTEGER = "decodeinteger"; //$NON-NLS-1$
-    public static final String COMMAND_PAYLOAD = "commandpayload"; //$NON-NLS-1$
-    
-    public static final String CONCAT = "CONCAT"; //$NON-NLS-1$
-    public static final String CONCAT2 = "CONCAT2"; //$NON-NLS-1$
-    public static final String CONCAT_OPERATOR = "||"; //$NON-NLS-1$
-    public static final String SUBSTRING = "substring"; //$NON-NLS-1$
-    public static final String NVL = "NVL"; //$NON-NLS-1$
-    public static final String IFNULL = "IFNULL"; //$NON-NLS-1$
-    
-    public static final String FROM_UNIXTIME = "from_unixtime"; //$NON-NLS-1$
-    public static final String TIMESTAMPADD = "timestampadd"; //$NON-NLS-1$
-    
-    public static final String PARSETIME = "parsetime"; //$NON-NLS-1$
-    public static final String PARSEDATE = "parsedate"; //$NON-NLS-1$
-    public static final String FORMATTIME = "formattime"; //$NON-NLS-1$
-    public static final String FORMATDATE = "formatdate"; //$NON-NLS-1$
-    
-    public static final String NULLIF = "nullif"; //$NON-NLS-1$
-    public static final String COALESCE = "coalesce"; //$NON-NLS-1$
-
-    public static final String SPACE = "space"; //$NON-NLS-1$
-    
-    public static final String XMLFOREST = "XMLFOREST"; //$NON-NLS-1$
-    public static final String XMLATTRIBUTES = "XMLATTRIBUTES"; //$NON-NLS-1$
-    public static final String XMLNAMESPACES = "XMLNAMESPACES"; //$NON-NLS-1$
-    public static final String XMLELEMENT = "XMLELEMENT"; //$NON-NLS-1$
-	
-    // Function tree for system functions (never reloaded)
-    private FunctionTree systemFunctions;
-
-    // Function tree for user-defined functions
-    private FunctionTree userFunctions;
-
-	/**
-	 * Construct the function library.  This should be called only once by the
-	 * FunctionLibraryManager.
-	 */
-	public FunctionLibrary(FunctionTree systemFuncs, FunctionTree userFuncs) {
-        systemFunctions = systemFuncs;
-       	userFunctions = userFuncs;
-	}
-
-    /**
-     * Get all function categories, sorted in alphabetical order
-     * @return List of function category names, sorted in alphabetical order
-     */
-    public List getFunctionCategories() {
-        // Remove category duplicates
-        HashSet categories = new HashSet();
-        categories.addAll( systemFunctions.getCategories() );
-        categories.addAll( userFunctions.getCategories() );
-
-        // Sort alphabetically
-        ArrayList categoryList = new ArrayList(categories);
-        Collections.sort(categoryList);
-        return categoryList;
-    }
-
-    /**
-     * Get all function forms in a category, sorted by name, then # of args, then names of args.
-     * @param category Category name
-     * @return List of {@link FunctionForm}s in a category
-     */
-    public List getFunctionForms(String category) {
-        List forms = new ArrayList();
-        forms.addAll(systemFunctions.getFunctionForms(category));
-        forms.addAll(userFunctions.getFunctionForms(category));
-
-        // Sort alphabetically
-        Collections.sort(forms);
-        return forms;
-    }
-
-    /**
-     * Find function form based on function name and # of arguments.
-     * @param name Function name
-     * @param numArgs Number of arguments
-     * @return Corresponding form or null if not found
-     */
-    public FunctionForm findFunctionForm(String name, int numArgs) {
-        FunctionForm form = systemFunctions.findFunctionForm(name, numArgs);
-        if(form == null) {
-            form = userFunctions.findFunctionForm(name, numArgs);
-        }
-        return form;
-    }
-
-	/**
-	 * Find a function descriptor given a name and the types of the arguments.
-	 * This method matches based on case-insensitive function name and
-     * an exact match of the number and types of parameter arguments.
-     * @param name Name of the function to resolve
-     * @param types Array of classes representing the types
-     * @return Descriptor if found, null if not found
-	 */
-	public FunctionDescriptor findFunction(String name, Class[] types) {
-        // First look in system functions
-        FunctionDescriptor descriptor = systemFunctions.getFunction(name, types);
-
-        // If that fails, check the user defined functions
-        if(descriptor == null) {
-            descriptor = userFunctions.getFunction(name, types);
-        }
-
-        return descriptor;
-	}
-
-	/**
-	 * Get the conversions that are needed to call the named function with arguments
-	 * of the given type.  In the case of an exact match, the list will contain all nulls.
-	 * In other cases the list will contain one or more non-null values where the value
-	 * is a conversion function that can be used to convert to the proper types for
-	 * executing the function.
-     * @param name Name of function
-	 * @param returnType
-	 * @param types Existing types passed to the function
-     * @return Null if no conversion could be found, otherwise an array of conversions
-     * to apply to each argument.  The list should match 1-to-1 with the parameters.
-     * Parameters that do not need a conversion are null; parameters that do are
-     * FunctionDescriptors.
-	 * @throws QueryResolverException 
-	 */
-	public FunctionDescriptor[] determineNecessaryConversions(String name, Class<?> returnType, Class<?>[] types, boolean hasUnknownType) {
-		// Check for no args - no conversion necessary
-		if(types.length == 0) {
-			return new FunctionDescriptor[0];
-		}
-
-		// Construct results array
-		FunctionDescriptor[] results = null;
-
-        //First find existing functions with same name and same number of parameters
-        final Collection<FunctionMethod> functionMethods = new LinkedList<FunctionMethod>();
-        functionMethods.addAll( this.systemFunctions.findFunctionMethods(name , types.length) );
-        functionMethods.addAll( this.userFunctions.findFunctionMethods(name , types.length) );
-        
-        //Score each match, reject any where types can not be converted implicitly       
-        //Score of current method (lower score means better match with less converts
-        //Current best score (lower score is best.  Higher score results in more implicit conversions
-        int bestScore = Integer.MAX_VALUE;
-        boolean ambiguous = false;
-                
-        for (FunctionMethod nextMethod : functionMethods) {
-            int currentScore = 0; 
-            final FunctionParameter[] methodTypes = nextMethod.getInputParameters();
-            //Holder for current signature with converts where required
-            FunctionDescriptor[] currentSignature = new FunctionDescriptor[types.length];
-            
-            //Iterate over the parameters adding conversions where required or failing when
-            //no implicit conversion is possible
-            int i = 0;
-            for(; i < types.length; i++) {
-            	//treat all varags as the same type
-                final String tmpTypeName = methodTypes[Math.min(i, methodTypes.length - 1)].getType();
-                Class<?> targetType = DataTypeManager.getDataTypeClass(tmpTypeName);
-
-                Class<?> sourceType = types[i];
-                if (sourceType == null) {
-                    FunctionDescriptor fd = findTypedConversionFunction(DataTypeManager.DefaultDataClasses.NULL, targetType);
-                    currentSignature[i] = fd;
-                    currentScore++;
-                    continue;
-                }
-                
-				try {
-					FunctionDescriptor fd = getConvertFunctionDescriptor(sourceType, targetType);
-					if (fd != null) {
-		                currentScore++;
-		                currentSignature[i] = fd;
-					}
-				} catch (InvalidFunctionException e) {
-					break;
-				}
-            }
-            
-            //If the method is valid match and it is the current best score, capture those values as current best match
-            if (i != types.length || currentScore > bestScore) {
-                continue;
-            }
-            
-            if (hasUnknownType) {
-            	if (returnType != null) {
-            		try {
-						FunctionDescriptor fd = getConvertFunctionDescriptor(DataTypeManager.getDataTypeClass(nextMethod.getOutputParameter().getType()), returnType);
-						if (fd != null) {
-							currentScore++;
-						}
-					} catch (InvalidFunctionException e) {
-						//there still may be a common type, but use any other valid conversion over this one
-						currentScore += (types.length + 1);
-					}
-            	}
-                ambiguous = currentScore == bestScore;
-            }
-            
-            if (currentScore < bestScore) {
-
-                if (currentScore == 0) {
-                    //this must be an exact match
-                    return currentSignature;
-                }    
-                
-                bestScore = currentScore;
-                results = currentSignature;
-            }            
-        }
-        
-        if (ambiguous) {
-            return null;
-        }
-        
-		return results;
-	}
-	
-	private FunctionDescriptor getConvertFunctionDescriptor(Class<?> sourceType, Class<?> targetType) throws InvalidFunctionException {
-		final String sourceTypeName = DataTypeManager.getDataTypeName(sourceType);
-        final String targetTypeName = DataTypeManager.getDataTypeName(targetType);
-        //If exact match no conversion necessary
-        if(sourceTypeName.equals(targetTypeName)) {
-            return null;
-        }
-        //Else see if an implicit conversion is possible.
-        if(!DataTypeManager.isImplicitConversion(sourceTypeName, targetTypeName)){
-            throw new InvalidFunctionException();
-        }
-        //Else no conversion is available and the current method is not a valid match
-        final FunctionDescriptor fd = findTypedConversionFunction(sourceType, targetType);
-        if(fd == null) {
-        	throw new InvalidFunctionException();
-        }
-        return fd;
-	}
-
-    /**
-     * Find conversion function and set return type to proper type.   
-     * @param sourceType The source type class
-     * @param targetType The target type class
-     * @return A CONVERT function descriptor or null if not possible
-     */
-    public FunctionDescriptor findTypedConversionFunction(Class sourceType, Class targetType) {
-        FunctionDescriptor fd = findFunction(CONVERT, new Class[] {sourceType, DataTypeManager.DefaultDataClasses.STRING});
-        if (fd != null) {
-            return copyFunctionChangeReturnType(fd, targetType);
-        }
-        return null;
-    }
-
-	/**
-	 * Return a copy of the given FunctionDescriptor with the sepcified return type.
-	 * @param fd FunctionDescriptor to be copied.
-	 * @param returnType The return type to apply to the copied FunctionDescriptor.
-	 * @return The copy of FunctionDescriptor.
-	 */
-    public FunctionDescriptor copyFunctionChangeReturnType(FunctionDescriptor fd, Class returnType) {
-        if(fd != null) {
-        	FunctionDescriptor fdImpl = fd;
-            FunctionDescriptor copy = (FunctionDescriptor)fdImpl.clone();
-            copy.setReturnType(returnType);
-            return copy;
-        }
-        return fd;
-    }
-    
-    public static boolean isConvert(Function function) {
-        Expression[] args = function.getArgs();
-        String funcName = function.getName().toLowerCase();
-        
-        return args.length == 2 && (funcName.equalsIgnoreCase(FunctionLibrary.CONVERT) || funcName.equalsIgnoreCase(FunctionLibrary.CAST));
-    }
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,55 +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.function;
-
-import java.util.Collection;
-
-import com.metamatrix.query.function.metadata.FunctionMethod;
-
-/**
- * A FunctionMetadataSource represents a source of function metadata for
- * the function library.  A FunctionMetadataSource needs to know how to 
- * return a collection of all the function signatures it knows about.
- */
-public interface FunctionMetadataSource {
-
-    /**
-     * This method requests that the source return all 
-     * {@link com.metamatrix.query.function.FunctionMethod}s
-     * the source knows about.  This can occur in several situations - 
-     * on initial registration with the FunctionLibraryManager, on a 
-     * general reload, etc.  This may be called multiple times and should
-     * always return the newest information available.
-     * @return Collection of FunctionMethod objects
-     */
-    Collection<FunctionMethod> getFunctionMethods();
-    
-    /**
-     * This method determines where the invocation classes specified in the 
-     * function metadata are actually retrieved from.  
-     * @param className Name of class
-     * @return Class reference  
-     * @throws ClassNotFoundException If class could not be found
-     */
-    Class getInvocationClass(String className) throws ClassNotFoundException;    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,1249 +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.function;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Properties;
-import java.util.TimeZone;
-
-import org.teiid.connector.language.SQLReservedWords;
-
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.common.util.TimestampWithTimezone;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-public final class FunctionMethods {
-
-	// ================== Function = plus =====================
-
-	public static int plus(int x, int y) {
-		return x + y;
-	}
-	
-	public static long plus(long x, long y) {
-		return x + y;
-	}
-	
-	public static float plus(float x, float y) {
-		return x + y;
-	}
-	
-	public static double plus(double x, double y) {
-		return x + y;
-	}
-	
-	public static Object plus(BigInteger x, BigInteger y) {
-		return x.add(y);
-	}
-	
-	public static Object plus(BigDecimal x, BigDecimal y) {
-		return x.add(y);
-	}
-
-	// ================== Function = minus =====================
-
-	public static int minus(int x, int y) {
-		return x - y;
-	}
-	
-	public static long minus(long x, long y) {
-		return x - y;
-	}
-	
-	public static float minus(float x, float y) {
-		return x - y;
-	}
-	
-	public static double minus(double x, double y) {
-		return x - y;
-	}
-	
-	public static Object minus(BigInteger x, BigInteger y) {
-		return x.subtract(y);
-	}
-	
-	public static Object minus(BigDecimal x, BigDecimal y) {
-		return x.subtract(y);
-	}
-
-	// ================== Function = multiply =====================
-
-	public static int multiply(int x, int y) {
-		return x * y;
-	}
-	
-	public static long multiply(long x, long y) {
-		return x * y;
-	}
-	
-	public static float multiply(float x, float y) {
-		return x * y;
-	}
-	
-	public static double multiply(double x, double y) {
-		return x * y;
-	}
-	
-	public static Object multiply(BigInteger x, BigInteger y) {
-		return x.multiply(y);
-	}
-	
-	public static Object multiply(BigDecimal x, BigDecimal y) {
-		return x.multiply(y);
-	}
-
-	// ================== Function = divide =====================
-
-	public static int divide(int x, int y) {
-		return x / y;
-	}
-	
-	public static long divide(long x, long y) {
-		return x / y;
-	}
-	
-	public static float divide(float x, float y) {
-		return x / y;
-	}
-	
-	public static double divide(double x, double y) {
-		return x / y;
-	}
-	
-	public static Object divide(BigInteger x, BigInteger y) {
-		return x.divide(y);
-	}
-	
-	public static Object divide(BigDecimal x, BigDecimal y) {
-		return x.divide(y, BigDecimal.ROUND_HALF_UP);
-	}
-
-	// ================== Function = abs =====================
-
-	public static int abs(int x) {
-		return Math.abs(x);
-	}
-	
-	public static long abs(long x) {
-		return Math.abs(x);
-	}
-	
-	public static float abs(float x) {
-		return Math.abs(x);
-	}
-	
-	public static double abs(double x) {
-		return Math.abs(x);
-	}
-	
-	public static Object abs(BigInteger x) {
-		return x.abs();
-	}
-	
-	public static Object abs(BigDecimal x) {
-		return x.abs();
-	}
-
-	// ================== Function = ceiling =====================
-
-	public static Object ceiling(Number x) {
-		return new Double(Math.ceil(x.doubleValue()));
-	}
-
-	// ================== Function = exp =====================
-
-	public static Object exp(Number x) {
-		return new Double(Math.exp(x.doubleValue()));
-	}
-
-	// ================== Function = floor =====================
-
-	public static  Object floor(Number x) {
-		return new Double(Math.floor(x.doubleValue()));
-	}
-
-	// ================== Function = log =====================
-
-	public static  Object log(Number x) {
-		return new Double(Math.log(x.doubleValue()));
-	}
-
-	// ================== Function = log10 =====================
-
-	private static final double log10baseE = Math.log(10);
-
-	public static Object log10(Number x) {
-		return new Double( Math.log(x.doubleValue()) / log10baseE);
-	}
-    
-    // ================== Function = rand=====================
-    
-    public static Object rand(CommandContext context, Object seed) throws FunctionExecutionException {        
-        if(context != null) {
-            if(seed == null) {
-                return new Double(context.getNextRand());
-            } else if(seed instanceof Integer) {
-                return new Double(context.getNextRand(((Integer)seed).longValue()));
-            }
-        }
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0069, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0069, "rand", seed)); //$NON-NLS-1$        
-    }
-        
-    public static Object rand(CommandContext context) throws FunctionExecutionException {
-        if(context != null) {
-            return new Double(context.getNextRand());
-        }
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0069, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0069, "rand")); //$NON-NLS-1$
-    }
-    
-	// ================== Function = mod =====================
-
-	public static int mod(int x, int y) {
-		return x % y;
-	}
-	
-	public static long mod(long x, long y) {
-		return x % y;
-	}
-	
-	public static float mod(float x, float y) {
-		return x % y;
-	}
-	
-	public static double mod(double x, double y) {
-		return x % y;
-	}
-	
-	public static Object mod(BigInteger x, BigInteger y) {
-		return x.remainder(y);
-	}
-	
-	public static Object mod(BigDecimal x, BigDecimal y) {
-		return x.remainder(y);
-	}
-    
-	// ================== Function = power =====================
-	
-	public static double power(double x, double y) {
-		return Math.pow(x, y);
-	}
-	
-	public static BigInteger power(BigInteger x, int y) {
-		return x.pow(y);
-	}
-	
-	public static BigDecimal power(BigDecimal x, int y) {
-		return x.pow(y);
-	}
-
-    public static int round(int number, int places) {
-        if(places < 0){
-        	return round(new BigDecimal(number), places).intValue();
-        }
-        return number;
-    }
-    
-    public static float round(float number, int places) {
-    	return round(new BigDecimal(number), places).floatValue();
-    }
-    
-    public static double round(double number, int places) {
-    	return round(new BigDecimal(number), places).doubleValue();
-    }
-    
-    public static BigDecimal round(BigDecimal bigDecimalNumber, int places) {
-        int scale = bigDecimalNumber.scale();
-        if (scale <= places) {
-        	return bigDecimalNumber;
-        }
-        bigDecimalNumber = bigDecimalNumber.setScale(places,BigDecimal.ROUND_HALF_UP);
-        return bigDecimalNumber.setScale(scale,BigDecimal.ROUND_HALF_UP);
-    }
-
-	// ================== Function = sign =====================
-
-	public static Object sign(int x) {
-		return Integer.signum(x);
-	}
-	
-	public static Object sign(long x) {
-		return Long.signum(x);
-	}
-
-	public static Object sign(float x) {
-		return Math.signum(x);
-	}
-	
-	public static Object sign(double x) {
-		return Math.signum(x);
-	}
-	
-	public static Object sign(BigInteger x) {
-		return new Integer(x.signum());
-	}
-	
-	public static Object sign(BigDecimal x) {
-		return new Integer(x.signum());
-	}
-
-	// ================== Function = sqrt =====================
-
-
-	public static  Object sqrt(Number x) {
-		return new Double( Math.sqrt(x.doubleValue()));
-	}
-
-	// ================== Function = currentDate =====================
-
-	public static  Object currentDate() {
-		return TimestampWithTimezone.createDate(new Date());
-	}
-
-	// ================== Function = currentTime =====================
-
-	public static  Object currentTime() {
-		return TimestampWithTimezone.createTime(new Date());
-	}
-
-	// ================== Function = currentTimestamp =====================
-
-	public static  Object currentTimestamp() {
-		return new Timestamp(System.currentTimeMillis());
-	}
-
-	// ================== Helper for a bunch of date functions =====================
-
-	private static int getField(java.util.Date date, int field) {
-		Calendar cal = TimestampWithTimezone.getCalendar();
-		cal.setTime(date);
-
-		return cal.get(field);
-	}
-
-	// ================== Function = dayname =====================
-
-	static final String[] dayNames = new String[] {
-		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
-
-	public static Object dayName(Date x) {
-		return dayNames[getField(x, Calendar.DAY_OF_WEEK) - 1];
-	}
-
-	// ================== Function = dayofmonth =====================
-
-	public static  Object dayOfMonth(Date x) {
-		return Integer.valueOf(getField(x, Calendar.DATE));
-	}
-
-	// ================== Function = dayofweek =====================
-
-	public static Object dayOfWeek(Date x) {
-		return Integer.valueOf(getField(x, Calendar.DAY_OF_WEEK));
-	}
-
-	// ================== Function = dayofyear =====================
-
-	public static Object dayOfYear(Date x) {
-		return Integer.valueOf(getField(x, Calendar.DAY_OF_YEAR));
-	}
-
-	// ================== Function = hour =====================
-
-	public static Object hour(Date x) {
-		return Integer.valueOf(getField(x, Calendar.HOUR_OF_DAY));
-	}
-
-	// ================== Function = minute =====================
-
-	public static Object minute(Date x) {
-		return Integer.valueOf(getField(x, Calendar.MINUTE));
-	}
-
-	// ================== Function = month =====================
-
-	public static Object month(Date x) {
-		return Integer.valueOf(getField(x, Calendar.MONTH)+1);
-	}
-
-	// ================== Function = monthname =====================
-
-	static final String[] monthNames = new String[] {
-		"January", "February", "March", "April", "May", "June", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
-		"July", "August", "September", "October", "November", "December" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
-
-	public static Object monthName(Date x) {
-		return monthNames[getField(x, Calendar.MONTH)];
-	}
-
-	// ================== Function = second =====================
-
-	public static Object second(Date x) {
-		return Integer.valueOf(getField(x, Calendar.SECOND));
-	}
-
-	// ================== Function = week =====================
-
-	public static Object week(Date x) {
-		return Integer.valueOf(getField(x, Calendar.WEEK_OF_YEAR));
-	}
-
-	// ================== Function = year =====================
-
-	public static Object year(Date x) {
-		return Integer.valueOf(getField(x, Calendar.YEAR));
-	}
-
-	// ================== Function = quarter =====================
-
-	public static Object quarter(Date date)
-		throws FunctionExecutionException {
-		int month = getField(date, Calendar.MONTH);
-		
-		if (month > 11) {
-			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0066, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0066,
-					new Object[] {"quarter", date.getClass().getName()})); //$NON-NLS-1$
-		}
-		return Integer.valueOf(month/3 + 1);
-	}
-
-	//	================== Function = timestampadd =====================
-
-	public static Object timestampAdd(String intervalType, Integer count, Timestamp timestamp) {
-		Calendar cal = TimestampWithTimezone.getCalendar();
-
-		int nanos = timestamp.getNanos();
-		cal.setTime(timestamp);
-
-		// case of interval = 1, fractional seconds (nanos), don't go to branches of addField()
-		if (intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
-			int countValue = count.intValue();
-			nanos += countValue;
-
-			// Handle the case of nanos > 999,999,999 and increase the second.
-			// Since the count number is an interger, so the maximum is definite,
-			// and nanos/999,999,999 can at most be added to second
-			if ( nanos > 999999999) {
-				int addSecond = nanos / 999999999;
-				int leftNanos = nanos % 999999999;
-				cal.add(Calendar.SECOND, addSecond);
-
-				Timestamp ts = new Timestamp(cal.getTime().getTime());
-				ts.setNanos(leftNanos);
-				return ts;
-			} 
-            // nanos <= 999,999,999
-			Timestamp ts = new Timestamp(cal.getTime().getTime());
-			ts.setNanos(nanos);
-			return ts;
-		}
-        // for interval from 2 to 9
-		addField(intervalType, count, cal);
-		Timestamp ts = new Timestamp(cal.getTime().getTime());
-
-		//rectify returned timestamp with original nanos
-		ts.setNanos(nanos);
-		return ts;
-	}
-	
-	/** Helper method for timestampAdd method
-	 * @param interval Integer
-	 * @param count Integer
-	 * @param cal Calendar instance
-	 */
-	private static void addField(String interval, Integer count, Calendar cal) {
-		int countValue = count.intValue();
-
-        if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
-            //nano seconds - should never get into this branch
-        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_SECOND)) {
-            cal.add(Calendar.SECOND, countValue);
-        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MINUTE)) {
-            cal.add(Calendar.MINUTE, countValue);
-        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_HOUR)) {
-            cal.add(Calendar.HOUR_OF_DAY, countValue);
-        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_DAY)) {
-            cal.add(Calendar.DAY_OF_YEAR, countValue);
-        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_WEEK)) {
-            cal.add(Calendar.WEEK_OF_YEAR, countValue);
-        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MONTH)) {
-            cal.add(Calendar.MONTH, countValue);
-        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_QUARTER)) {
-            cal.add(Calendar.MONTH, countValue*3);
-        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_YEAR)) {
-            cal.add(Calendar.YEAR, countValue);
-        }
-	}
-
-	//	================== Function = timestampdiff =====================
-
-	/**
-     * This method truncates (ignores) figures
-     * @param interval
-     * @param timestamp1
-     * @param timestamp2
-     * @return
-     * @throws FunctionExecutionException
-     */
-    public static Object timestampDiff(String intervalType, Timestamp ts1Obj, Timestamp ts2Obj)  {
-        long ts1 = ts1Obj.getTime() / 1000 * 1000000000 + ts1Obj.getNanos();
-        long ts2 = ts2Obj.getTime() / 1000 * 1000000000 + ts2Obj.getNanos();
-        
-        long tsDiff = ts2 - ts1;
-
-        long count = 0;
-        if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
-            count = tsDiff;
-        } else { 
-        	tsDiff = tsDiff / 1000000; //convert to milliseconds
-            if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_SECOND)) {
-                count = tsDiff / 1000;
-            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MINUTE)) {
-                count = (tsDiff / 1000) / 60;
-            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_HOUR)) {
-                count = (tsDiff / 1000) / (60*60);
-            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_DAY)) {
-                count = (tsDiff / 1000) / (60*60*24);
-            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_WEEK)) {
-                count = (tsDiff / 1000) / (60*60*24*7);
-            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MONTH)) {
-                count = (tsDiff / 1000) / (60*60*24*30);
-            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_QUARTER)) {
-                count = (tsDiff / 1000) / (60*60*24*91);
-            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_YEAR)) {
-                count = (tsDiff / 1000) / (60*60*24*365);
-            }    
-        }
-        return new Long(count);
-	}
-
-    //  ================== Function = timestampcreate =====================
-
-    /**
-     * This method truncates (ignores) figures
-     * @param interval
-     * @param timestamp1
-     * @param timestamp2
-     * @return
-     * @throws FunctionExecutionException
-     */
-    public static Object timestampCreate(java.sql.Date date, Time time) {
-        Calendar tsCal = TimestampWithTimezone.getCalendar();
-        tsCal.setTime(time);
-        int hour = tsCal.get(Calendar.HOUR_OF_DAY);
-        int minute = tsCal.get(Calendar.MINUTE);
-        int second = tsCal.get(Calendar.SECOND);
-        
-        tsCal.setTime(date);
-        
-        tsCal.set(Calendar.HOUR_OF_DAY, hour);
-        tsCal.set(Calendar.MINUTE, minute);
-        tsCal.set(Calendar.SECOND, second);
-
-        return new Timestamp(tsCal.getTime().getTime());
-    }
-
-	// ================== Function = length =====================
-
-	public static Object length(String str) {
-		return new Integer(str.length());
-	}
-
-	// ================== Function = concat =====================
-
-	public static Object concat(String str1, String str2) {
-		return str1 + str2;
-	}
-
-	// ================== Function = substring =====================
-
-	public static Object substring(String string, Integer startVal, Integer lengthVal) {
-		if (startVal < 0) {
-        	startVal = string.length() + startVal;
-        } else if (startVal > 0){
-            startVal--;     // Adjust to 1-based
-        }
-		
-		if(startVal < 0 || startVal >= string.length()) {
-		    return null;
-		}
-
-		if(lengthVal < 0) {
-		    return null;
-		}
-
-		int endVal = Math.min(startVal+lengthVal, string.length());
-
-		return string.substring(startVal, endVal);
-	}
-
-    public static Object substring(String string, Integer start) {
-        int startVal = start.intValue();
-        return substring(string, startVal, string.length());
-    }
-
-	// ================== Function = left =====================
-
-	public static Object left(String string, Integer count)
-		throws FunctionExecutionException {
-		int countValue = count.intValue();
-        if(countValue < 0) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0017, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0017, countValue));
-        } 
-        if(string.length() < countValue) {
-            return string;
-        }
-        return string.substring(0, countValue);
-	}
-
-	// ================== Function = right =====================
-
-	public static Object right(String string, Integer count) 
-		throws FunctionExecutionException {
-		int countValue = count.intValue();
-        if(countValue < 0) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0017, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0017, countValue));
-        } else if(string.length() < countValue) {
-            return string;
-		} else {
-			return string.substring(string.length() - countValue);
-        }
-	}
-
-	// ================== Function = lowercase =====================
-
-	public static Object lowerCase(String str) {
-		return str.toLowerCase();
-	}
-
-	// ================== Function = uppercase =====================
-
-	public static Object upperCase(String str) {
-		return str.toUpperCase();
-	}
-
-	// ================== Function = locate =====================
-
-	public static Object locate(String sub, String str) {
-		return locate(sub, str, 1);
-	}
-
-	/**
-	 * TODO: The treatment of negative start indexes is inconsistent here.
-	 * We're treating the null value like Derby, but not throwing an
-	 * exception if the value is less than 1 (less than 0 in DB2).
-	 */
-	public static Object locate(String sub, String str, Integer start) {
-		if(str == null || sub == null) {
-			return null;
-		} 
-		if (start == null) {
-			start = 1;
-		}
-		return new Integer(str.indexOf(sub, start.intValue() - 1) + 1);
-	}
-
-	// ================== Function = lefttrim =====================
-
-	private static final char SPACE = ' ';
-
-	public static Object leftTrim(String string) {
-		for(int i=0; i<string.length(); i++) {
-			if(string.charAt(i) != SPACE) {
-				// end of trim, return what's left
-				return string.substring(i);
-			}
-		}
-
-		// All spaces, so trim it all
-		return ""; //$NON-NLS-1$
-	}
-
-	// ================== Function = righttrim =====================
-
-	public static Object rightTrim(String string) {
-		for(int i=string.length()-1; i>=0; i--) {
-			if(string.charAt(i) != SPACE) {
-				// end of trim, return what's left
-				return string.substring(0, i+1);
-			}
-		}
-
-		// All spaces, so trim it all
-		return ""; //$NON-NLS-1$
-	}
-
-	// ================== Function = replace =====================
-
-	public static Object replace(String string, String subString, String replaceString) {
-		// Check some simple cases that require no work
-		if(subString.length() > string.length() || string.length() == 0 || subString.length() == 0) {
-			return string;
-		}
-
-		StringBuffer result = new StringBuffer();
-		int index = 0;
-
-		while(true) {
-			int newIndex = string.indexOf(subString, index);
-			if(newIndex < 0) {
-				// No more replacement sections, grab from old index to end of string
-				result.append( string.substring(index) );
-
-				// Break out of loop
-				break;
-
-			}
-			// Matched the substring at newIndex
-
-			// First append section from old index to new
-			result.append( string.substring( index, newIndex) );
-
-			// Then append replacement section for sub
-			result.append( replaceString );
-
-			// Then move the index counter forward
-			index = newIndex + subString.length();
-		}
-
-		return result.toString();
-	}
-
-	// ================== Function = insert =====================
-
-	public static Object insert(String string1, Integer start, Integer length, String str2)
-		throws FunctionExecutionException {
-		int startValue = start.intValue();
-		int len = length.intValue();
-
-		// Check some invalid cases
-		if(startValue < 1 || (startValue-1) > string1.length()) {
-			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0061, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0061, start, string1));
-		} else if (len < 0) {
-			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0062, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0062, len));
-		} else if (string1.length() == 0 && (startValue > 1 || len >0) ) {
-			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0063, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0063));
-		}
-
-		StringBuffer result = new StringBuffer();
-		result.append(string1.substring(0, startValue-1));
-		int endValue = startValue + len - 1;
-
-		// str2.length() = 0 is a valid case
-		if (endValue > string1.length()) {
-			result.append(str2);
-		} else {
-			result.append(str2);
-			result.append(string1.substring( endValue ));
-		}
-
-		return result.toString();
-	}
-
-	// ================== Function = repeat =====================
-	public static Object repeat(String str, Integer count) {
-		int repeatCount = count.intValue();
-		StringBuffer result = new StringBuffer();
-
-		for (int i = 0; i < repeatCount && result.length() <= DataTypeManager.MAX_STRING_LENGTH; i++) {
-			result.append(str);
-		}
-		return result.toString();
-	}
-
-    // ================== Function = ascii =====================
-
-    public static Integer ascii(String ch) {
-        if(ch.length() == 0) {
-        	return null;
-        } 
-        return (int)ch.charAt(0);
-    }
-    
-    public static Integer ascii(Character ch) {
-        return (int)ch.charValue();
-    }
-
-    // ================== Function = chr =====================
-
-    public static Object chr(int intValue) {
-        return new Character((char) intValue);
-    }
-
-    // ================== Function = initCap =====================
-
-    public static Object initCap(String s) {
-        StringBuffer cap = new StringBuffer();
-
-        boolean checkCap = true;
-        for(int i=0; i<s.length(); i++) {
-            char c = s.charAt(i);
-
-            // Decide whether to upper case
-            if(checkCap) {
-                cap.append(Character.toUpperCase(c));
-            } else {
-                cap.append(Character.toLowerCase(c));
-            }
-
-            // Reset flag for next character
-            checkCap = Character.isWhitespace(c);
-        }
-        return cap.toString();
-    }
-
-    // ================== Function = lpad =====================
-
-    public static Object lpad(String inputString, Integer padLength, String padStr)
-        throws FunctionExecutionException {
-
-    	return pad(inputString, padLength, padStr, true);
-    }
-
-    public static Object pad(String str, Integer padLength, String padStr, boolean left)
-    throws FunctionExecutionException {
-	    int length = padLength.intValue();
-	    if(length < 1) {
-	        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0025, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0025));
-	    }
-	    if(length < str.length()) {
-	        return str.substring(0, length);
-	    }
-	    if(length > DataTypeManager.MAX_STRING_LENGTH) {
-	    	length = DataTypeManager.MAX_STRING_LENGTH;
-	    }
-	    // Get pad character
-	    if(padStr.length() == 0) {
-	        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0027, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0027));
-	    }
-	    // Pad string
-	    StringBuffer outStr = new StringBuffer(str);
-	    while(outStr.length() < length) {
-	    	if (left) {
-	    		outStr.insert(0, padStr);
-	    	} else {
-	    		outStr.append(padStr);
-	    	}
-	    }
-	    if (left) {
-	    	return outStr.substring(outStr.length() - length);
-	    }
-	    return outStr.substring(0, length);
-	}
-
-    
-    public static final String SPACE_CHAR = " "; //$NON-NLS-1$
-
-    public static Object lpad(String inputString, Integer padLength)
-        throws FunctionExecutionException {
-
-        return lpad(inputString, padLength, SPACE_CHAR);
-    }
-
-    // ================== Function = rpad =====================
-
-    public static Object rpad(String inputString, Integer padLength, String padStr)
-        throws FunctionExecutionException {
-
-    	return pad(inputString, padLength, padStr, false);
-    }
-
-    public static Object rpad(String inputString, Integer padLength)
-        throws FunctionExecutionException {
-
-        return rpad(inputString, padLength, SPACE_CHAR);
-    }
-
-    // ================== Function = translate =====================
-
-    public static Object translate(String str, String in, String out)
-        throws FunctionExecutionException {
-        if(in.length() != out.length()) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0031, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0031));
-        }
-
-        if(in.length() == 0 || str.length() == 0) {
-            return str;
-        }
-
-        StringBuffer translated = new StringBuffer(str.length());
-        for(int i=0; i<str.length(); i++) {
-            char c = str.charAt(i);
-            boolean matched = false;
-            for(int j=0; j<in.length(); j++) {
-                char inChar = in.charAt(j);
-                if(c == inChar) {
-                    translated.append(out.charAt(j));
-                    matched = true;
-                    break;
-                }
-            }
-            if(! matched) {
-                translated.append(c);
-            }
-        }
-        return translated.toString();
-    }
-
-	// ================== Function = convert =====================
-
-	@SuppressWarnings("unchecked")
-	public static Object convert(Object src, String type)
-		throws FunctionExecutionException {
-		try {
-			return DataTypeManager.transformValue(src, DataTypeManager.getDataTypeClass(type));
-		} catch(TransformationException e) {
-			throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0033, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0033, new Object[]{src, DataTypeManager.getDataTypeName(src.getClass()), type}));
-		}
-	}
-
-    // ================== Function = context and rowlimit =====================
-
-    /**
-     * This function should never actually be called - it is here solely so the
-     * xml context function can be resolved properly.  The actual function is
-     * implemented in the XML planner.
-     * @param context The context to apply the criteria in
-     * @param expression The expression on the left side of the criteria
-     * @return Same as expression
-     */
-    public static Object context(Object context, Object expression)
-        throws FunctionExecutionException {
-
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0035, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0035));
-    }
-
-    /**
-     * This pseudo-function should never actually be called - it is here solely so the
-     * xml rowlimit function can be resolved properly.  The actual functionality is
-     * implemented in the XML planner/processor.
-     * @param expression The expression on the left side of the criteria, an xml node
-     * @return doesn't really return anything; this pseudo-function is used to control
-     * the number of rows returned from a mapping class.
-     */
-    public static Object rowlimit(Object expression)
-        throws FunctionExecutionException {
-    
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0035a, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0035a));
-    }    
-
-    /**
-     * This pseudo-function should never actually be called - it is here solely so the
-     * xml rowlimitexception function can be resolved properly.  The actual functionality is
-     * implemented in the XML planner/processor.
-     * @param expression The expression on the left side of the criteria, an xml node
-     * @return doesn't really return anything; this pseudo-function is used to control
-     * the number of rows returned from a mapping class.
-     */
-    public static Object rowlimitexception(Object expression)
-        throws FunctionExecutionException {
-    
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0035a, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0035a));
-    }      
-    
-    // ================== Function = lookup =====================
-
-    /**
-     * This function should never actually be called - it is here solely so the
-     * lookup function can be resolved properly.  The actual function is
-     * implemented in the ExpresionEvaluator
-     * @param context The context to apply the criteria in
-     * @param expression The expression on the left side of the criteria
-     * @return Same as expression
-     */
-    public static Object lookup(Object codeTable, Object returnElement, Object keyElement, Object keyValue) {
-
-        throw new UnsupportedOperationException("This method should never be called."); //$NON-NLS-1$
-    }
-	
-    // ================== Function = nvl =====================
-    
-    public static Object ifnull(Object value, Object ifNullValue) {
-    	return coalesce(value, ifNullValue);
-    }
-    
-    public static Object coalesce(Object value, Object value1, Object... other) {
-    	if (value != null) {
-    		return value;
-    	}
-    	if (value1 != null) {
-    		return value1;
-    	}
-        for (Object object : other) {
-			if (object != null) {
-				return object;
-			}
-		}
-        return null;
-    }
-
-	// ================== Format date/time/timestamp TO String ==================
-	public static String format(Date date, String format)
-		throws FunctionExecutionException {
-		try {
-            SimpleDateFormat sdf = new SimpleDateFormat(format);
-            return sdf.format(date);
-		} catch (IllegalArgumentException iae) {
-			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0042, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0042 ,
-				iae.getMessage()));
-		}
-	}
-
-	//	================== Parse String TO date/time/timestamp  ==================
-	private static Date parseDateHelper(String date, String format)
-			throws FunctionExecutionException {
-		DateFormat df = new SimpleDateFormat(format);
-		try {
-			return df.parse(date);
-		} catch (ParseException e) {
-			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
-					date, format));
-		}
-	}
-	
-	public static Timestamp parseTimestamp(String timestamp, String format)
-		throws FunctionExecutionException {
-        return new Timestamp(parseDateHelper(timestamp, format).getTime());
-	}
-
-	//	================== Format number TO String ==================
-	public static String format(Number number, String format)
-	throws FunctionExecutionException {
-		try {
-	        DecimalFormat df = new DecimalFormat(format);
-	        return df.format(number);
-		} catch (IllegalArgumentException iae) {
-			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0042, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0042 ,
-			iae.getMessage()));
-		}
-	}
-
-	//	================== Parse String TO numbers ==================
-	public static Object parseInteger(String number, String format)
-		throws FunctionExecutionException {
-		Number intNum = parseNumberHelper(number, format);
-		return new Integer(intNum.intValue());
-	}
-
-	public static Object parseLong(String number, String format)
-		throws FunctionExecutionException {
-		Number longNum = parseNumberHelper(number, format);
-		return new Long(longNum.longValue());
-	}
-
-	public static Object parseDouble(String number, String format)
-		throws FunctionExecutionException {
-		Number doubleNum = parseNumberHelper(number, format);
-		return new Double(doubleNum.doubleValue());
-	}
-
-	public static Object parseFloat(String number, String format)
-		throws FunctionExecutionException {
-		Number longNum = parseNumberHelper(number, format);
-		return new Float(longNum.floatValue());
-	}
-
-	public static Object parseBigInteger(String number, String format)
-		throws FunctionExecutionException {
-		Number bigIntegerNum = parseNumberHelper(number, format);
-		return new BigInteger(bigIntegerNum.toString());
-	}
-
-	public static Object parseBigDecimal(String number, String format)
-		throws FunctionExecutionException {
-		Number bigDecimalNum = parseNumberHelper(number, format);
-		return new BigDecimal(bigDecimalNum.toString());
-	}
-
-	// ============== Helper Function for format/parse numbers ==================
-
-	private static Number parseNumberHelper(String number, String format)
-		throws FunctionExecutionException {
-		DecimalFormat df= new DecimalFormat(format);
-		try {
-			return df.parse(number);
-		} catch (ParseException e) {
-			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
-					number,format));
-		}
-	}
-
-	// ================== Function - ACOS =====================
-	public static Object acos(Number number) {
-		return new Double(Math.acos(number.doubleValue()));
-	}
-
-	// ================== Function - ASIN =====================
-	public static Object asin(Number number) {
-		return new Double(Math.asin(number.doubleValue()));
-	}
-
-	// ================== Function - ATAN =====================
-	public static Object atan(Number number) {
-		return new Double(Math.atan(number.doubleValue()));
-	}
-
-	// ================== Function - ATAN2 =====================
-	public static Object atan2(Number number1, Number number2) {
-		return new Double(Math.atan2(number1.doubleValue(), number2.doubleValue()));
-	}
-
-	// ================== Function - COS =====================
-	public static Object cos(Number number) {
-		return new Double(Math.cos(number.doubleValue()));
-	}
-
-	// ================== Function - COT =====================
-	public static Object cot(Number number) {
-		return new Double(1/Math.tan(number.doubleValue()));
-	}
-
-	// ================== Function - DEGREES =====================
-	public static Object degrees(Number number) {
-		return new Double(Math.toDegrees(number.doubleValue()));
-	}
-
-	// ================== Function - PI =====================
-	public static Object pi() {
-		return new Double(Math.PI);
-	}
-
-	// ================== Function - RADIANS =====================
-	public static Object radians(Number number) {
-		return new Double(Math.toRadians(number.doubleValue()));
-	}
-
-	// ================== Function - SIN =====================
-	public static Object sin(Number number) {
-		return new Double(Math.sin(number.doubleValue()));
-	}
-
-	// ================== Function - TAN =====================
-	public static Object tan(Number number) {
-		return new Double(Math.tan(number.doubleValue()));
-	}
-
-    // ================== Function - BITAND =====================
-	public static Object bitand(int x, int y) {
-        return x & y;
-	}
-
-    // ================== Function - BITOR =====================
-    public static Object bitor(int x, int y) {
-        return x | y;
-    }
-
-    // ================== Function - BITXOR =====================
-    public static Object bitxor(int x, int y) {
-        return x ^ y;
-    }
-
-    // ================== Function - BITNOT =====================
-    public static int bitnot(int x) {
-        return x ^ 0xFFFFFFFF;
-    }
-
-    // ================= Function - USER ========================
-    public static Object user(CommandContext context) {
-        return context.getUserName();
-    }
-
-    // ================= Function - COMMANDPAYLOAD ========================
-    public static Object commandPayload(CommandContext context) {
-        Serializable payload = context.getCommandPayload();
-        if(payload == null) {
-            return null;
-        }
-        // 0-arg form - just return payload as a string if it exists
-        return payload.toString();
-    }
-
-    public static Object commandPayload(CommandContext context, String param) 
-        throws ExpressionEvaluationException, FunctionExecutionException{
-        Serializable payload = context.getCommandPayload();
-        if(payload == null) {
-            return null;
-        }
-        
-        // 1-arg form - assume payload is a Properties object
-        if(payload instanceof Properties) {
-            return ((Properties)payload).getProperty(param);
-        }            
-        // Payload was bad
-        throw new ExpressionEvaluationException(QueryPlugin.Util.getString("ExpressionEvaluator.Expected_props_for_payload_function", "commandPayload", payload.getClass().getName())); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // ================= Function - ENV ========================
-    public static Object env(CommandContext context, String propertyName) {
-        // All context property keys must be lowercase - we lowercase the incoming key here to match regardless of case
-        String propertyNameNocase = propertyName.toLowerCase();
-        Properties envProps = context.getEnvironmentProperties();
-        if(envProps != null && envProps.containsKey(propertyNameNocase)) {
-            return envProps.getProperty(propertyNameNocase);
-        }
-        String value = System.getProperty(propertyName);
-        if (value == null) {
-            value = System.getProperty(propertyNameNocase);
-        }
-        return value;            
-    }
-    
-    // ================= Function - MODIFYTIMEZONE ========================
-    
-    public static Object modifyTimeZone(Timestamp value, String originalTimezoneString, String targetTimezoneString) {
-        TimeZone originalTimeZone = TimeZone.getTimeZone(originalTimezoneString);
-        TimeZone dbmsTimeZone = TimeZone.getTimeZone(targetTimezoneString);
-
-        // Check that the dbms time zone is really different than the local time zone
-        if (originalTimeZone.equals(dbmsTimeZone)) {
-            return value;
-        }
-
-        Calendar cal = Calendar.getInstance(dbmsTimeZone);
-        
-        return TimestampWithTimezone.createTimestamp(value, originalTimeZone, cal);
-    }
-
-    public static Object modifyTimeZone(CommandContext context, Timestamp value, String targetTimezoneString) {
-        TimeZone dbmsTimeZone = TimeZone.getTimeZone(targetTimezoneString);
-
-        Calendar cal = Calendar.getInstance(dbmsTimeZone);
-        
-        return TimestampWithTimezone.createTimestamp(value, context.getServerTimeZone(), cal);
-    } 
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,415 +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.function;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.metadata.FunctionCategoryConstants;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.function.metadata.FunctionParameter;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-/**
- * Data structure used to store function signature information. There are multiple uses
- * of this signature information so there are multiple data structures within the FunctionTree
- * for handling each.  One type of information is the function metadata required by users of
- * this class for data driving GUIs or function selection.  The other type of information is that
- * needed to quickly find and/or invoke the functions at execution time.  In general all methods
- * are concerned with function metadata EXCEPT {@link #getFunction} which is used to find a function
- * for execution.
- */
-public class FunctionTree {
-
-    // Constant used to look up the special descriptor key in a node map
-    private static final Integer DESCRIPTOR_KEY = new Integer(-1);
-
-    private Map<String, Set<String>> categories = new HashMap<String, Set<String>>();
-
-    private Map<String, List<FunctionMethod>> functionsByName = new HashMap<String, List<FunctionMethod>>();
-    
-    private Set<FunctionMethod> allFunctions = new HashSet<FunctionMethod>();
-
-	/**
-	 * Function lookup and invocation use: Function name (uppercase) to Map (recursive tree)
-	 */
-    private Map treeRoot = new HashMap();
-
-    /**
-     * Construct a new tree with the given source of function metadata.
-     * @param source The metadata source
-     */
-    public FunctionTree(FunctionMetadataSource source) {
-        // Load data structures
-        addSource(source);
-    }
-
-    /**
-     * Construct a new tree with the given collection of sources.
-     * @param sources The collection of function metadata sources ({@link com.metamatrix.query.function.FunctionMetadataSource})
-     */
-    FunctionTree(Collection sources) {
-        // Load data structures
-        addSources(sources);
-    }
-
-    /**
-     * Add a collection of functions to the data structures.
-     * @param sources The function metadata sources ({@link com.metamatrix.query.function.FunctionMetadataSource})
-     */
-    private void addSources(Collection sources) {
-        if(sources == null) {
-            return;
-        }
-
-        Iterator sourceIter = sources.iterator();
-        while(sourceIter.hasNext()) {
-            Object sourceObj = sourceIter.next();
-            if(sourceObj instanceof FunctionMetadataSource) {
-                addSource((FunctionMetadataSource) sourceObj);
-            } else {
-                Assertion.failed(QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0044, sourceObj.getClass().getName()));
-            }
-        }
-    }
-
-    /**
-     * Add all functions from a metadata source to the data structures.
-     * @param source The source of the functions
-     */
-    private void addSource(FunctionMetadataSource source) {
-        if(source == null) {
-            return;
-        }
-
-        Collection functions = source.getFunctionMethods();
-        if(functions != null) {
-            Iterator functionIter = functions.iterator();
-            while(functionIter.hasNext()) {
-                Object functionObj = functionIter.next();
-                if(! (functionObj instanceof FunctionMethod)) {
-                    Assertion.failed(QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0045, functionObj.getClass().getName()));
-                }
-                FunctionMethod method = (FunctionMethod) functionObj;
-
-				if (!containsIndistinguishableFunction(method)){
-                    // Store method metadata for retrieval
-                    addMetadata(method);
-
-                    // Add to tree
-                    addFunction(source, method);
-				} else {
-                    LogManager.logWarning(LogConstants.CTX_FUNCTION_TREE, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0046, new Object[]{method}));
-				}
-            }
-        }
-    }
-
-	// ---------------------- FUNCTION SELECTION USE METHODS ----------------------
-
-	/*
-	 * Per defect 4612 -
-	 * Because of the fix for defect 4264, it is possible in the modeler to
-	 * define two functions with different implementations, but having the
-	 * same name (using the "alias") and the same parameter types, making the
-	 * two FunctionMethod objects indistinguishable by their equals method.
-	 * This method will check if any indistinguishable functions are already
-	 * present in this FunctionTree.  If so, it will be logged and any
-	 * newer indistinguishable functions will just not be added.
-	 */
-	private boolean containsIndistinguishableFunction(FunctionMethod method){
-        return allFunctions.contains(method);
-	}
-
-    /**
-     * Store the method in the function metadata.
-     * @param method The function metadata for a particular method signature
-     */
-    private void addMetadata(FunctionMethod method) {
-    	String categoryKey = method.getCategory();
-    	if (categoryKey == null) {
-    		method.setCategory(FunctionCategoryConstants.MISCELLANEOUS);
-    		categoryKey = FunctionCategoryConstants.MISCELLANEOUS;
-    	}
-    	categoryKey = categoryKey.toUpperCase();
-        String nameKey = method.getName().toUpperCase();
-
-        // Look up function map (create if necessary)
-        Set<String> functions = categories.get(categoryKey);
-        if (functions == null) {
-            functions = new HashSet<String>();
-            categories.put(categoryKey, functions);
-        }
-
-        // Look up function in function map
-        functions.add(nameKey);
-
-        // Add method to list by function name
-        List<FunctionMethod> knownMethods = functionsByName.get(nameKey);
-        if(knownMethods == null) {
-            knownMethods = new ArrayList<FunctionMethod>();
-            functionsByName.put(nameKey, knownMethods);
-        }
-        knownMethods.add(method);
-        allFunctions.add(method);
-    }
-
-    /**
-     * Get collection of category names.
-     * @return Category names
-     */
-    Collection<String> getCategories() {
-        return categories.keySet();
-    }
-
-    /**
-     * Get collection of function forms in a category
-     * @param category Category to get (case-insensitive)
-     * @return Collection of {@link FunctionForm}s
-     */
-    Collection<FunctionForm> getFunctionForms(String category) {
-        Set<FunctionForm> functionForms = new HashSet<FunctionForm>();
-
-        Set<String> functions = categories.get(category.toUpperCase());
-        if(functions != null) {
-        	for (String functionName : functions) {
-        		for (FunctionMethod functionMethod : this.functionsByName.get(functionName)) {
-                    functionForms.add(new FunctionForm(functionMethod));
-                }
-            }
-        }
-
-        return functionForms;
-    }
-
-    /**
-     * Find function form based on function name and # of arguments.
-     * @param name Function name, case insensitive
-     * @param args Number of arguments
-     * @return Corresponding form or null if not found
-     */
-    FunctionForm findFunctionForm(String name, int args) {
-    	List<FunctionMethod> results = findFunctionMethods(name, args);
-    	if (results.size() > 0) {
-    		return new FunctionForm(results.get(0));
-    	}
-    	return null;
-    }
-    
-    /**
-     * Find all function methods with the given name and arg length
-     * @param name Function name, case insensitive
-     * @param args Number of arguments
-     * @return Corresponding form or null if not found
-     */
-    List<FunctionMethod> findFunctionMethods(String name, int args) {
-        final List<FunctionMethod> allMatches = new ArrayList<FunctionMethod>();
-        List<FunctionMethod> methods = functionsByName.get(name.toUpperCase());
-        if(methods == null || methods.size() == 0) {
-            return allMatches;
-        }
-
-        for (FunctionMethod functionMethod : methods) {
-            if(functionMethod.getInputParameterCount() == args || functionMethod.isVarArgs() && args >= functionMethod.getInputParameterCount() - 1) {
-                allMatches.add(functionMethod);
-            }
-        }
-
-        return allMatches;
-    }    
-
-	// ---------------------- FUNCTION INVOCATION USE METHODS ----------------------
-
-    /**
-     * Store the method for function resolution and invocation.
-     * @param source The function metadata source, which knows how to obtain the invocation class
-     * @param method The function metadata for a particular method signature
-     */
-    private void addFunction(FunctionMetadataSource source, FunctionMethod method) {
-        // Get method name
-        String methodName = method.getName();
-
-        // Get input types for path
-        FunctionParameter[] inputParams = method.getInputParameters();
-        List<Class> inputTypes = new LinkedList<Class>();
-        if(inputParams != null) {
-            for(int i=0; i<inputParams.length; i++) {
-                String typeName = inputParams[i].getType();
-                inputTypes.add(DataTypeManager.getDataTypeClass(typeName));
-            }
-        }
-        Class[] types = inputTypes.toArray(new Class[inputTypes.size()]);
-
-        if (method.isVarArgs()) {
-        	inputTypes.set(inputTypes.size() - 1, Array.newInstance(inputTypes.get(inputTypes.size() - 1), 0).getClass());
-        }
-
-        // Get return type
-        FunctionParameter outputParam = method.getOutputParameter();
-        Class outputType = null;
-        if(outputParam != null) {
-            outputType = DataTypeManager.getDataTypeClass(outputParam.getType());
-        }
-
-        Method invocationMethod = null;
-        boolean requiresContext = false;
-        // Defect 20007 - Ignore the invocation method if pushdown is not required.
-        if (method.getPushdown() == FunctionMethod.CAN_PUSHDOWN || method.getPushdown() == FunctionMethod.CANNOT_PUSHDOWN) {
-            try {
-                Class methodClass = source.getInvocationClass(method.getInvocationClass());
-                ReflectionHelper helper = new ReflectionHelper(methodClass);
-                try {
-                	invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
-                } catch (NoSuchMethodException e) {
-                    inputTypes.add(0, CommandContext.class);
-                	invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
-                	requiresContext = true;
-                }
-            } catch (ClassNotFoundException e) {
-              // Failed to load class, so can't load method - this will fail at invocation time.
-              // We don't fail here because this situation can occur in the modeler, which does
-              // not have the function jar files.  The modeler never invokes, so this isn't a
-              // problem.
-            } catch (Exception e) {                
-                throw new MetaMatrixRuntimeException(e, ErrorMessageKeys.FUNCTION_0047, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0047, new Object[]{method.getInvocationClass(), invocationMethod, inputTypes}));
-            } 
-            if(invocationMethod != null && !FunctionTree.isValidMethod(invocationMethod)) {
-            	throw new MetaMatrixRuntimeException(ErrorMessageKeys.FUNCTION_0047, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0047, new Object[]{method.getInvocationClass(), invocationMethod, inputTypes}));
-            }
-        } else {
-            inputTypes.add(0, CommandContext.class);
-        }
-
-        FunctionDescriptor descriptor = new FunctionDescriptor(method.getName(), method.getPushdown(), types, outputType, invocationMethod, requiresContext, method.isNullDependent(), method.getDeterministic());
-        // Store this path in the function tree
-        Map node = treeRoot;
-        Object[] path = buildPath(methodName, types);
-        for(int pathIndex = 0; pathIndex < path.length; pathIndex++) {
-            Object pathPart = path[pathIndex];
-            Map children = (Map) node.get(pathPart);
-            if(children == null) {
-                children = new HashMap();
-                node.put(pathPart, children);
-            }
-            if (method.isVarArgs() && pathIndex == path.length - 1) {
-        		node.put(DESCRIPTOR_KEY, descriptor);
-            }
-            node = children;
-        }
-
-        if (method.isVarArgs()) {
-        	node.put(types[types.length - 1], node);
-        }
-        // Store the leaf descriptor in the tree
-        node.put(DESCRIPTOR_KEY, descriptor);
-    }
-    
-	/**
-	 * Validate a method looked up by reflection.  The method should have a non-void return type
-	 * and be a public static method.
-	 * @param method Method to validate
-	 * @return True if valid
-	 */
-	static boolean isValidMethod(Method method) {
-		// Check return type is non void
-		Class methodReturn = method.getReturnType();
-		if(methodReturn.equals(Void.TYPE)) {
-		    return false;
-		}
-
-		// Check that method is public
-		int modifiers = method.getModifiers();
-		if(! Modifier.isPublic(modifiers)) {
-		    return false;
-		}
-
-		// Check that method is static
-		if(! Modifier.isStatic(modifiers)) {
-		    return false;
-		}
-
-		return true;
-	}
-
-    /**
-     * Look up a function descriptor by signature in the tree.  If none is
-     * found, null is returned.
-     * @param name Name of the function, case is not important
-     * @param argTypes Types of each argument in the function
-     * @return Descriptor which can be used to invoke the function
-     */
-    FunctionDescriptor getFunction(String name, Class[] argTypes) {
-        // Build search path
-        Object[] path = buildPath(name, argTypes);
-
-        // Walk path in tree
-        Map node = treeRoot;
-        for(int i=0; i<path.length; i++) {
-        	node = (Map)node.get(path[i]);
-        	if (node == null) {
-        		return null;
-            }
-        }
-
-        // Look for key at the end
-        if(node.containsKey(DESCRIPTOR_KEY)) {
-            // This is the end - return descriptor
-            return (FunctionDescriptor) node.get(DESCRIPTOR_KEY);
-        }
-        // No descriptor at this location in tree
-        return null;
-    }
-
-    /**
-     * Build the path in the function storage tree.  The path for a function consists
-     * of it's name (uppercased) and each of the argument classes.
-     * @param name Name of function
-     * @param argTypes Types of each arguments
-     * @return Path in function storage tree
-     */
-    private Object[] buildPath(String name, Class[] argTypes) {
-        Object[] path = new Object[argTypes.length + 1];
-        path[0] = name.toUpperCase();
-        System.arraycopy(argTypes, 0, path, 1, argTypes.length);
-        return path;
-    }
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,71 +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.function;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.metadata.FunctionMetadataValidator;
-import com.metamatrix.query.function.source.SystemSource;
-import com.metamatrix.query.report.ActivityReport;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-public class SystemFunctionManager {
-
-	private static FunctionTree systemFunctionTree;
-	
-    static {
-        // Create the system source and add it to the source list
-    	SystemSource systemSource = new SystemSource();
-
-		// Validate the system source - should never fail
-        ActivityReport report = new ActivityReport("Function Validation"); //$NON-NLS-1$
-       	validateSource(systemSource, report);
-		if(report.hasItems()) {
-		    // Should never happen as SystemSource doesn't change
-		    System.err.println(QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0005, report));
-		}
-		
-		systemFunctionTree = new FunctionTree(systemSource);
-    }
-	
-    
-    public static FunctionTree getSystemFunctions() {
-    	return systemFunctionTree;
-    }
-    
-    public static FunctionLibrary getSystemFunctionLibrary() {
-    	return new FunctionLibrary(systemFunctionTree, new FunctionTree(new UDFSource(Collections.EMPTY_LIST)));
-    }
-    
-    /**
-     * Validate all function metadata in the source with the FunctionMetadataValidator.  Add
-     * any problems to the specified report.
-     * @param source Source of function metadata
-     * @param report Report to update with any problems
-     */
-    private static void validateSource(FunctionMetadataSource source, ActivityReport report) {
-        Collection functionMethods = source.getFunctionMethods();
-    	FunctionMetadataValidator.validateFunctionMethods(functionMethods,report);
-    }
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,45 +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.function;
-
-import java.util.Collection;
-
-import com.metamatrix.query.function.metadata.FunctionMethod;
-
-
-public class UDFSource implements FunctionMetadataSource {
-	
-    private Collection <FunctionMethod> methods = null;
-    
-    public UDFSource(Collection <FunctionMethod> methods) {
-    	this.methods = methods;
-    }    
-    
-    public Collection getFunctionMethods() {
-        return this.methods;
-    }
-
-    public Class getInvocationClass(String className) throws ClassNotFoundException {
-        return Class.forName(className);
-    }
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandPlanner.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandPlanner.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,61 +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.optimizer;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- * <p>The common interface of all planners which take a user's command 
- * object and produce a 
- * {@link com.metamatrix.query.processor.ProcessorPlan ProcessorPlan} 
- * object, which is a plan for executing the query.</p>
- */
-public interface CommandPlanner {
-	
-	/**
-	 * Allows the planner a chance to optimize the canonical plan(s) stored in
-	 * the CommandTreeNode tree.  This method should be called in a bottom-up
-	 * manner; from leaf nodes up to the root node.
-	 * @param command TODO
-	 * @param metadata source of metadata
-	 * @param capFinder Class usable to find the connector capabilities for a particular model
-	 * @param context 
-	 * @param debug whether or not to generate verbose debug output during planning
-	 * @return ProcessorPlan implementation specific to the CommandPlanner
-     * @throws QueryPlannerException indicating a problem in planning
-     * @throws QueryMetadataException indicating an exception in accessing the metadata
-     * @throws MetaMatrixComponentException indicating an unexpected exception
-	 */
-	ProcessorPlan optimize(Command command, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
-	throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException;
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/QueryOptimizer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/QueryOptimizer.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/QueryOptimizer.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,126 +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.optimizer;
-
-import java.util.Map;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.core.id.IntegerIDFactory;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.optimizer.batch.BatchedUpdatePlanner;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.proc.ProcedurePlanner;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
-import com.metamatrix.query.optimizer.xml.XMLPlanner;
-import com.metamatrix.query.optimizer.xquery.XQueryPlanner;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- * <p>This Class produces a ProcessorPlan object (a plan for query execution) from a 
- * user's command and a source of metadata.</p>
- * 
- * <p>The user's Command object may in fact be a tree of commands and subcommands.
- * This component is architected to defer to the proper 
- * {@link CommandPlanner CommandPlanner} implementation to plan each Command in the
- * tree.</p>
- */
-public class QueryOptimizer {
-	
-	private static final CommandPlanner XML_PLANNER = new XMLPlanner();
-	private static final CommandPlanner PROCEDURE_PLANNER = new ProcedurePlanner();
-    private static final CommandPlanner XQUERY_PLANNER = new XQueryPlanner();
-    private static final CommandPlanner BATCHED_UPDATE_PLANNER = new BatchedUpdatePlanner();
-
-	// Can't construct	
-	private QueryOptimizer() {}
-
-	public static ProcessorPlan optimizePlan(Command command, QueryMetadataInterface metadata, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
-		throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-
-		if (analysisRecord == null) {
-			analysisRecord = new AnalysisRecord(false, false);
-		}
-		
-		if (context == null) {
-			context = new CommandContext();
-		}
-		
-        boolean debug = analysisRecord.recordDebug();
-        
-        Map tempMetadata = command.getTemporaryMetadata();
-        metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(tempMetadata));
-                
-        // Create an ID generator that can be used for all plans to generate unique data node IDs
-        if(idGenerator == null) {
-            idGenerator = new IDGenerator();
-            idGenerator.setDefaultFactory(new IntegerIDFactory());
-        }
-        
-		if(debug) {
-			analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
-            analysisRecord.println("OPTIMIZE: \n" + command); //$NON-NLS-1$
-		}   
-                                   
-		ProcessorPlan result = null;
-
-		if (command.getType() == Command.TYPE_UPDATE_PROCEDURE){
-			result = PROCEDURE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
-        } else if (command.getType() == Command.TYPE_XQUERY){
-            result = XQUERY_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
-        } else if (command.getType() == Command.TYPE_BATCHED_UPDATE){
-            result = BATCHED_UPDATE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
-        } else {
-			try {
-				if (command.getType() == Command.TYPE_QUERY && command instanceof Query && QueryResolver.isXMLQuery((Query)command, metadata)) {
-					result = XML_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
-				} else {
-					result = new RelationalPlanner().optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
-				}
-			} catch (QueryResolverException e) {
-				throw new MetaMatrixRuntimeException(e);
-			}
-        }
-		
-		if(debug) {
-            analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
-            analysisRecord.println("OPTIMIZATION COMPLETE:"); //$NON-NLS-1$
-            analysisRecord.println("PROCESSOR PLAN:\n" + result); //$NON-NLS-1$
-			analysisRecord.println("============================================================================");		 //$NON-NLS-1$
-		}			
-
-		return result;
-	}
-	
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,370 +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.optimizer.relational;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-
-/**
- * Adds safe (generated) aliases to the source command
- * 
- * The structure is a little convoluted:
- * AliasGenerator - structure navigator, alters the command by adding alias symbols
- * NamingVisitor - changes the output names of Element and Group symbols
- * SQLNamingContext - a hierarchical context for tracking Element and Group names
- */
-public class AliasGenerator extends PreOrderNavigator {
-    
-    private static class NamingVisitor extends LanguageVisitor {
-
-        private class SQLNamingContext {
-            SQLNamingContext parent;
-            
-            Map<String, Map<String, String>> elementMap = new HashMap<String, Map<String, String>>();
-            Map<String, String> groupNames = new HashMap<String, String>();
-            Map<SingleElementSymbol, String> currentSymbols;
-            
-            boolean aliasColumns = false;
-            
-            public SQLNamingContext(SQLNamingContext parent) {
-                this.parent = parent;
-            }
-            
-            public String getElementName(SingleElementSymbol symbol, boolean renameGroup) {
-            	String name = null;
-            	if (currentSymbols != null) {
-            		name = currentSymbols.get(symbol);
-                	if (name != null) {
-                		if (renameGroup && symbol instanceof ElementSymbol) {
-            				renameGroup(((ElementSymbol)symbol).getGroupSymbol());
-            			}
-                		return name;
-                	}
-            	}
-            	if (!(symbol instanceof ElementSymbol)) {
-            		return null;
-            	}
-            	ElementSymbol element = (ElementSymbol)symbol;
-            	Map<String, String> elements = this.elementMap.get(element.getGroupSymbol().getCanonicalName());
-            	if (elements != null) {
-            		name = elements.get(element.getShortCanonicalName());
-            		if (name != null) {
-            			if (renameGroup) {
-            				renameGroup(element.getGroupSymbol());
-            			}
-            			return name;
-            		}
-                }
-                if (parent != null) {
-                	name = parent.getElementName(symbol, renameGroup);
-                	if (name != null) {
-                		return name;
-                	}
-                }
-            	if (renameGroup) {
-    				renameGroup(element.getGroupSymbol());
-    			}
-            	return null;
-            }
-            
-            public void renameGroup(GroupSymbol obj) {
-                if (aliasGroups) {
-                    String definition = obj.getNonCorrelationName();
-                    String newAlias = getGroupName(obj.getCanonicalName());
-                    if (newAlias == null) {
-                        return;
-                    }
-                    obj.setOutputName(newAlias);
-                    obj.setOutputDefinition(definition);
-                } else if(obj.getDefinition() != null) {
-                    obj.setOutputName(obj.getDefinition());
-                    obj.setOutputDefinition(null);
-                }
-            }
-                    
-            private String getGroupName(String group) {
-                String groupName = groupNames.get(group);
-                if (groupName == null) {
-                    if (parent == null) {
-                        return null;
-                    }
-                    return parent.getGroupName(group);
-                }
-                return groupName;
-            }
-        }
-    	
-        private SQLNamingContext namingContext = new SQLNamingContext(null);
-        boolean aliasGroups;
-        
-        public NamingVisitor(boolean aliasGroups) {
-            this.aliasGroups = aliasGroups;
-        }
-                
-        /** 
-         * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.symbol.ElementSymbol)
-         */
-        @Override
-        public void visit(ElementSymbol obj) {
-            GroupSymbol group = obj.getGroupSymbol();
-            if(group == null) {
-                return;
-            }
-            String newName = namingContext.getElementName(obj, true);
-            
-            if (newName == null) {
-                newName = ElementSymbol.getShortName(obj.getOutputName());
-            }
-            
-            obj.setOutputName(group.getOutputName() + ElementSymbol.SEPARATOR + newName);
-            obj.setDisplayMode(ElementSymbol.DisplayMode.OUTPUT_NAME);
-        }
-        
-        /** 
-         * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.symbol.GroupSymbol)
-         */
-        @Override
-        public void visit(GroupSymbol obj) {
-        	this.namingContext.renameGroup(obj);
-        }
-        
-        public void createChildNamingContext(boolean aliasColumns) {
-            this.namingContext = new SQLNamingContext(this.namingContext);
-            this.namingContext.aliasColumns = aliasColumns;
-        }
-        
-        public void removeChildNamingContext() {
-            this.namingContext = this.namingContext.parent;
-        }
-
-    }
-    
-    private NamingVisitor visitor;
-    private int groupIndex = 0;
-    private int viewIndex = 0;
-
-    public AliasGenerator(boolean aliasGroups) {
-        super(new NamingVisitor(aliasGroups));
-        this.visitor = (NamingVisitor)this.getVisitor();
-    }
-
-    /**
-     * visit the branches other than the first with individual naming contexts
-     * Aliases are being added in all cases, even though they may only be needed in the order by case.
-     * Adding the same alias to all branches ensures cross db support (db2 in particular)
-     */
-    public void visit(SetQuery obj) {
-        visitor.createChildNamingContext(true);
-        visitNode(obj.getRightQuery());
-        visitor.removeChildNamingContext();
-        visitor.namingContext.aliasColumns = true;
-        visitNode(obj.getLeftQuery());
-        visitNode(obj.getOrderBy());
-    }
-    
-    public void visit(Select obj) {
-        List selectSymbols = obj.getSymbols();
-        HashMap<SingleElementSymbol, String> symbols = new HashMap<SingleElementSymbol, String>(selectSymbols.size());                
-        for (int i = 0; i < selectSymbols.size(); i++) {
-            SingleElementSymbol symbol = (SingleElementSymbol)selectSymbols.get(i);
-            
-            String newAlias = "c_" + i; //$NON-NLS-1$
-            
-            boolean needsAlias = true;
-            
-            Expression expr = SymbolMap.getExpression(symbol);
-            
-            SingleElementSymbol newSymbol = symbol;
-            
-            if (!(expr instanceof SingleElementSymbol)) {
-                newSymbol = new ExpressionSymbol(newSymbol.getShortName(), expr);
-            } else if (expr instanceof ElementSymbol) {
-                if (!needsAlias(newAlias, (ElementSymbol)expr)) {
-                    needsAlias = false;
-                    ((ElementSymbol)expr).setOutputName(newAlias);
-                }
-                newSymbol = (ElementSymbol)expr;
-            } else {
-                newSymbol = (SingleElementSymbol)expr; 
-            }
-                        
-            symbols.put(symbol, newAlias);
-            if (visitor.namingContext.aliasColumns && needsAlias) {
-                newSymbol = new AliasSymbol(symbol.getShortName(), newSymbol);
-                newSymbol.setOutputName(newAlias);
-            } 
-            selectSymbols.set(i, newSymbol);
-        }
-        
-        super.visit(obj);
-        visitor.namingContext.currentSymbols = symbols; 
-    }
-
-    private boolean needsAlias(String newAlias,
-                               ElementSymbol symbol) {
-        return !(symbol.getMetadataID() instanceof TempMetadataID) || !newAlias.equalsIgnoreCase(visitor.namingContext.getElementName(symbol, false));
-    }
-    
-    /**
-     * visit the query in definition order
-     */
-    public void visit(Query obj) {
-        if (obj.getOrderBy() != null || obj.getLimit() != null) {
-            visitor.namingContext.aliasColumns = true;
-        }        
-        visitNode(obj.getFrom());
-        visitNode(obj.getCriteria());
-        visitNode(obj.getGroupBy());
-        visitNode(obj.getHaving());
-        visitNode(obj.getSelect());
-        visitNode(obj.getOrderBy());
-    }
-    
-    public void visit(SubqueryFromClause obj) {
-        visitor.createChildNamingContext(true);
-        obj.getCommand().acceptVisitor(this);
-        Map<String, String> viewGroup = new HashMap<String, String>();
-        for (Entry<SingleElementSymbol, String> entry : visitor.namingContext.currentSymbols.entrySet()) {
-        	viewGroup.put(entry.getKey().getShortCanonicalName(), entry.getValue());
-        }
-        visitor.namingContext.parent.elementMap.put(obj.getName().toUpperCase(), viewGroup);
-        visitor.removeChildNamingContext();
-        obj.getGroupSymbol().setOutputName(recontextGroup(obj.getGroupSymbol(), true));
-    }
-    
-    @Override
-    public void visit(UnaryFromClause obj) {
-        if (visitor.aliasGroups) {
-            GroupSymbol symbol = obj.getGroup();
-            recontextGroup(symbol, false);
-        } 
-        super.visit(obj);
-    }
-
-    /** 
-     * @param symbol
-     */
-    private String recontextGroup(GroupSymbol symbol, boolean virtual) {
-        String newAlias = null;
-        if (virtual) {
-            newAlias = "v_" + viewIndex++; //$NON-NLS-1$
-        } else {
-            newAlias = "g_" + groupIndex++; //$NON-NLS-1$
-        }
-        visitor.namingContext.groupNames.put(symbol.getName().toUpperCase(), newAlias);
-        return newAlias;
-    }
-    
-    public void visit(ScalarSubquery obj) {
-        visitor.createChildNamingContext(false);
-        visitNode(obj.getCommand());
-        visitor.removeChildNamingContext();
-    }
-    
-    public void visit(SubqueryCompareCriteria obj) {
-        visitNode(obj.getLeftExpression());
-        visitor.createChildNamingContext(false);
-        visitNode(obj.getCommand());
-        visitor.removeChildNamingContext();
-    }
-    
-    public void visit(SubquerySetCriteria obj) {
-        visitNode(obj.getExpression());
-        visitor.createChildNamingContext(false);
-        visitNode(obj.getCommand());
-        visitor.removeChildNamingContext();
-    }
-    
-    public void visit(ExistsCriteria obj) {
-        visitor.createChildNamingContext(false);
-        visitNode(obj.getCommand());
-        visitor.removeChildNamingContext();
-    }
-    
-    public void visit(OrderBy obj) {
-    	//add/correct aliases if necessary
-        for (int i = 0; i < obj.getVariableCount(); i++) {
-            OrderByItem item = obj.getOrderByItems().get(i);
-            SingleElementSymbol element = item.getSymbol();
-            if (item.isUnrelated()) {
-            	visitNode(element);
-            	continue;
-            }
-            String name = visitor.namingContext.getElementName(element, false);
-            if (name != null) {
-	            boolean needsAlias = true;
-	            
-	            Expression expr = SymbolMap.getExpression(element);
-	                        
-	            if (!(expr instanceof SingleElementSymbol)) {
-	                expr = new ExpressionSymbol(element.getShortName(), expr);
-	            } else if (expr instanceof ElementSymbol) {
-	                needsAlias = needsAlias(name, (ElementSymbol)expr);
-	            } 
-	                        
-	            if (needsAlias) {
-	                element = new AliasSymbol(element.getShortName(), (SingleElementSymbol)expr);
-	                obj.getOrderByItems().get(i).setSymbol(element);
-	            }
-	            element.setOutputName(name);
-            }
-            
-            visitNode(element);
-            
-            if (name != null && element instanceof ElementSymbol) {
-        		element.setOutputName(SingleElementSymbol.getShortName(element.getOutputName()));
-        	}
-        }
-    }
-    
-    public void visit(Reference obj) {
-    	//we need to follow references to correct correlated variables
-        visitNode(obj.getExpression());
-    }
-
-}
\ No newline at end of file

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/OptimizerRule.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/OptimizerRule.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/OptimizerRule.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,38 +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.optimizer.relational;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.*;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.*;
-
-public interface OptimizerRule {
-
-	PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capabilitiesFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
-		throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException;
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,54 +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.optimizer.relational;
-
-
-public final class PlanHints { 
-
-    // This flag indicates that the plan has a criteria somewhere
-    public boolean hasCriteria = false;
-    
-    // This flag indicates that the plan has a join somewhere
-    public boolean hasJoin = false;
-    
-    // This flag indicates that the plan has a virtual group somewhere
-    public boolean hasVirtualGroups = false;
-    
-    // flag indicates that the plan has a union somewhere
-    public boolean hasSetQuery = false;
-    
-    // flag indicating that the plan has a grouping node somewhere
-    public boolean hasAggregates = false;
-        
-    public boolean hasLimit = false;
-    
-    public boolean hasOptionalJoin = false;
-    
-    public boolean hasRelationalProc = false;
-    
-    public PlanHints() { }    
-    
-    public String toString(){
-    	return "PlanHints"; //$NON-NLS-1$
-    }
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,487 +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.optimizer.relational;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.core.id.IntegerID;
-import com.metamatrix.core.id.IntegerIDFactory;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
-import com.metamatrix.query.optimizer.relational.rules.CapabilitiesUtil;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.DependentAccessNode;
-import com.metamatrix.query.processor.relational.DependentProcedureAccessNode;
-import com.metamatrix.query.processor.relational.DependentProcedureExecutionNode;
-import com.metamatrix.query.processor.relational.GroupingNode;
-import com.metamatrix.query.processor.relational.InsertPlanExecutionNode;
-import com.metamatrix.query.processor.relational.JoinNode;
-import com.metamatrix.query.processor.relational.LimitNode;
-import com.metamatrix.query.processor.relational.MergeJoinStrategy;
-import com.metamatrix.query.processor.relational.NestedLoopJoinStrategy;
-import com.metamatrix.query.processor.relational.NullNode;
-import com.metamatrix.query.processor.relational.PartitionedSortJoin;
-import com.metamatrix.query.processor.relational.PlanExecutionNode;
-import com.metamatrix.query.processor.relational.ProjectIntoNode;
-import com.metamatrix.query.processor.relational.ProjectNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.processor.relational.SelectNode;
-import com.metamatrix.query.processor.relational.SortNode;
-import com.metamatrix.query.processor.relational.UnionAllNode;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
-import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-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.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-public class PlanToProcessConverter {
-	protected QueryMetadataInterface metadata;
-	private IDGenerator idGenerator;
-	private AnalysisRecord analysisRecord;
-	private CapabilitiesFinder capFinder;
-	
-	public PlanToProcessConverter(QueryMetadataInterface metadata, IDGenerator idGenerator, AnalysisRecord analysisRecord, CapabilitiesFinder capFinder) {
-		this.metadata = metadata;
-		this.idGenerator = idGenerator;
-		this.analysisRecord = analysisRecord;
-		this.capFinder = capFinder;
-	}
-	
-    public RelationalPlan convert(PlanNode planNode)
-        throws QueryPlannerException, MetaMatrixComponentException {
-
-        boolean debug = analysisRecord.recordDebug();
-        if(debug) {
-            analysisRecord.println("\n============================================================================"); //$NON-NLS-1$
-            analysisRecord.println("CONVERTING PLAN TREE TO PROCESS TREE"); //$NON-NLS-1$
-        }
-
-        // Convert plan tree nodes into process tree nodes
-        RelationalNode processNode = convertPlan(planNode);
-        if(debug) {
-            analysisRecord.println("\nPROCESS PLAN = \n" + processNode); //$NON-NLS-1$
-            analysisRecord.println("============================================================================"); //$NON-NLS-1$
-        }
-
-        RelationalPlan processPlan = new RelationalPlan(processNode);
-        return processPlan;
-
-    }
-
-	private RelationalNode convertPlan(PlanNode planNode)
-		throws QueryPlannerException, MetaMatrixComponentException {
-
-		// Convert current node in planTree
-		RelationalNode convertedNode = convertNode(planNode);
-		
-		if(convertedNode == null) {
-		    Assertion.assertTrue(planNode.getChildCount() == 1);
-	        return convertPlan(planNode.getFirstChild());
-		}
-		
-		RelationalNode nextParent = convertedNode;
-		
-        // convertedNode may be the head of 1 or more nodes   - go to end of chain
-        while(nextParent.getChildren()[0] != null) {
-            nextParent = nextParent.getChildren()[0];
-        }
-		
-		// Call convertPlan recursively on children
-		for (PlanNode childNode : planNode.getChildren()) {
-		    nextParent.addChild(convertPlan(childNode));
-		}
-
-        // Return root of tree for top node
-		return convertedNode;
-	}
-
-    protected int getID() {
-        IntegerIDFactory intFactory = (IntegerIDFactory) idGenerator.getDefaultFactory();
-        return ((IntegerID) intFactory.create()).getValue();
-    }
-    
-	protected RelationalNode convertNode(PlanNode node)
-		throws QueryPlannerException, MetaMatrixComponentException {
-
-		RelationalNode processNode = null;
-
-		switch(node.getType()) {
-			case NodeConstants.Types.PROJECT:
-                GroupSymbol intoGroup = (GroupSymbol) node.getProperty(NodeConstants.Info.INTO_GROUP);
-                if(intoGroup != null) {
-                    try {
-                    	Insert insert = (Insert)node.getFirstChild().getProperty(Info.VIRTUAL_COMMAND);
-                        List<ElementSymbol> allIntoElements = insert.getVariables();
-                        
-                        Object groupID = intoGroup.getMetadataID();
-                        Object modelID = metadata.getModelID(groupID);
-                        String modelName = metadata.getFullName(modelID);
-                        if (metadata.isVirtualGroup(groupID)) {
-                        	InsertPlanExecutionNode ipen = new InsertPlanExecutionNode(getID(), metadata);
-                        	ipen.setProcessorPlan((ProcessorPlan)node.getFirstChild().getProperty(Info.PROCESSOR_PLAN));
-                        	ipen.setReferences(insert.getValues());
-                        	processNode = ipen;
-                        } else {
-	                        ProjectIntoNode pinode = new ProjectIntoNode(getID());
-	                        pinode.setIntoGroup(intoGroup);
-	                        pinode.setIntoElements(allIntoElements);
-	                        pinode.setModelName(modelName);
-	                        processNode = pinode;
-	                        if (!metadata.isTemporaryTable(groupID)) {
-	                            SourceCapabilities caps = capFinder.findCapabilities(modelName);
-	                            pinode.setDoBatching(caps.supportsCapability(Capability.BATCHED_UPDATES));
-	                            pinode.setDoBulkInsert(caps.supportsCapability(Capability.BULK_UPDATE));
-	                        } else {
-	                            pinode.setDoBulkInsert(true);
-	                        } 
-                        }
-                    } catch(QueryMetadataException e) {
-                        throw new MetaMatrixComponentException(e);
-                    }
-
-                } else {
-                    List symbols = (List) node.getProperty(NodeConstants.Info.PROJECT_COLS);
-                    
-                    ProjectNode pnode = new ProjectNode(getID());
-                    pnode.setSelectSymbols(symbols);
-            		processNode = pnode;
-                }
-                break;
-
-			case NodeConstants.Types.JOIN:
-                JoinType jtype = (JoinType) node.getProperty(NodeConstants.Info.JOIN_TYPE);
-                JoinStrategyType stype = (JoinStrategyType) node.getProperty(NodeConstants.Info.JOIN_STRATEGY);
-
-                JoinNode jnode = new JoinNode(getID());
-                jnode.setJoinType(jtype);
-                jnode.setLeftDistinct(node.hasBooleanProperty(NodeConstants.Info.IS_LEFT_DISTINCT));
-                jnode.setRightDistinct(node.hasBooleanProperty(NodeConstants.Info.IS_RIGHT_DISTINCT));
-                List joinCrits = (List) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
-                String depValueSource = (String) node.getProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE);
-                SortOption leftSort = (SortOption)node.getProperty(NodeConstants.Info.SORT_LEFT);
-                if(stype.equals(JoinStrategyType.MERGE) || stype.equals(JoinStrategyType.PARTITIONED_SORT)) {
-                	MergeJoinStrategy mjStrategy = null;
-                	if (stype.equals(JoinStrategyType.PARTITIONED_SORT)) { 
-                		mjStrategy = new PartitionedSortJoin(leftSort, (SortOption)node.getProperty(NodeConstants.Info.SORT_RIGHT));
-                	} else {
-                		mjStrategy = new MergeJoinStrategy(leftSort, (SortOption)node.getProperty(NodeConstants.Info.SORT_RIGHT), false);
-                	}
-                    jnode.setJoinStrategy(mjStrategy);
-                    List leftExpressions = (List) node.getProperty(NodeConstants.Info.LEFT_EXPRESSIONS);
-                    List rightExpressions = (List) node.getProperty(NodeConstants.Info.RIGHT_EXPRESSIONS);
-                    jnode.setJoinExpressions(leftExpressions, rightExpressions);
-                    joinCrits = (List) node.getProperty(NodeConstants.Info.NON_EQUI_JOIN_CRITERIA);
-                } else {
-                    NestedLoopJoinStrategy nljStrategy = new NestedLoopJoinStrategy();
-                    jnode.setJoinStrategy(nljStrategy);
-                } 
-                Criteria joinCrit = Criteria.combineCriteria(joinCrits);
-                jnode.setJoinCriteria(joinCrit);
-                               
-                processNode = jnode;
-                
-                jnode.setDependentValueSource(depValueSource);
-                
-				break;
-
-			case NodeConstants.Types.ACCESS:
-                ProcessorPlan plan = (ProcessorPlan) node.getProperty(NodeConstants.Info.PROCESSOR_PLAN);
-                if(plan != null) {
-                    
-                    PlanExecutionNode peNode = null;
-                    
-                    Criteria crit = (Criteria)node.getProperty(NodeConstants.Info.PROCEDURE_CRITERIA);
-                    
-                    if (crit != null) {
-                        List references = (List)node.getProperty(NodeConstants.Info.PROCEDURE_INPUTS);
-                        List defaults = (List)node.getProperty(NodeConstants.Info.PROCEDURE_DEFAULTS);
-                        
-                        peNode = new DependentProcedureExecutionNode(getID(), crit, references, defaults);                        
-                    } else {
-                        peNode = new PlanExecutionNode(getID());
-                    }
-                    
-                    peNode.setProcessorPlan(plan);
-                    processNode = peNode;
-
-                } else {
-                    AccessNode aNode = null;
-                    Command command = (Command) node.getProperty(NodeConstants.Info.ATOMIC_REQUEST);
-                    Object modelID = node.getProperty(NodeConstants.Info.MODEL_ID);
-                    
-                    if(node.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)) {
-                        if (command instanceof StoredProcedure) {
-                            List references = (List)node.getProperty(NodeConstants.Info.PROCEDURE_INPUTS);
-                            List defaults = (List)node.getProperty(NodeConstants.Info.PROCEDURE_DEFAULTS);
-                            Criteria crit = (Criteria)node.getProperty(NodeConstants.Info.PROCEDURE_CRITERIA);
-                            
-                            DependentProcedureAccessNode depAccessNode = new DependentProcedureAccessNode(getID(), crit, references, defaults);
-                            processNode = depAccessNode;
-                            aNode = depAccessNode;
-                        } else {
-                            //create dependent access node
-                            DependentAccessNode depAccessNode = new DependentAccessNode(getID());
-                            
-                            if(modelID != null){
-                                depAccessNode.setMaxSetSize(CapabilitiesUtil.getMaxInCriteriaSize(modelID, metadata, capFinder));   
-                            }
-                            processNode = depAccessNode;
-                            aNode = depAccessNode;
-                        }
-                        aNode.setShouldEvaluateExpressions(true);
-                    } else {
-                        
-                        // create access node
-                        aNode = new AccessNode(getID());
-                        processNode = aNode;
-                                                
-                        //-- special handling for temp tables. currently they cannot perform projection
-                        try {
-                            if (command instanceof Query) {
-                                processNode = correctProjectionInternalTables(node, aNode, (Query)command);
-                            }
-                        } catch (QueryMetadataException err) {
-                            throw new MetaMatrixComponentException(err);
-                        }
-                        aNode.setShouldEvaluateExpressions(EvaluatableVisitor.needsProcessingEvaluation(command));
-                    }
-                    
-                    try {
-                        command = (Command)command.clone();
-                        command.acceptVisitor(new AliasGenerator(modelID != null && CapabilitiesUtil.supportsGroupAliases(modelID, metadata, capFinder)));
-                    } catch (QueryMetadataException err) {
-                        throw new MetaMatrixComponentException(err);
-                    }
-                    aNode.setCommand(command);
-                    aNode.setModelName(getRoutingName(node));
-                }
-                break;
-
-			case NodeConstants.Types.SELECT:
-
-				Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
-
-				SelectNode selnode = new SelectNode(getID());
-				selnode.setCriteria(crit);
-				processNode = selnode;
-                
-				break;
-
-			case NodeConstants.Types.SORT:
-			case NodeConstants.Types.DUP_REMOVE:
-                SortNode sortNode = new SortNode(getID());
-                OrderBy orderBy = (OrderBy) node.getProperty(NodeConstants.Info.SORT_ORDER);
-				if (orderBy != null) {
-					sortNode.setSortElements(orderBy.getSortKeys(), orderBy.getTypes());
-				}
-				if (node.getType() == NodeConstants.Types.DUP_REMOVE) {
-					sortNode.setMode(Mode.DUP_REMOVE);
-				} else if (node.hasBooleanProperty(NodeConstants.Info.IS_DUP_REMOVAL)) {
-					sortNode.setMode(Mode.DUP_REMOVE_SORT);
-				}
-
-				processNode = sortNode;
-				break;
-			case NodeConstants.Types.GROUP:
-				GroupingNode gnode = new GroupingNode(getID());
-				gnode.setGroupingElements( (List) node.getProperty(NodeConstants.Info.GROUP_COLS) );
-				gnode.setRemoveDuplicates(node.hasBooleanProperty(NodeConstants.Info.IS_DUP_REMOVAL));
-				processNode = gnode;
-				break;
-
-			case NodeConstants.Types.SOURCE:
-			    SymbolMap symbolMap = (SymbolMap) node.getProperty(NodeConstants.Info.SYMBOL_MAP);
-				if(symbolMap != null) {
-					PlanNode child = node.getLastChild();
-
-                    if (node.getParent().getType() != NodeConstants.Types.PROJECT || node.getParent().getProperty(NodeConstants.Info.INTO_GROUP) == null) {
-                    	if (child.getType() == NodeConstants.Types.PROJECT) {
-                    		//update the project cols based upon the original output
-                    		child.setProperty(NodeConstants.Info.PROJECT_COLS, child.getProperty(NodeConstants.Info.OUTPUT_COLS));
-                    	}
-                        child.setProperty(NodeConstants.Info.OUTPUT_COLS, node.getProperty(NodeConstants.Info.OUTPUT_COLS));
-                    }
-				}
-				
-				return null;
-
-    		case NodeConstants.Types.SET_OP:
-                Operation setOp = (Operation) node.getProperty(NodeConstants.Info.SET_OPERATION);
-                boolean useAll = ((Boolean) node.getProperty(NodeConstants.Info.USE_ALL)).booleanValue();
-                if(setOp == Operation.UNION) {
-                    RelationalNode unionAllNode = new UnionAllNode(getID());
-
-                    if(useAll) {
-                        processNode = unionAllNode;
-                    } else {
-                    	SortNode sNode = new SortNode(getID());
-                    	boolean onlyDupRemoval = node.hasBooleanProperty(NodeConstants.Info.IS_DUP_REMOVAL);
-                    	sNode.setMode(onlyDupRemoval?Mode.DUP_REMOVE:Mode.DUP_REMOVE_SORT);
-                        processNode = sNode;
-                        
-                        unionAllNode.setElements( (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS) );
-                        processNode.addChild(unionAllNode);
-                    }
-                } else {
-                    JoinNode joinAsSet = new JoinNode(getID());
-                    joinAsSet.setJoinStrategy(new MergeJoinStrategy(SortOption.SORT_DISTINCT, SortOption.SORT_DISTINCT, true));
-                    List leftExpressions = (List) node.getFirstChild().getProperty(NodeConstants.Info.OUTPUT_COLS);
-                    List rightExpressions = (List) node.getLastChild().getProperty(NodeConstants.Info.OUTPUT_COLS);
-                    joinAsSet.setJoinType(setOp == Operation.EXCEPT ? JoinType.JOIN_ANTI_SEMI : JoinType.JOIN_SEMI);
-                    joinAsSet.setJoinExpressions(leftExpressions, rightExpressions);
-                    processNode = joinAsSet;
-                }
-
-                break;
-
-            case NodeConstants.Types.TUPLE_LIMIT:
-                Expression rowLimit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
-                Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT);
-                processNode = new LimitNode(getID(), rowLimit, offset);
-                break;
-                
-            case NodeConstants.Types.NULL:
-                processNode = new NullNode(getID());
-                break;
-
-			default:
-                throw new QueryPlannerException(QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0007, NodeConstants.getNodeTypeString(node.getType())));
-		}
-
-		if(processNode != null) {
-			processNode = prepareToAdd(node, processNode);
-		}
-
-		return processNode;
-	}
-
-    private RelationalNode correctProjectionInternalTables(PlanNode node,
-                                                                AccessNode aNode, Query query) throws QueryMetadataException,
-                                                                                                       MetaMatrixComponentException {
-        if (node.getGroups().size() != 1) {
-            return aNode;
-        }
-        GroupSymbol group = node.getGroups().iterator().next();
-        if (!group.isTempTable() && !CoreConstants.SYSTEM_MODEL.equals(metadata.getFullName(metadata.getModelID(group.getMetadataID())))) {
-            return aNode;
-        }
-        List projectSymbols = (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS);
-        List<ElementSymbol> acutalColumns = ResolverUtil.resolveElementsInGroup(group, metadata);
-        if (projectSymbols.equals(acutalColumns)) {
-        	return aNode;
-        }
-        node.setProperty(NodeConstants.Info.OUTPUT_COLS, acutalColumns);
-        if (node.getParent() != null && node.getParent().getType() == NodeConstants.Types.PROJECT) {
-            //if the parent is already a project, just correcting the output cols is enough
-            return aNode;
-        }
-        ProjectNode pnode = new ProjectNode(getID());
-  
-        pnode.setSelectSymbols(projectSymbols);
-        //if the following cast fails it means that we have a dependent temp table - that is not yet possible
-        aNode = (AccessNode)prepareToAdd(node, aNode);
-        node.setProperty(NodeConstants.Info.OUTPUT_COLS, projectSymbols);
-        pnode.addChild(aNode);
-        return pnode;
-    }
-
-    private RelationalNode prepareToAdd(PlanNode node,
-                                          RelationalNode processNode) {
-        // Set the output elements from the plan node
-        List cols = (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS);
-
-        processNode.setElements(cols);
-        
-        // Set the Cost Estimates
-        Number estimateNodeCardinality = (Number) node.getProperty(NodeConstants.Info.EST_CARDINALITY);
-        processNode.setEstimateNodeCardinality(estimateNodeCardinality);
-        Number estimateNodeSetSize = (Number) node.getProperty(NodeConstants.Info.EST_SET_SIZE);
-        processNode.setEstimateNodeSetSize(estimateNodeSetSize);
-        Number estimateDepAccessCardinality = (Number) node.getProperty(NodeConstants.Info.EST_DEP_CARDINALITY);
-        processNode.setEstimateDepAccessCardinality(estimateDepAccessCardinality);
-        Number estimateDepJoinCost = (Number) node.getProperty(NodeConstants.Info.EST_DEP_JOIN_COST);
-        processNode.setEstimateDepJoinCost(estimateDepJoinCost);
-        Number estimateJoinCost = (Number) node.getProperty(NodeConstants.Info.EST_JOIN_COST);
-        processNode.setEstimateJoinCost(estimateJoinCost);
-       
-        return processNode;
-    }
-
-	private String getRoutingName(PlanNode node)
-		throws QueryPlannerException, MetaMatrixComponentException {
-
-		// Look up connector binding name
-		try {
-			Object modelID = node.getProperty(NodeConstants.Info.MODEL_ID);
-			if(modelID == null || modelID instanceof TempMetadataID) {
-				Command command = (Command) node.getProperty(NodeConstants.Info.ATOMIC_REQUEST);
-				if(command instanceof StoredProcedure){
-					modelID = ((StoredProcedure)command).getModelID();
-				}else{
-					Collection groups = GroupCollectorVisitor.getGroups(command, true);
-					Iterator groupIter = groups.iterator();
-					GroupSymbol group = (GroupSymbol) groupIter.next();
-
-					modelID = metadata.getModelID(group.getMetadataID());
-				}
-			}
-			String cbName = metadata.getFullName(modelID);
-			return cbName;
-		} catch(QueryMetadataException e) {
-            throw new QueryPlannerException(e, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0009));
-		}
-	}
-
-}

Deleted: 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-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,970 +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.optimizer.relational;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.teiid.client.plan.Annotation;
-import org.teiid.client.plan.Annotation.Priority;
-import org.teiid.dqp.internal.process.Request;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-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.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
-import com.metamatrix.query.optimizer.relational.rules.RuleConstants;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.BindVariableVisitor;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.LanguageObject.Util;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-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.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
-import com.metamatrix.query.sql.visitor.CorrelatedReferenceCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
-import com.metamatrix.query.validator.ValidationVisitor;
-
-/**
- * This class generates a relational plan for query execution.  The output of
- * this class is a {@link com.metamatrix.query.optimizer.relational.plantree.PlanNode PlanNode}
- * object - this object then becomes the input to
- * {@link PlanToProcessConverter PlanToProcessConverter}
- * to  produce a
- * {@link com.metamatrix.query.processor.relational.RelationalPlan RelationalPlan}.
- */
-public class RelationalPlanner implements CommandPlanner {
-	
-	private AnalysisRecord analysisRecord;
-	private Command parentCommand;
-	private IDGenerator idGenerator;
-	private CommandContext context;
-	private CapabilitiesFinder capFinder;
-	private QueryMetadataInterface metadata;
-	private PlanHints hints = new PlanHints();
-	private Option option;
-
-    /**
-     * @see com.metamatrix.query.optimizer.CommandPlanner#optimize(com.metamatrix.query.optimizer.CommandTreeNode, java.util.Map, com.metamatrix.query.metadata.QueryMetadataInterface, boolean)
-     */
-    public ProcessorPlan optimize(
-        Command command,
-        IDGenerator idGenerator,
-        QueryMetadataInterface metadata,
-        CapabilitiesFinder capFinder,
-        AnalysisRecord analysisRecord, CommandContext context)
-        throws
-            QueryPlannerException,
-            QueryMetadataException,
-            MetaMatrixComponentException {
-    	initialize(command, idGenerator, metadata, capFinder, analysisRecord, context);
-
-        boolean debug = analysisRecord.recordDebug();
-		if(debug) {
-            analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
-            analysisRecord.println("GENERATE CANONICAL: \n" + command); //$NON-NLS-1$
-		}   
-        PlanNode plan;
-		try {
-			plan = generatePlan(command);
-		} catch (MetaMatrixProcessingException e) {
-			throw new QueryPlannerException(e, e.getMessage());
-		}
-
-		if(debug) {
-            analysisRecord.println("\nCANONICAL PLAN: \n" + plan); //$NON-NLS-1$
-		} 
-
-        // Connect ProcessorPlan to SubqueryContainer (if any) of SELECT or PROJECT nodes
-		connectSubqueryContainers(plan); //TODO: merge with node creation
-        
-        // Set top column information on top node
-        List<SingleElementSymbol> topCols = Util.deepClone(command.getProjectedSymbols(), SingleElementSymbol.class);
-
-        // Build rule set based on hints
-        RuleStack rules = RelationalPlanner.buildRules(hints);
-
-        // Run rule-based optimizer
-        plan = executeRules(rules, plan);
-
-        PlanToProcessConverter planToProcessConverter = null;
-        if (context != null) {
-        	planToProcessConverter = context.getPlanToProcessConverter();
-        }
-        if (planToProcessConverter == null) {
-        	planToProcessConverter = new PlanToProcessConverter(metadata, idGenerator, analysisRecord, capFinder);
-        }
-        
-        RelationalPlan result = planToProcessConverter.convert(plan);
-        
-        result.setOutputElements(topCols);
-        
-        return result;
-    }
-
-	public void initialize(Command command, IDGenerator idGenerator,
-			QueryMetadataInterface metadata, CapabilitiesFinder capFinder,
-			AnalysisRecord analysisRecord, CommandContext context) {
-		this.parentCommand = command;
-    	this.idGenerator = idGenerator;
-    	this.metadata = metadata;
-    	this.capFinder = capFinder;
-    	this.analysisRecord = analysisRecord;
-    	this.context = context;
-	}
-
-    private void connectSubqueryContainers(PlanNode plan) throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-        Set<GroupSymbol> groupSymbols = getGroupSymbols(plan);
-
-        for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.PROJECT | NodeConstants.Types.SELECT | NodeConstants.Types.JOIN)) {
-            List<SubqueryContainer> subqueryContainers = node.getSubqueryContainers();
-            if (subqueryContainers.isEmpty()){
-            	continue;
-            }
-            Set<GroupSymbol> localGroupSymbols = groupSymbols;
-            if (node.getType() == NodeConstants.Types.JOIN) {
-            	localGroupSymbols = getGroupSymbols(node);
-            }
-            for (SubqueryContainer container : subqueryContainers) {
-                ArrayList<Reference> correlatedReferences = new ArrayList<Reference>(); 
-                Command subCommand = container.getCommand();
-                ProcessorPlan procPlan = QueryOptimizer.optimizePlan(subCommand, metadata, idGenerator, capFinder, analysisRecord, context);
-                subCommand.setProcessorPlan(procPlan);
-                CorrelatedReferenceCollectorVisitor.collectReferences(subCommand, localGroupSymbols, correlatedReferences);
-                if (!correlatedReferences.isEmpty()) {
-	                SymbolMap map = new SymbolMap();
-	                for (Reference reference : correlatedReferences) {
-	    				map.addMapping(reference.getExpression(), reference.getExpression());
-	    			}
-	                subCommand.setCorrelatedReferences(map);
-                }
-            }
-            node.addGroups(GroupsUsedByElementsVisitor.getGroups(node.getCorrelatedReferenceElements()));
-        }
-    }
-
-	private static Set<GroupSymbol> getGroupSymbols(PlanNode plan) {
-		Set<GroupSymbol> groupSymbols = new HashSet<GroupSymbol>();
-        for (PlanNode source : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) {
-            groupSymbols.addAll(source.getGroups());
-        }
-		return groupSymbols;
-	}
-
-    /**
-     * Distribute and "make (not) dependent" hints specified in the query into the
-     * fully resolved query plan.  This is done after virtual group resolution so
-     * that all groups in the plan are known.  The hint is attached to all SOURCE
-     * nodes for each group that should be made dependent/not dependent.
-     * @param groups List of groups (Strings) to be made dependent
-     * @param plan The canonical plan
-     */
-    private void distributeDependentHints(Collection<String> groups, PlanNode plan, QueryMetadataInterface metadata, NodeConstants.Info hintProperty)
-        throws QueryMetadataException, MetaMatrixComponentException {
-    
-        if(groups == null || groups.isEmpty()) {
-        	return;
-        }
-        // Get all source nodes
-        List<PlanNode> nodes = NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE);
-
-        // Walk through each dependent group hint and
-        // attach to the correct source node
-        for (String groupName : groups) {
-            // Walk through nodes and apply hint to all that match group name
-            boolean appliedHint = applyHint(nodes, groupName, hintProperty);
-
-            if(! appliedHint) {
-                //check if it is partial group name
-                Collection groupNames = metadata.getGroupsForPartialName(groupName);
-                if(groupNames.size() == 1) {
-                    groupName = (String)groupNames.iterator().next();
-                    appliedHint = applyHint(nodes, groupName, hintProperty);
-                }
-                
-                if(! appliedHint) {
-                	String msg = QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0010, groupName);
-                	if (this.analysisRecord.recordAnnotations()) {
-                		this.analysisRecord.addAnnotation(new Annotation(Annotation.HINTS, msg, "ignoring hint", Priority.MEDIUM)); //$NON-NLS-1$
-                	}
-                }
-            }
-        }
-    }
-    
-    private static boolean applyHint(List<PlanNode> nodes, String groupName, NodeConstants.Info hintProperty) {
-        boolean appliedHint = false;
-        for (PlanNode node : nodes) {
-            GroupSymbol nodeGroup = node.getGroups().iterator().next();
-            
-            String sDefinition = nodeGroup.getDefinition();
-            
-            if (nodeGroup.getName().equalsIgnoreCase(groupName) 
-             || (sDefinition != null && sDefinition.equalsIgnoreCase(groupName)) ) {
-                node.setProperty(hintProperty, Boolean.TRUE);
-                appliedHint = true;
-            }
-        }
-        return appliedHint;
-    }
-
-    public static RuleStack buildRules(PlanHints hints) {
-        RuleStack rules = new RuleStack();
-
-        rules.push(RuleConstants.COLLAPSE_SOURCE);
-        
-        rules.push(RuleConstants.PLAN_SORTS);
-
-        if(hints.hasJoin) {
-            rules.push(RuleConstants.IMPLEMENT_JOIN_STRATEGY);
-        }
-        
-        rules.push(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
-        
-        rules.push(RuleConstants.CALCULATE_COST);
-        
-        if (hints.hasLimit) {
-            rules.push(RuleConstants.PUSH_LIMIT);
-        }
-        if (hints.hasJoin || hints.hasCriteria) {
-            rules.push(RuleConstants.MERGE_CRITERIA);
-        }
-        if (hints.hasRelationalProc) {
-            rules.push(RuleConstants.PLAN_PROCEDURES);
-        }
-        if(hints.hasJoin) {
-            rules.push(RuleConstants.CHOOSE_DEPENDENT);
-        }
-        if(hints.hasAggregates) {
-            rules.push(RuleConstants.PUSH_AGGREGATES);
-        }
-        if(hints.hasJoin) {
-            rules.push(RuleConstants.CHOOSE_JOIN_STRATEGY);
-            rules.push(RuleConstants.RAISE_ACCESS);
-            //after planning the joins, let the criteria be pushed back into place
-            rules.push(RuleConstants.PUSH_SELECT_CRITERIA);
-            rules.push(RuleConstants.PLAN_JOINS);
-        }
-        rules.push(RuleConstants.RAISE_ACCESS);
-        if (hints.hasSetQuery) {
-            rules.push(RuleConstants.PLAN_UNIONS);
-        } 
-        if(hints.hasCriteria || hints.hasJoin) {
-            //after copy criteria, it is no longer necessary to have phantom criteria nodes, so do some cleaning
-            rules.push(RuleConstants.CLEAN_CRITERIA);
-        }
-        if(hints.hasJoin) {
-            rules.push(RuleConstants.COPY_CRITERIA);
-            rules.push(RuleConstants.PUSH_NON_JOIN_CRITERIA);
-        }
-        if(hints.hasVirtualGroups) {
-            rules.push(RuleConstants.MERGE_VIRTUAL);
-        }
-        if(hints.hasCriteria) {
-            rules.push(RuleConstants.PUSH_SELECT_CRITERIA);
-        }
-        if (hints.hasJoin && hints.hasOptionalJoin) {
-            rules.push(RuleConstants.REMOVE_OPTIONAL_JOINS);
-        }
-        rules.push(RuleConstants.PLACE_ACCESS);
-        return rules;
-    }
-
-    private PlanNode executeRules(RuleStack rules, PlanNode plan)
-        throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-
-        boolean debug = analysisRecord.recordDebug();
-        while(! rules.isEmpty()) {
-            if(debug) {
-                analysisRecord.println("\n============================================================================"); //$NON-NLS-1$
-            }
-
-            OptimizerRule rule = rules.pop();
-            if(debug) {
-                analysisRecord.println("EXECUTING " + rule); //$NON-NLS-1$
-            }
-
-            plan = rule.execute(plan, metadata, capFinder, rules, analysisRecord, context);
-            if(debug) {
-                analysisRecord.println("\nAFTER: \n" + plan); //$NON-NLS-1$
-            }
-        }
-        return plan;
-    }
-	
-	public PlanNode generatePlan(Command cmd) throws MetaMatrixComponentException, MetaMatrixProcessingException {
-		//cascade the option clause nocache
-		Option savedOption = option;
-		option = cmd.getOption();
-        if (option == null) {
-        	if (savedOption != null) {
-        		option = savedOption;
-        	} 
-        } else if (savedOption != null && savedOption.isNoCache()) { //merge no cache settings
-    		if (savedOption.getNoCacheGroups() == null || savedOption.getNoCacheGroups().isEmpty()) {
-    			if (option.getNoCacheGroups() != null) {
-    				option.getNoCacheGroups().clear(); // full no cache
-    			}
-    		} else if (option.getNoCacheGroups() != null && !option.getNoCacheGroups().isEmpty()) {
-    			for (String noCache : savedOption.getNoCacheGroups()) {
-					option.addNoCacheGroup(noCache); // only groups
-				}
-    		}
-    		option.setNoCache(true);
-        }
-		
-		PlanNode result = null;
-		switch (cmd.getType()) {
-		case Command.TYPE_QUERY:
-			result = createQueryPlan((QueryCommand)cmd);
-			break;
-		case Command.TYPE_INSERT:
-		case Command.TYPE_UPDATE:
-		case Command.TYPE_DELETE:
-		case Command.TYPE_CREATE:
-		case Command.TYPE_DROP:
-			result = createUpdatePlan(cmd);
-			break;
-		case Command.TYPE_STORED_PROCEDURE:
-			result = createStoredProcedurePlan((StoredProcedure)cmd);
-			break;
-		default:
-			throw new AssertionError("Invalid command type"); //$NON-NLS-1$
-		}
-        // Distribute make dependent hints as necessary
-        if (cmd.getOption() != null) {
-	        if(cmd.getOption().getDependentGroups() != null) {
-	            distributeDependentHints(cmd.getOption().getDependentGroups(), result, metadata, NodeConstants.Info.MAKE_DEP);
-	        }
-	        if (cmd.getOption().getNotDependentGroups() != null) {
-	            distributeDependentHints(cmd.getOption().getNotDependentGroups(), result, metadata, NodeConstants.Info.MAKE_NOT_DEP);
-	        }
-        }
-        this.option = savedOption;
-        return result;
-	}
-
-	PlanNode createUpdatePlan(Command command) throws MetaMatrixComponentException, MetaMatrixProcessingException {
-        // Create top project node - define output columns for stored query / procedure
-        PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
-
-        Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command, false);
-        projectNode.addGroups(groups);
-
-        // Set output columns
-        List<SingleElementSymbol> cols = command.getProjectedSymbols();
-        projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, cols);
-
-        // Define source of data for stored query / procedure
-        PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
-        sourceNode.setProperty(NodeConstants.Info.ATOMIC_REQUEST, command);
-        sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, command);
-        if (command instanceof ProcedureContainer) {
-        	ProcedureContainer container = (ProcedureContainer)command;
-        	addNestedProcedure(sourceNode, container);
-        }
-        sourceNode.addGroups(groups);
-
-        attachLast(projectNode, sourceNode);
-
-        //for INTO query, attach source and project nodes
-        if(command instanceof Insert){
-        	Insert insert = (Insert)command;
-        	if (insert.getQueryExpression() != null) {
-	            PlanNode plan = generatePlan(insert.getQueryExpression());
-	            attachLast(sourceNode, plan);
-	            mergeTempMetadata(insert.getQueryExpression(), insert);
-	            projectNode.setProperty(NodeConstants.Info.INTO_GROUP, insert.getGroup());
-        	}
-        }
-        
-        return projectNode;
-	}
-
-	private void addNestedProcedure(PlanNode sourceNode,
-			ProcedureContainer container) throws MetaMatrixComponentException,
-			QueryMetadataException, MetaMatrixProcessingException {
-		//plan any subqueries in criteria/parameters/values
-		for (SubqueryContainer subqueryContainer : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(container)) {
-    		ProcessorPlan plan = QueryOptimizer.optimizePlan(subqueryContainer.getCommand(), metadata, null, capFinder, analysisRecord, context);
-    		subqueryContainer.getCommand().setProcessorPlan(plan);
-		}
-		
-		String cacheString = "transformation/" + container.getClass().getSimpleName(); //$NON-NLS-1$
-		Command c = (Command)metadata.getFromMetadataCache(container.getGroup().getMetadataID(), cacheString);
-		if (c == null) {
-			c = QueryResolver.expandCommand(container, metadata, analysisRecord);
-			if (c != null) {
-		        Request.validateWithVisitor(new ValidationVisitor(), metadata, c);
-		        metadata.addToMetadataCache(container.getGroup().getMetadataID(), cacheString, c.clone());
-			}
-		} else {
-			c = (Command)c.clone();
-			if (c instanceof CreateUpdateProcedureCommand) {
-				((CreateUpdateProcedureCommand)c).setUserCommand(container);
-			}
-		}
-		if (c != null) {
-		    c = QueryRewriter.rewrite(c, metadata, context);
-		    addNestedCommand(sourceNode, container.getGroup(), container, c, false);
-		}
-	}
-
-    PlanNode createStoredProcedurePlan(StoredProcedure storedProc) throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException {
-        // Create top project node - define output columns for stored query / procedure
-        PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
-
-        // Set output columns
-        List cols = storedProc.getProjectedSymbols();
-        projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, cols);
-
-        // Define source of data for stored query / procedure
-        PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
-        sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, storedProc);
-    	addNestedProcedure(sourceNode, storedProc);
-        
-        hints.hasRelationalProc |= storedProc.isProcedureRelational();
-
-        // Set group on source node
-        sourceNode.addGroup(storedProc.getGroup());
-
-        attachLast(projectNode, sourceNode);
-
-        return projectNode;
-    }
-
-	PlanNode createQueryPlan(QueryCommand command)
-		throws MetaMatrixComponentException, MetaMatrixProcessingException {
-        // Build canonical plan
-    	PlanNode node = null;
-        if(command instanceof Query) {
-            node = createQueryPlan((Query) command);
-        } else {
-            hints.hasSetQuery = true;
-            SetQuery query = (SetQuery)command;
-            PlanNode leftPlan = createQueryPlan( query.getLeftQuery());
-            PlanNode rightPlan = createQueryPlan( query.getRightQuery());
-
-            node = NodeFactory.getNewNode(NodeConstants.Types.SET_OP);
-            node.setProperty(NodeConstants.Info.SET_OPERATION, query.getOperation());
-            node.setProperty(NodeConstants.Info.USE_ALL, query.isAll());
-            
-            attachLast(node, leftPlan);
-            attachLast(node, rightPlan);
-        }
-        
-		if(command.getOrderBy() != null) {
-			node = attachSorting(node, command.getOrderBy());
-		}
-
-        if (command.getLimit() != null) {
-            node = attachTupleLimit(node, command.getLimit(), hints);
-        }
-        
-        return node;
-    }
-
-    private PlanNode createQueryPlan(Query query)
-		throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException {
-
-        PlanNode plan = null;
-
-        if(query.getFrom() != null){
-            FromClause fromClause = mergeClauseTrees(query.getFrom());
-            
-            PlanNode dummyRoot = new PlanNode();
-            
-    		buildTree(fromClause, dummyRoot);
-            
-            plan = dummyRoot.getFirstChild();
-            
-            hints.hasJoin |= plan.getType() == NodeConstants.Types.JOIN;
-
-    		// Attach criteria on top
-    		if(query.getCriteria() != null) {
-    			plan = attachCriteria(plan, query.getCriteria(), false);
-                hints.hasCriteria = true;
-    		}
-
-    		// Attach grouping node on top
-    		if(query.getGroupBy() != null || query.getHaving() != null || !AggregateSymbolCollectorVisitor.getAggregates(query.getSelect(), false).isEmpty()) {
-    			plan = attachGrouping(plan, query, hints);
-    		}
-
-    		// Attach having criteria node on top
-    		if(query.getHaving() != null) {
-    			plan = attachCriteria(plan, query.getHaving(), true);
-                hints.hasCriteria = true;
-    		}
-            
-        }
-
-		// Attach project on top
-		plan = attachProject(plan, query.getSelect());
-
-		// Attach dup removal on top
-		if(query.getSelect().isDistinct()) {
-			plan = attachDupRemoval(plan);
-		}
-
-		return plan;
-	}
-
-    /**
-     * Merges the from clause into a single join predicate if there are more than 1 from clauses
-     */
-    private static FromClause mergeClauseTrees(From from) {
-        List clauses = from.getClauses();
-        
-        while (clauses.size() > 1) {
-            FromClause first = (FromClause)from.getClauses().remove(0);
-            FromClause second = (FromClause)from.getClauses().remove(0);
-            JoinPredicate jp = new JoinPredicate(first, second, JoinType.JOIN_CROSS);
-            clauses.add(0, jp);
-        }
-        
-        return (FromClause)clauses.get(0);
-    }
-    
-    /**
-     * Build a join plan based on the structure in a clause.  These structures should be
-     * essentially the same tree, but with different objects and details.
-     * @param clause Clause to build tree from
-     * @param parent Parent node to attach join node structure to
-     * @param sourceMap Map of group to source node, used for connecting children to join plan
-     * @param markJoinsInternal Flag saying whether joins built in this method should be marked
-     * as internal
-     * @throws MetaMatrixComponentException 
-     * @throws QueryMetadataException 
-     * @throws MetaMatrixProcessingException 
-     */
-    void buildTree(FromClause clause, PlanNode parent)
-        throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException {
-        
-        PlanNode node = null;
-        
-        if(clause instanceof UnaryFromClause) {
-            // No join required
-            UnaryFromClause ufc = (UnaryFromClause)clause;
-            GroupSymbol group = ufc.getGroup();
-            if (metadata.isVirtualGroup(group.getMetadataID())) {
-            	hints.hasVirtualGroups = true;
-            }
-            Command nestedCommand = ufc.getExpandedCommand();
-            if (nestedCommand == null && !group.isTempGroupSymbol() && !group.isProcedure() 
-            		&& (!(group.getMetadataID() instanceof TempMetadataID) || metadata.getVirtualPlan(group.getMetadataID()) != null)
-        	        && (metadata.isVirtualGroup(group.getMetadataID()))) { 
-            	//must be a view layer
-            	nestedCommand = resolveVirtualGroup(group);
-            }
-            node = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
-            node.addGroup(group);
-            if (nestedCommand != null) {
-            	addNestedCommand(node, group, nestedCommand, nestedCommand, true);
-            }
-            parent.addLastChild(node);
-        } else if(clause instanceof JoinPredicate) {
-            JoinPredicate jp = (JoinPredicate) clause;
-
-            // Set up new join node corresponding to this join predicate
-            node = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
-            node.setProperty(NodeConstants.Info.JOIN_TYPE, jp.getJoinType());
-            node.setProperty(NodeConstants.Info.JOIN_STRATEGY, JoinStrategyType.NESTED_LOOP);
-            node.setProperty(NodeConstants.Info.JOIN_CRITERIA, jp.getJoinCriteria());
-            
-            if (jp.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
-            	hints.hasOptionalJoin = true;
-            }
-         
-            // Attach join node to parent
-            parent.addLastChild(node);
-
-            // Handle each child
-            FromClause[] clauses = new FromClause[] {jp.getLeftClause(), jp.getRightClause()};
-            for(int i=0; i<2; i++) {
-                buildTree(clauses[i], node);
-
-                // Add groups to joinNode
-                for (PlanNode child : node.getChildren()) {
-                    node.addGroups(child.getGroups());
-                }
-            }
-        } else if (clause instanceof SubqueryFromClause) {
-            SubqueryFromClause sfc = (SubqueryFromClause)clause;
-            GroupSymbol group = sfc.getGroupSymbol();
-            Command nestedCommand = sfc.getCommand();
-            node = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
-            node.addGroup(group);
-            addNestedCommand(node, group, nestedCommand, nestedCommand, true);
-            hints.hasVirtualGroups = true;
-            parent.addLastChild(node);
-        }
-        
-        if (clause.isOptional()) {
-            node.setProperty(NodeConstants.Info.IS_OPTIONAL, Boolean.TRUE);
-            hints.hasOptionalJoin = true;
-        }
-        
-        if (clause.isMakeDep()) {
-            node.setProperty(NodeConstants.Info.MAKE_DEP, Boolean.TRUE);
-        } else if (clause.isMakeNotDep()) {
-            node.setProperty(NodeConstants.Info.MAKE_NOT_DEP, Boolean.TRUE);
-        }
-    }
-
-	private void addNestedCommand(PlanNode node,
-			GroupSymbol group, Command nestedCommand, Command toPlan, boolean merge) throws MetaMatrixComponentException, QueryMetadataException, MetaMatrixProcessingException {
-		if (nestedCommand instanceof QueryCommand) {
-			//remove unnecessary order by
-        	QueryCommand queryCommand = (QueryCommand)nestedCommand;
-        	if (queryCommand.getLimit() == null) {
-        		queryCommand.setOrderBy(null);
-        	}
-        }
-		node.setProperty(NodeConstants.Info.NESTED_COMMAND, nestedCommand);
-
-		if (merge && nestedCommand instanceof Query && QueryResolver.isXMLQuery((Query)nestedCommand, metadata)) {
-			merge = false;
-		}
-
-		if (merge) {
-			mergeTempMetadata(nestedCommand, parentCommand);
-		    PlanNode childRoot = generatePlan(nestedCommand);
-		    node.addFirstChild(childRoot);
-			List<SingleElementSymbol> projectCols = nestedCommand.getProjectedSymbols();
-			node.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(group, projectCols, metadata));
-		} else {
-			QueryMetadataInterface actualMetadata = metadata;
-			if (actualMetadata instanceof TempMetadataAdapter) {
-				actualMetadata = ((TempMetadataAdapter)metadata).getMetadata();
-			}
-			ProcessorPlan plan = QueryOptimizer.optimizePlan(toPlan, actualMetadata, null, capFinder, analysisRecord, context);
-		    node.setProperty(NodeConstants.Info.PROCESSOR_PLAN, plan);
-		}
-	}
-
-	/**
-	 * Attach all criteria above the join nodes.  The optimizer will push these
-	 * criteria down to the appropriate source.
-	 * @param plan Existing plan, which joins all source groups
-	 * @param criteria Criteria from query
-	 * @return Updated tree
-	 */
-	private static PlanNode attachCriteria(PlanNode plan, Criteria criteria, boolean isHaving) {
-	    List<Criteria> crits = Criteria.separateCriteriaByAnd(criteria);
-	    
-	    for (Criteria crit : crits) {
-            PlanNode critNode = createSelectNode(crit, isHaving);
-            attachLast(critNode, plan);
-            plan = critNode;
-        } 
-	    
-		return plan;
-	}
-
-    public static PlanNode createSelectNode(final Criteria crit, boolean isHaving) {
-        PlanNode critNode = NodeFactory.getNewNode(NodeConstants.Types.SELECT);
-        critNode.setProperty(NodeConstants.Info.SELECT_CRITERIA, crit);
-        if (isHaving && !AggregateSymbolCollectorVisitor.getAggregates(crit, false).isEmpty()) {
-            critNode.setProperty(NodeConstants.Info.IS_HAVING, Boolean.TRUE);
-        }
-        // Add groups to crit node
-        critNode.addGroups(GroupsUsedByElementsVisitor.getGroups(crit));
-        critNode.addGroups(GroupsUsedByElementsVisitor.getGroups(critNode.getCorrelatedReferenceElements()));
-        return critNode;
-    }
-
-	/**
-	 * Attach a grouping node at top of tree.
-	 * @param plan Existing plan
-	 * @param groupBy Group by clause, which may be null
-	 * @return Updated plan
-	 */
-	private static PlanNode attachGrouping(PlanNode plan, Query query, PlanHints hints) {
-		PlanNode groupNode = NodeFactory.getNewNode(NodeConstants.Types.GROUP);
-
-		GroupBy groupBy = query.getGroupBy();
-		if(groupBy != null) {
-			groupNode.setProperty(NodeConstants.Info.GROUP_COLS, groupBy.getSymbols());
-            groupNode.addGroups(GroupsUsedByElementsVisitor.getGroups(groupBy));
-		}
-
-		attachLast(groupNode, plan);
-        
-        // Mark in hints
-        hints.hasAggregates = true;
-        
-		return groupNode;
-	}
-
-    /**
-	 * Attach SORT node at top of tree.  The SORT may be pushed down to a source (or sources)
-	 * if possible by the optimizer.
-	 * @param plan Existing plan
-	 * @param orderBy Sort description from the query
-	 * @return Updated plan
-	 */
-	private static PlanNode attachSorting(PlanNode plan, OrderBy orderBy) {
-		PlanNode sortNode = NodeFactory.getNewNode(NodeConstants.Types.SORT);
-		
-		sortNode.setProperty(NodeConstants.Info.SORT_ORDER, orderBy);
-		if (orderBy.hasUnrelated()) {
-			sortNode.setProperty(Info.UNRELATED_SORT, true);
-		}
-		sortNode.addGroups(GroupsUsedByElementsVisitor.getGroups(orderBy));
-
-		attachLast(sortNode, plan);
-		return sortNode;
-	}
-    
-    private static PlanNode attachTupleLimit(PlanNode plan, Limit limit, PlanHints hints) {
-        hints.hasLimit = true;
-        PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
-        
-        boolean attach = false;
-        if (limit.getOffset() != null) {
-            limitNode.setProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT, limit.getOffset());
-            attach = true;
-        }
-        if (limit.getRowLimit() != null) {
-            limitNode.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, limit.getRowLimit());
-            attach = true;
-        }
-        if (attach) {
-            attachLast(limitNode, plan);
-            plan = limitNode;
-        }
-        return plan;
-    }
-
-	/**
-	 * Attach DUP_REMOVE node at top of tree.  The DUP_REMOVE may be pushed down
-	 * to a source (or sources) if possible by the optimizer.
-	 * @param plan Existing plan
-	 * @return Updated plan
-	 */
-	private static PlanNode attachDupRemoval(PlanNode plan) {
-		PlanNode dupNode = NodeFactory.getNewNode(NodeConstants.Types.DUP_REMOVE);
-		attachLast(dupNode, plan);
-		return dupNode;
-	}
-
-	private static PlanNode attachProject(PlanNode plan, Select select) {
-		PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
-		projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, select.getProjectedSymbols());
-
-		// Set groups
-		projectNode.addGroups(GroupsUsedByElementsVisitor.getGroups(select));
-
-		attachLast(projectNode, plan);
-		return projectNode;
-	}
-
-	static final void attachLast(PlanNode parent, PlanNode child) {
-		if(child != null) {
-			parent.addLastChild(child);
-		}
-	}
-
-    /**
-     * Adds temp metadata (if any) of child command to temp metadata
-     * (if any) of parent command.
-     * @param childCommand 
-     * @param parentCommand
-     */
-    static void mergeTempMetadata(
-        Command childCommand,
-        Command parentCommand) {
-        Map childTempMetadata = childCommand.getTemporaryMetadata();
-        if (childTempMetadata != null && !childTempMetadata.isEmpty()){
-            // Add to parent temp metadata
-            Map parentTempMetadata = parentCommand.getTemporaryMetadata();
-            if (parentTempMetadata == null){
-                parentCommand.setTemporaryMetadata(new HashMap(childTempMetadata));
-            } else {
-                parentTempMetadata.putAll(childTempMetadata);
-            }
-        }
-    }
-	
-    private Command resolveVirtualGroup(GroupSymbol virtualGroup)
-    throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException {
-    	
-        QueryNode qnode = null;
-        
-        Object metadataID = virtualGroup.getMetadataID();
-        boolean noCache = false;
-        boolean isMaterializedGroup = metadata.hasMaterialization(metadataID);
-        String cacheString = "select"; //$NON-NLS-1$
-        if( isMaterializedGroup) {
-            noCache = isNoCacheGroup(metadata, metadataID, option);
-        	if(noCache){
-        		//not use cache
-        		qnode = metadata.getVirtualPlan(metadataID);
-        		String matTableName = metadata.getFullName(metadata.getMaterialization(metadataID));
-        		recordMaterializationTableAnnotation(virtualGroup, analysisRecord, matTableName, "SimpleQueryResolver.materialized_table_not_used"); //$NON-NLS-1$
-        	}else{
-                // Default query for a materialized group - go to cached table
-                String groupName = metadata.getFullName(metadataID);
-                String matTableName = metadata.getFullName(metadata.getMaterialization(metadataID));
-                qnode = new QueryNode(groupName, "SELECT * FROM " + matTableName); //$NON-NLS-1$
-                cacheString = "matview"; //$NON-NLS-1$
-                recordMaterializationTableAnnotation(virtualGroup, analysisRecord, matTableName, "SimpleQueryResolver.Query_was_redirected_to_Mat_table"); //$NON-NLS-1$                
-        	}
-        } else {
-            // Not a materialized view - query the primary transformation
-            qnode = metadata.getVirtualPlan(metadataID);            
-        }
-
-        Command result = (Command)metadata.getFromMetadataCache(virtualGroup.getMetadataID(), "transformation/" + cacheString); //$NON-NLS-1$
-        if (result != null) {
-        	result = (Command)result.clone();
-        } else {
-        	//parse, resolve, validate
-        	result = convertToSubquery(qnode, metadata);
-	        QueryResolver.resolveCommand(result, Collections.EMPTY_MAP, metadata, analysisRecord);
-	        Request.validateWithVisitor(new ValidationVisitor(), metadata, result);
-	        metadata.addToMetadataCache(virtualGroup.getMetadataID(), "transformation/" + cacheString, result.clone()); //$NON-NLS-1$
-        }        
-        return QueryRewriter.rewrite(result, metadata, context);
-    }
-
-    public static boolean isNoCacheGroup(QueryMetadataInterface metadata,
-                                          Object metadataID,
-                                          Option option) throws QueryMetadataException,
-                                                        MetaMatrixComponentException {
-        if(option == null || !option.isNoCache()){
-            return false;
-        }
-    	if(option.getNoCacheGroups() == null || option.getNoCacheGroups().isEmpty()){
-    		//only OPTION NOCACHE, no group specified
-    		return true;
-    	}       
-    	for (String groupName : option.getNoCacheGroups()) {
-            try {
-                Object noCacheGroupID = metadata.getGroupID(groupName);
-                if(metadataID.equals(noCacheGroupID)){
-                    return true;
-                }
-            } catch (QueryMetadataException e) {
-                //log that an unknown groups was used in the no cache
-                LogManager.logWarning(LogConstants.CTX_QUERY_RESOLVER, e, QueryPlugin.Util.getString("SimpleQueryResolver.unknown_group_in_nocache", groupName)); //$NON-NLS-1$
-            }
-        }
-        return false;
-    }
-    
-    private static void recordMaterializationTableAnnotation(GroupSymbol virtualGroup,
-                                                      AnalysisRecord analysis,
-                                                      String matTableName, String msg) {
-        if ( analysis.recordAnnotations() ) {
-            Object[] params = new Object[] {virtualGroup, matTableName};
-            Annotation annotation = new Annotation(Annotation.MATERIALIZED_VIEW, 
-                                                         QueryPlugin.Util.getString(msg, params), 
-                                                         null, 
-                                                         Priority.LOW);
-            analysis.addAnnotation(annotation);
-        }
-    }
-
-    private static Command convertToSubquery(QueryNode qnode, QueryMetadataInterface metadata)
-    throws QueryResolverException, MetaMatrixComponentException {
-
-        // Parse this node's command
-        Command command = qnode.getCommand();
-        
-        if (command == null) {
-            try {
-                command = QueryParser.getQueryParser().parseCommand(qnode.getQuery());
-            } catch(QueryParserException e) {
-                throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0011, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0011, qnode.getGroupName()));
-            }
-            
-            //Handle bindings and references
-            List bindings = qnode.getBindings();
-            if (bindings != null){
-                BindVariableVisitor.bindReferences(command, bindings, metadata);
-            }
-        }
-
-        return command;
-    }
-
-}
\ No newline at end of file

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RuleStack.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RuleStack.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RuleStack.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,67 +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.optimizer.relational;
-
-import java.util.LinkedList;
-
-public class RuleStack {
-
-    private LinkedList<OptimizerRule> rules = new LinkedList<OptimizerRule>();
-    
-    public void push(OptimizerRule rule) { 
-        rules.addFirst(rule);
-    }
-    
-    public void addLast(OptimizerRule rule) {
-    	rules.addLast(rule);
-    }
-    
-    public OptimizerRule pop() { 
-        if(rules.isEmpty()) { 
-            return null;
-        }    
-        return rules.removeFirst();
-    }
-    
-    public boolean isEmpty() { 
-        return rules.isEmpty();
-    }
-    
-    public int size() { 
-        return rules.size();
-    }
-    
-    /**
-     * Remove all occurrences of this rule in the stack 
-     * @param rule The rule to remove
-     * @since 4.2
-     */
-    public void remove(OptimizerRule rule) {
-        while(rules.remove(rule)) {}            
-    }
-    
-    public boolean contains(OptimizerRule rule) {
-        return rules.contains(rule);
-    }
-    
-}
\ No newline at end of file

Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/BatchCollector.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/BatchCollector.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/BatchCollector.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,111 +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.processor;
-
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-
-public class BatchCollector {
-	
-	public interface BatchProducer {
-	    /**
-	     * Get a batch of results or possibly an Exception.
-	     * @return Batch of results
-	     * @throws BlockedException indicating next batch is not available yet
-	     * @throws MetaMatrixComponentException for non-business rule exception
-	     * @throws MetaMatrixProcessingException for business rule exception, related
-	     * to user input or modeling
-	     */
-	    TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException;
-	    
-	    /**
-	     * Get list of resolved elements describing output columns for this plan.
-	     * @return List of SingleElementSymbol
-	     */
-	    List getOutputElements();
-	}
-	
-	public interface BatchHandler {
-		boolean batchProduced(TupleBatch batch) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-	}
-
-    private BatchProducer sourceNode;
-    private BatchHandler batchHandler;
-
-    private boolean done = false;
-    private TupleBuffer buffer;
-    
-    public BatchCollector(BatchProducer sourceNode, TupleBuffer buffer) {
-        this.sourceNode = sourceNode;
-        this.buffer = buffer;
-    }
-
-    public TupleBuffer collectTuples() throws MetaMatrixComponentException, MetaMatrixProcessingException {
-        TupleBatch batch = null;
-    	while(!done) {
-            batch = sourceNode.nextBatch();
-
-            flushBatch(batch);
-
-            // Check for termination condition
-            if(batch.getTerminationFlag()) {
-            	done = true;
-            	buffer.close();
-                break;
-            }
-        }
-        return buffer;
-    }
-    
-    public TupleBuffer getTupleBuffer() {
-		return buffer;
-	}
-    
-    /**
-     * Flush the batch by giving it to the buffer manager.
-     */
-    private void flushBatch(TupleBatch batch) throws MetaMatrixComponentException, MetaMatrixProcessingException {
-    	boolean add = true;
-		if (this.batchHandler != null && (batch.getRowCount() > 0 || batch.getTerminationFlag())) {
-        	add = this.batchHandler.batchProduced(batch);
-        }
-    	// Add batch
-        if(batch.getRowCount() > 0 || batch.getTerminationFlag()) {
-        	buffer.addTupleBatch(batch, add);
-        }
-    }
-    
-	public void setBatchHandler(BatchHandler batchHandler) {
-		this.batchHandler = batchHandler;
-	}
-    
-    public int getRowCount() {
-        return buffer.getRowCount();
-    }
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/BatchIterator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/BatchIterator.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/BatchIterator.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,190 +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.processor;
-
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.IndexedTupleSource;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.query.processor.BatchCollector.BatchProducer;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-
-/**
- * A BatchIterator provides an iterator interface to a {@link BatchProducer}.
- * By setting {@link #setBuffer(TupleBuffer)}, 
- * the iterator can copy on read into a {@link TupleBuffer} for repeated reading.
- * 
- * Note that the saveOnMark buffering only lasts until the next mark is set.
- */
-public class BatchIterator implements IndexedTupleSource {
-
-    private final BatchProducer source;
-    private boolean saveOnMark;
-    private TupleBuffer buffer;
-    private IndexedTupleSource bufferedTs;
-
-    public BatchIterator(BatchProducer source) {
-        this.source = source;
-    }
-
-    private boolean done;
-    private int currentRow = 1;
-    private TupleBatch currentBatch;
-    private List currentTuple;
-    private int bufferedIndex;
-    private boolean mark;
-    
-    @Override
-    public boolean hasNext() throws MetaMatrixComponentException,
-                            MetaMatrixProcessingException {
-    	
-    	if (done && this.bufferedTs == null) {
-            return false;
-        }
-        while (currentTuple == null) {
-            if (currentBatch == null) {
-            	if (this.bufferedTs != null) {
-            		if (this.currentRow <= this.bufferedIndex) {
-	            		this.bufferedTs.setPosition(currentRow++);
-	            		this.currentTuple = this.bufferedTs.nextTuple();
-	            		return true;
-            		}
-            		if (done) {
-            			return false;
-            		}
-            	} 
-                currentBatch = this.source.nextBatch();
-                if (buffer != null && !saveOnMark) {
-                	buffer.addTupleBatch(currentBatch, true);
-                	bufferedIndex = currentBatch.getEndRow();
-                }
-            }
-
-            if (currentBatch.containsRow(currentRow)) {
-                this.currentTuple = currentBatch.getTuple(currentRow++);
-            } else {
-                done = currentBatch.getTerminationFlag();
-                currentBatch = null;
-                if (done) {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-    
-    public void setBuffer(TupleBuffer buffer, boolean saveOnMark) {
-		this.buffer = buffer;
-		this.bufferedTs = this.buffer.createIndexedTupleSource();
-		this.saveOnMark = saveOnMark;
-	}
-    
-    @Override
-    public void closeSource() {
-    	if (this.buffer != null) {
-    		this.buffer.remove();
-    		this.buffer = null;
-    	}
-    }
-    
-    @Override
-    public List<SingleElementSymbol> getSchema() {
-    	return source.getOutputElements();
-    }
-    
-    @Override
-    public List<?> nextTuple() throws MetaMatrixComponentException,
-    		MetaMatrixProcessingException {
-        if (currentTuple == null && !hasNext()) {
-            return null;
-        }
-        List result = currentTuple;
-        currentTuple = null;
-        if (mark && saveOnMark && this.currentRow - 1 > this.buffer.getRowCount()) {
-        	this.buffer.setRowCount(this.currentRow - 2);
-        	this.buffer.addTuple(result);
-        	this.bufferedIndex = this.currentRow - 1;
-        }
-        return result;
-    }
-
-    public void reset() {
-    	if (this.bufferedTs != null) {
-    		mark = false;
-    		this.bufferedTs.reset();
-    		if (this.currentRow != this.bufferedTs.getCurrentIndex()) {
-    			this.currentRow = this.bufferedTs.getCurrentIndex();
-    			this.currentTuple = null;
-    		}
-    		return;
-    	}
-        throw new UnsupportedOperationException();
-    }
-
-    public void mark() {
-    	if (this.bufferedTs != null) {
-    		this.bufferedTs.mark();
-    		if (saveOnMark && this.currentRow > this.bufferedIndex) {
-    			this.buffer.purge();
-    			this.bufferedIndex = 0;
-    		}
-    	}
-    	mark = true;
-    }
-
-    @Override
-    public int getCurrentIndex() {
-        return currentRow;
-    }
-
-    public void setPosition(int position) {
-    	if (this.bufferedTs != null) {
-    		this.bufferedTs.setPosition(position);
-    		this.currentRow = position;
-    	}
-    	if (this.currentBatch == null && position < this.currentRow) {
-			throw new UnsupportedOperationException("Backwards positioning is not allowed"); //$NON-NLS-1$
-    	}
-    	this.currentRow = position;
-        this.currentTuple = null;
-    	if (this.currentBatch == null || !this.currentBatch.containsRow(position)) {
-        	this.currentBatch = null;
-    	}
-    }
-    
-    @Override
-    public int available() {
-    	if (this.currentRow <= this.bufferedIndex) {
-    		this.bufferedTs.setPosition(this.currentRow);
-    		return this.bufferedTs.available();
-    	}
-    	if (currentBatch != null) {
-    		return currentBatch.getEndRow() - currentRow + 1;
-    	}
-    	return 0;
-    }
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/CollectionTupleSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/CollectionTupleSource.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/CollectionTupleSource.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,78 +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.processor;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-
-public class CollectionTupleSource implements TupleSource {
-	
-	private Iterator<? extends List<?>> tuples;
-	private List<SingleElementSymbol> schema;
-
-	public static CollectionTupleSource createUpdateCountTupleSource(int count) {
-		return new CollectionTupleSource(Arrays.asList(Arrays.asList(count)).iterator(), Command.getUpdateCommandSymbol());
-	}
-	
-	public static CollectionTupleSource createNullTupleSource(List<SingleElementSymbol> schema) {
-		return new CollectionTupleSource(new ArrayList<List<Object>>(0).iterator(), schema);
-	}
-	
-	public CollectionTupleSource(Iterator<? extends List<?>> tuples,
-			List<SingleElementSymbol> schema) {
-		this.tuples = tuples;
-		this.schema = schema;
-	}
-
-	@Override
-	public List<?> nextTuple() {
-		if (tuples.hasNext()) {
-			return tuples.next();
-		}
-		return null;
-	}
-	
-	@Override
-	public List<SingleElementSymbol> getSchema() {
-		return schema;
-	}
-	
-	@Override
-	public void closeSource() {
-		
-	}
-	
-	@Override
-	public int available() {
-		if (tuples.hasNext()) {
-			return 1;
-		}
-		return 0;
-	}
-}
\ No newline at end of file

Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorDataManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorDataManager.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorDataManager.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,51 +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.processor;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
-
-public interface ProcessorDataManager {
-
-	TupleSource registerRequest(Object processorId, Command command, String modelName, String connectorBindingId, int nodeID)
-		throws MetaMatrixComponentException, MetaMatrixProcessingException;
-	
-    /**
-     * Lookup a value from a cached code table.  If the code table is not loaded, it will be 
-     * loaded on the first query.  Code tables should be cached based on a combination of
-     * the codeTableName, returnElementName, and keyElementName.  If the table is not loaded,
-     * a request will be made and the method should throw a BlockedException.
-     */
-    Object lookupCodeValue(CommandContext context,
-                                           String codeTableName,
-                                           String returnElementName,
-                                           String keyElementName,
-                                           Object keyValue) throws BlockedException,
-                                                           MetaMatrixComponentException, MetaMatrixProcessingException;
-    
-    void clearCodeTables();
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,166 +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.processor;
-
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.client.plan.PlanNode;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-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.query.analysis.AnalysisRecord;
-import com.metamatrix.query.processor.BatchCollector.BatchProducer;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- * <p>This class represents a processor plan.  It is generic in that it 
- * abstracts the interface to the plan by the processor, meaning that the
- * actual implementation of the plan or the types of processing done by the
- * plan is not important to the processor.</p>
- * <p>All the implementations of this interface need to implement {@link #clone}
- * method. The plan is only clonable in the pre or post-processing stage, not
- * during the processing state (things like program state, result sets, etc).
- * It's only safe to clone in between query processings.  In other words, it's
- * only safe to call {@link #clone} before the call to {@link #open} or after
- * the call to {@link #close}.
- * </p>
- */
-public abstract class ProcessorPlan implements Cloneable, BatchProducer {
-	
-    private List warnings = null;
-    
-    private CommandContext context;
-
-	/**
-	 * Initialize the plan with some required pieces of data for making 
-	 * queries.  The data manager is used to make queries and the processorID
-	 * must be passed with the request so the data manager can find the 
-	 * processor again.
-	 * 
-	 * @param context Process execution context
-	 * @param dataMgr Data manager reference
-     * @param bufferMgr Buffer manager reference
-	 */
-	public abstract void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr);
-	
-    /**
-     * Get all warnings found while processing this plan.  These warnings may
-     * be detected throughout the plan lifetime, which means new ones may arrive
-     * at any time.  This method returns all current warnings and clears 
-     * the current warnings list.  The warnings are in order they were detected.
-     * @return Current list of warnings, never null
-     */
-    public List getAndClearWarnings() {
-        if (warnings == null) {
-            return null;
-        }
-        List copied = warnings;
-        warnings = null;
-        return copied;
-    }
-    
-    protected void addWarning(MetaMatrixException warning) {
-        if (warnings == null) {
-            warnings = new ArrayList(1);
-        }
-        warnings.add(warning);
-    }
-
-    /**
-     * Reset a plan so that it can be processed again.
-     */
-    public void reset() {
-    	this.warnings = null;
-    }
-    
-    /**
-     * Get list of resolved elements describing output columns for this plan.
-     * @return List of SingleElementSymbol
-     */
-    public abstract List getOutputElements();
-    
-    /**
-     * Get the processor context, which can be modified.
-     * @return context object
-     */
-    public CommandContext getContext() {
-        return context;
-    }
-    
-    public void setContext(CommandContext context) {
-		this.context = context;
-	}
-    
-    /**
-     * Open the plan for processing.
-     * @throws MetaMatrixComponentException
-     */
-    public abstract void open() throws MetaMatrixComponentException, MetaMatrixProcessingException;
-    
-    /**
-     * Get a batch of results or possibly an Exception.
-     * @return Batch of results
-     * @throws BlockedException indicating next batch is not available yet
-     * @throws MetaMatrixComponentException for non-business rule exception
-     * @throws MetaMatrixProcessingException for business rule exception, related
-     * to user input or modeling
-     */
-    public abstract TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException;
-
-    /**
-     * Close the plan after processing.
-     * @throws MetaMatrixComponentException
-     */
-    public abstract void close() throws MetaMatrixComponentException;
-    
-	/**
-	 * Return a safe clone of the ProcessorPlan.  A ProcessorPlan may only be
-	 * safely cloned in between processings.  That is, it is only safe to clone
-	 * a plan before it is {@link #open opened} or after it is {@link #close
-	 * closed}.
-	 * @return safe clone of this ProcessorPlan, as long as it is not open for
-	 * processing
-	 */
-	public abstract ProcessorPlan clone();
-	
-	public boolean requiresTransaction(boolean transactionalReads) {
-		return transactionalReads;
-	}
-	
-    /**
-     * @see com.metamatrix.query.processor.Describable#getDescriptionProperties()
-     */
-    public PlanNode getDescriptionProperties() {
-        PlanNode props = new PlanNode(this.getClass().getSimpleName());
-        props.addProperty(PROP_OUTPUT_COLS, AnalysisRecord.getOutputColumnProperties(getOutputElements()));
-        return props;
-    }
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,233 +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.processor;
-
-import java.util.List;
-
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.logging.MessageLevel;
-import org.teiid.resource.cci.DataNotAvailableException;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-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.buffer.BufferManager.BufferReserveMode;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.processor.BatchCollector.BatchProducer;
-import com.metamatrix.query.util.CommandContext;
-
-public class QueryProcessor implements BatchProducer {
-	
-	public static class ExpiredTimeSliceException extends MetaMatrixRuntimeException {
-		
-	}
-	
-	private static ExpiredTimeSliceException EXPIRED_TIME_SLICE = new ExpiredTimeSliceException();
-	
-	public interface ProcessorFactory {
-		QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-	}
-	
-    private CommandContext context;
-	private ProcessorDataManager dataMgr;
-	private BufferManager bufferMgr;
-	private ProcessorPlan processPlan;
-    private boolean initialized = false;
-    private int reserved;
-    /** Flag that marks whether the request has been canceled. */
-    private volatile boolean requestCanceled = false;
-    private static final int DEFAULT_WAIT = 50;       
-    private boolean processorClosed = false;
-    
-    private boolean nonBlocking = false;
-         
-    /**
-     * Construct a processor with all necessary information to process.
-     * @param plan The plan to process
-     * @param context The context that this plan is being processed in
-     * @param bufferMgr The buffer manager that provides access to tuple sources
-     * @param dataMgr The data manager that provides access to get data
-     * @throws MetaMatrixComponentException 
-     */
-    public QueryProcessor(ProcessorPlan plan, CommandContext context, BufferManager bufferMgr, ProcessorDataManager dataMgr) throws MetaMatrixComponentException {
-        this.context = context;
-		this.dataMgr = dataMgr;
-		this.processPlan = plan;
-		this.bufferMgr = bufferMgr;
-		// Add data manager to all nodes in tree
-		this.processPlan.initialize(context, this.dataMgr, bufferMgr);
-    }
-    
-    public CommandContext getContext() {
-		return context;
-	}
-    
-	public Object getProcessID() {
-		return this.context.getProcessorID();
-	}
-	
-    public ProcessorPlan getProcessorPlan() {
-        return this.processPlan;
-    }
-
-	public TupleBatch nextBatch()
-		throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
-		
-	    while (true) {
-	    	long wait = DEFAULT_WAIT;
-	    	try {
-	    		return nextBatchDirect();
-	    	} catch (ExpiredTimeSliceException e) {
-	    		if (!nonBlocking) {
-	    			throw e;
-	    		}
-	    		continue;
-	    	} catch (DataNotAvailableException e) {
-	    		if (!nonBlocking) {
-	    			throw e;
-	    		}
-	    		wait = e.getRetryDelay();
-	    	} catch (BlockedException e) {
-	    		if (!nonBlocking) {
-	    			throw e;
-	    		}
-	    	}
-    		try {
-                Thread.sleep(wait);
-            } catch (InterruptedException err) {
-                throw new MetaMatrixComponentException(err);
-            }
-	    }
-	}
-	
-	private TupleBatch nextBatchDirect()
-		throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
-		
-	    boolean done = false;
-	    TupleBatch result = null;
-		
-	    try {
-	    	// initialize if necessary
-			if(! initialized) {
-				if (reserved == 0) {
-					reserved = this.bufferMgr.reserveBuffers(this.bufferMgr.getSchemaSize(this.getOutputElements()), BufferReserveMode.FORCE);
-				}
-				// Open the top node for reading
-				processPlan.open();
-				initialized = true;
-			}
-	
-			long currentTime = System.currentTimeMillis();
-			Assertion.assertTrue(!processorClosed);
-	        while(currentTime < context.getTimeSliceEnd()) {
-	        	if (requestCanceled) {
-	                throw new MetaMatrixProcessingException(QueryExecPlugin.Util.getString("QueryProcessor.request_cancelled", getProcessID())); //$NON-NLS-1$
-	            }
-	        	if (currentTime > context.getTimeoutEnd()) {
-	        		throw new MetaMatrixProcessingException("Query timed out"); //$NON-NLS-1$
-	        	}
-	            result = processPlan.nextBatch();
-	
-	        	if(result.getTerminationFlag()) {
-	        		done = true;
-	        		break;
-	        	}
-	        	
-	        	if (result.getRowCount() > 0) {
-	        		break;
-	        	}
-	        	
-	        }
-	    } catch (BlockedException e) {
-	    	throw e;
-	    } catch (MetaMatrixException e) {
-    		closeProcessing();
-	    	if (e instanceof MetaMatrixProcessingException) {
-	    		throw (MetaMatrixProcessingException)e;
-	    	}
-	    	if (e instanceof MetaMatrixComponentException) {
-	    		throw (MetaMatrixComponentException)e;
-	    	}
-	    	throw new MetaMatrixComponentException(e);
-	    }
-		if(done) {
-			closeProcessing();
-		} 
-	    if (result == null) {
-	    	throw EXPIRED_TIME_SLICE;
-	    }
-		return result;
-	}
-
-	                   
-    /**
-     * Close processing and clean everything up.  Should only be called by the same thread that called process.
-     */
-    public void closeProcessing() {
-    	if (processorClosed) {
-    		return;
-    	}
-    	if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-    		LogManager.logDetail(LogConstants.CTX_DQP, "QueryProcessor: closing processor"); //$NON-NLS-1$
-    	}
-		this.bufferMgr.releaseBuffers(reserved);
-		reserved = 0;
-        processorClosed = true;
-        try {
-        	processPlan.close();
-		} catch (MetaMatrixComponentException e1){
-			LogManager.logDetail(LogConstants.CTX_DQP, e1, "Error closing processor"); //$NON-NLS-1$
-		}
-    }
-
-    @Override
-    public List getOutputElements() {
-    	return this.processPlan.getOutputElements();
-    }
-
-    public List<Exception> getAndClearWarnings() {
-        return this.processPlan.getAndClearWarnings();
-    }
-    
-    /** 
-     * Asynch shutdown of the QueryProcessor, which may trigger exceptions in the processing thread
-     */
-    public void requestCanceled() {
-        this.requestCanceled = true;
-    }
-    
-	public BatchCollector createBatchCollector() throws MetaMatrixComponentException {
-		return new BatchCollector(this, this.bufferMgr.createTupleBuffer(this.processPlan.getOutputElements(), context.getConnectionID(), TupleSourceType.PROCESSOR));
-	}
-	
-	public void setNonBlocking(boolean nonBlocking) {
-		this.nonBlocking = nonBlocking;
-	}
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/TempTableDataManager.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/TempTableDataManager.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,97 +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.processor;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.tempdata.TempTableStore;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- * This proxy ProcessorDataManager is used during XML query processing to handle temporary groups
- * in the document model.  Temp groups are materialized during processing, and their tuple sources
- * are cached, so this proxy shortcuts the need to go to the DataTierManager and immediately
- * returns the tuple source (synchronously) if a temp group's source is what's being requested.
- */
-public class TempTableDataManager implements ProcessorDataManager {
-
-    private ProcessorDataManager processorDataManager;
-    private TempTableStore tempTableStore;
-
-    /**
-     * Constructor takes the "real" ProcessorDataManager that this object will be a proxy to,
-     * and will pass most calls through to transparently.  Only when a request is registered for
-     * a temp group will this proxy do it's thing.  A ProcessorEnvironment is needed to to 
-     * access cached information about temp groups
-     * @param processorDataManager the real ProcessorDataManager that this object is a proxy to
-     * @param env a ProcessorEnvironment implementation
-     */
-    public TempTableDataManager(ProcessorDataManager processorDataManager, TempTableStore tempTableStore){
-        this.processorDataManager = processorDataManager;
-        this.tempTableStore = tempTableStore;
-    }
-
-	/**
-     * This is the magic method.  If the command is selecting from a temporary group, that 
-     * temporary groups tuple source (which is cached in the ProcessorEnvironment) will
-     * be retrieved and immediately (synchronously) delivered to the QueryProcessor.
-     * If a temp group is <i>not</i> being selected from, then this request will be
-     * passed through to the underlying ProcessorDataManager.
-	 * @throws MetaMatrixProcessingException 
-	 */
-	public TupleSource registerRequest(
-		Object processorID,
-		Command command,
-		String modelName,
-		String connectorBindingId, int nodeID)
-		throws MetaMatrixComponentException, MetaMatrixProcessingException {          
-
-        if(tempTableStore != null) {
-            TupleSource result = tempTableStore.registerRequest(command);
-            if (result != null) {
-            	return result;
-            }
-        }
-        return this.processorDataManager.registerRequest(processorID, command, modelName, connectorBindingId, nodeID);
-	}
-
-    public Object lookupCodeValue(
-        CommandContext context,
-        String codeTableName,
-        String returnElementName,
-        String keyElementName,
-        Object keyValue)
-        throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
-            
-        return this.processorDataManager.lookupCodeValue(context, codeTableName, returnElementName, keyElementName, keyValue);
-    }
-    
-    @Override
-    public void clearCodeTables() {
-    	this.processorDataManager.clearCodeTables();
-    }
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/resolver/CommandResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/CommandResolver.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/CommandResolver.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,52 +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.resolver;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.sql.lang.Command;
-
-/**
- * This is the interface that is implemented for each type of command, telling how 
- * to resolve that command.  
- */
-public interface CommandResolver {
-
-    /**
-     * Resolve the command using the metadata.  
-     * @param command The command to resolve
-     * @param metadata Metadata
-     * @param analysis
-     * @param resolveNullLiterals true if the resolver should consider replacing null literals with more appropriate types 
-     * @return the TempMetadataStore containing the metadata defined by this command
-     * @throws QueryMetadataException If there is a metadata problem
-     * @throws QueryResolverException If the query cannot be resolved
-     * @throws MetaMatrixComponentException If there is an internal error     
-     */        
-    void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
-    throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException;
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,236 +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.resolver;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-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;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-public abstract class ProcedureContainerResolver implements CommandResolver {
-
-    public abstract void resolveProceduralCommand(Command command,
-                                                  TempMetadataAdapter metadata,
-                                                  AnalysisRecord analysis) throws QueryMetadataException,
-                                                                          QueryResolverException,
-                                                                          MetaMatrixComponentException;
-    
-    /**
-     * Expand a command by finding and attaching all subcommands to the command.  If
-     * some initial resolution must be done for this to be accomplished, that is ok, 
-     * but it should be kept to a minimum.
-     * @param command The command to expand
-     * @param useMetadataCommands True if resolver should use metadata commands to completely resolve
-     * @param metadata Metadata access
-     * @param analysis The analysis record that will be filled in if doing annotation.
-     * 
-     * @throws QueryMetadataException If there is a metadata problem
-     * @throws QueryResolverException If the query cannot be resolved
-     * @throws MetaMatrixComponentException If there is an internal error
-     */
-    public Command expandCommand(ProcedureContainer procCommand, QueryMetadataInterface metadata, AnalysisRecord analysis)
-    throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
-    	
-        // Resolve group so we can tell whether it is an update procedure
-        GroupSymbol group = procCommand.getGroup();
-
-        Command subCommand = null;
-        
-        String plan = getPlan(metadata, procCommand);
-        
-        if (plan == null) {
-            return null;
-        }
-        
-        QueryParser parser = QueryParser.getQueryParser();
-        try {
-            subCommand = parser.parseCommand(plan);
-        } catch(QueryParserException e) {
-            throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0045, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0045, group));
-        }
-        
-        if(subCommand instanceof CreateUpdateProcedureCommand){
-            CreateUpdateProcedureCommand cupCommand = (CreateUpdateProcedureCommand)subCommand;
-            //if the subcommand is virtual stored procedure, it must have the same
-            //projected symbol as its parent.
-            if(!cupCommand.isUpdateProcedure()){
-                cupCommand.setProjectedSymbols(procCommand.getProjectedSymbols());
-            } 
-            
-            cupCommand.setVirtualGroup(procCommand.getGroup());
-            cupCommand.setUserCommand(procCommand);
-        } 
-        
-        //find the childMetadata using a clean metadata store
-        TempMetadataStore childMetadata = new TempMetadataStore();
-        QueryMetadataInterface resolveMetadata = new TempMetadataAdapter(metadata, childMetadata);
-
-        GroupContext externalGroups = findChildCommandMetadata(procCommand, childMetadata, resolveMetadata);
-        
-        QueryResolver.setChildMetadata(subCommand, childMetadata.getData(), externalGroups);
-        
-        QueryResolver.resolveCommand(subCommand, Collections.EMPTY_MAP, metadata, analysis);
-        
-        return subCommand;
-    }
-
-    /** 
-     * For a given resolver, this returns the unparsed command.
-     * 
-     * @param metadata
-     * @param group
-     * @return
-     * @throws MetaMatrixComponentException
-     * @throws QueryMetadataException
-     */
-    protected abstract String getPlan(QueryMetadataInterface metadata,
-                           GroupSymbol group) throws MetaMatrixComponentException,
-                                             QueryMetadataException;
-        
-    /**
-     * Find all metadata defined by this command for it's children.  This metadata should be collected 
-     * in the childMetadata object.  Typical uses of this are for stored queries that define parameter
-     * variables valid in subcommands. only used for inserts, updates, and deletes
-     * @param metadata Metadata access
-     * @param command The command to find metadata on
-     * @param childMetadata The store to collect child metadata in 
-     * @throws QueryMetadataException If there is a metadata problem
-     * @throws QueryResolverException If the query cannot be resolved
-     * @throws MetaMatrixComponentException If there is an internal error    
-     */ 
-    public GroupContext findChildCommandMetadata(ProcedureContainer container, TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata)
-    throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
-        // get the group on the delete statement
-        GroupSymbol group = container.getGroup();
-        // proceed further if it is a virtual group
-            
-        return createChildMetadata(discoveredMetadata, metadata, group);
-    }
-
-	static GroupContext createChildMetadata(
-			TempMetadataStore discoveredMetadata,
-			QueryMetadataInterface metadata, GroupSymbol group)
-			throws QueryMetadataException, MetaMatrixComponentException {
-		GroupContext externalGroups = new GroupContext();
-        
-        //Look up elements for the virtual group
-        List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(group, metadata);
-
-        // Create the INPUT variables
-        List<ElementSymbol> inputElments = new ArrayList<ElementSymbol>(elements.size());
-        for(int i=0; i<elements.size(); i++) {
-            ElementSymbol virtualElmnt = elements.get(i);
-            ElementSymbol inputElement = (ElementSymbol)virtualElmnt.clone();
-            inputElments.add(inputElement);
-        }
-
-        addScalarGroup(ProcedureReservedWords.INPUT, discoveredMetadata, externalGroups, inputElments);
-        addScalarGroup(ProcedureReservedWords.INPUTS, discoveredMetadata, externalGroups, inputElments);
-
-        // Switch type to be boolean for all CHANGING variables
-        List<ElementSymbol> changingElements = new ArrayList<ElementSymbol>(elements.size());
-        for(int i=0; i<elements.size(); i++) {
-            ElementSymbol virtualElmnt = elements.get(i);
-            ElementSymbol changeElement = (ElementSymbol)virtualElmnt.clone();
-            changeElement.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
-            changingElements.add(changeElement);
-        }
-
-        addScalarGroup(ProcedureReservedWords.CHANGING, discoveredMetadata, externalGroups, changingElements);
-		return externalGroups;
-	}
-        
-    /** 
-     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
-     */
-    public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
-        throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
-        
-        ProcedureContainer procCommand = (ProcedureContainer)command;
-        
-        resolveGroup(metadata, procCommand);
-        
-        resolveProceduralCommand(procCommand, metadata, analysis);
-        
-        getPlan(metadata, procCommand);
-    }
-
-	private String getPlan(QueryMetadataInterface metadata, ProcedureContainer procCommand)
-			throws MetaMatrixComponentException, QueryMetadataException,
-			QueryResolverException {
-		if(!procCommand.getGroup().isTempGroupSymbol() && metadata.isVirtualGroup(procCommand.getGroup().getMetadataID())) {
-            String plan = getPlan(metadata, procCommand.getGroup());
-            
-            if(plan == null) {
-                throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0009, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0009, procCommand.getGroup(), procCommand.getClass().getSimpleName()));
-            }
-            return plan;
-        }
-		return null;
-	}
-    
-    /** 
-     * @param metadata
-     * @param procCommand
-     * @throws MetaMatrixComponentException
-     * @throws QueryResolverException
-     */
-    protected void resolveGroup(TempMetadataAdapter metadata,
-                              ProcedureContainer procCommand) throws MetaMatrixComponentException,
-                                                            QueryResolverException {
-        // Resolve group so we can tell whether it is an update procedure
-        GroupSymbol group = procCommand.getGroup();
-        ResolverUtil.resolveGroup(group, metadata);
-    }
-
-	public static GroupSymbol addScalarGroup(String name, TempMetadataStore metadata, GroupContext externalGroups, List symbols) {
-		GroupSymbol variables = new GroupSymbol(name);
-	    externalGroups.addGroup(variables);
-	    TempMetadataID tid = metadata.addTempGroup(name, symbols);
-	    tid.setScalarGroup(true);
-	    variables.setMetadataID(tid);
-	    return variables;
-	}
-        
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,298 +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.resolver;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.teiid.logging.LogManager;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-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.resolver.command.BatchedUpdateResolver;
-import com.metamatrix.query.resolver.command.DeleteResolver;
-import com.metamatrix.query.resolver.command.DynamicCommandResolver;
-import com.metamatrix.query.resolver.command.ExecResolver;
-import com.metamatrix.query.resolver.command.InsertResolver;
-import com.metamatrix.query.resolver.command.SetQueryResolver;
-import com.metamatrix.query.resolver.command.SimpleQueryResolver;
-import com.metamatrix.query.resolver.command.TempTableResolver;
-import com.metamatrix.query.resolver.command.UpdateProcedureResolver;
-import com.metamatrix.query.resolver.command.UpdateResolver;
-import com.metamatrix.query.resolver.command.XMLQueryResolver;
-import com.metamatrix.query.resolver.command.XQueryResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-
-/**
- * <P>The QueryResolver is used between Parsing and QueryValidation. The SQL queries,
- * inserts, updates and deletes are parsed and converted into objects. The language
- * objects have variable names which resolved to fully qualified names using metadata
- * information. The resolver is also used in transforming the values in language
- * objects to their variable types defined in metadata.
- */
-public class QueryResolver {
-
-    private static final CommandResolver SIMPLE_QUERY_RESOLVER = new SimpleQueryResolver();
-    private static final CommandResolver SET_QUERY_RESOLVER = new SetQueryResolver();
-    private static final CommandResolver XML_QUERY_RESOLVER = new XMLQueryResolver();
-    private static final CommandResolver EXEC_RESOLVER = new ExecResolver();
-    private static final CommandResolver INSERT_RESOLVER = new InsertResolver();
-    private static final CommandResolver UPDATE_RESOLVER = new UpdateResolver();
-    private static final CommandResolver DELETE_RESOLVER = new DeleteResolver();
-    private static final CommandResolver UPDATE_PROCEDURE_RESOLVER = new UpdateProcedureResolver();
-    private static final CommandResolver X_QUERY_RESOLVER = new XQueryResolver();
-    private static final CommandResolver BATCHED_UPDATE_RESOLVER = new BatchedUpdateResolver();
-    private static final CommandResolver DYNAMIC_COMMAND_RESOLVER = new DynamicCommandResolver();
-    private static final CommandResolver TEMP_TABLE_RESOLVER = new TempTableResolver();
-    
-    public static Command expandCommand(ProcedureContainer proc, QueryMetadataInterface metadata, AnalysisRecord analysisRecord) throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
-    	ProcedureContainerResolver cr = (ProcedureContainerResolver)chooseResolver(proc, metadata);
-    	return cr.expandCommand(proc, metadata, analysisRecord);
-    }
-
-    /**
-     * This implements an algorithm to resolve all the symbols created by the parser into real metadata IDs
-     * @param command Command the SQL command we are running (Select, Update, Insert, Delete)
-     * @param metadata QueryMetadataInterface the metadata
-     * @param analysis The analysis record which can be used to add anotations and debug information.
-     */
-     public static void resolveCommand(Command command, QueryMetadataInterface metadata, AnalysisRecord analysis)
-         throws QueryResolverException, MetaMatrixComponentException {
-
-         resolveCommand(command, Collections.EMPTY_MAP, metadata, analysis);
-     }
-
-     /**
-      * This implements an algorithm to resolve all the symbols created by the parser into real metadata IDs
-      * @param command Command the SQL command we are running (Select, Update, Insert, Delete)
-      * @param metadata QueryMetadataInterface the metadata
-      */
-      public static void resolveCommand(Command command, QueryMetadataInterface metadata)
-          throws QueryResolverException, MetaMatrixComponentException {
-
-          resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
-      }
-
-   /**
-    * This implements an algorithm to resolve all the symbols created by the parser into real metadata IDs
- * @param externalMetadata Map of GroupSymbol to a List of ElementSymbol that identifies
-    * valid external groups that can be resolved against. Any elements resolved against external
-    * groups will be treated as variables
- * @param metadata QueryMetadataInterface the metadata
- * @param analysis The analysis record which can be used to add anotations and debug information.
- * @param command Command the SQL command we are running (Select, Update, Insert, Delete)
-    */
-    public static TempMetadataStore resolveCommand(Command currentCommand, Map externalMetadata, QueryMetadataInterface metadata, 
-                                                     AnalysisRecord analysis)
-                       throws QueryResolverException, MetaMatrixComponentException {
-        return resolveCommand(currentCommand, externalMetadata, metadata, analysis, true);
-    }
-      
-    public static TempMetadataStore resolveCommand(Command currentCommand, Map externalMetadata, QueryMetadataInterface metadata, 
-                                      AnalysisRecord analysis, boolean resolveNullLiterals)
-        throws QueryResolverException, MetaMatrixComponentException {
-
-		LogManager.logTrace(org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving command", currentCommand}); //$NON-NLS-1$
-        
-        TempMetadataAdapter resolverMetadata = null;
-        try {
-            TempMetadataStore rootExternalStore = new TempMetadataStore();
-            if(externalMetadata != null) {
-                for(Iterator iter = externalMetadata.entrySet().iterator(); iter.hasNext();) {
-                    Map.Entry entry = (Map.Entry)iter.next();
-                    GroupSymbol group = (GroupSymbol) entry.getKey();
-                    List elements = (List) entry.getValue();
-                    rootExternalStore.addTempGroup(group.getName(), elements);
-                    currentCommand.addExternalGroupToContext(group);
-                }
-            } 
-            Map tempMetadata = currentCommand.getTemporaryMetadata();
-            if(tempMetadata == null) {
-                currentCommand.setTemporaryMetadata(new HashMap(rootExternalStore.getData()));
-            } else {
-                tempMetadata.putAll(rootExternalStore.getData());
-            }
-            
-            TempMetadataStore discoveredMetadata = new TempMetadataStore(currentCommand.getTemporaryMetadata());
-            
-            resolverMetadata = new TempMetadataAdapter(metadata, discoveredMetadata);
-            
-            // Resolve external groups for command
-            Collection externalGroups = currentCommand.getAllExternalGroups();
-            Iterator extIter = externalGroups.iterator();
-            while(extIter.hasNext()) {
-                GroupSymbol extGroup = (GroupSymbol) extIter.next();
-                Object metadataID = extGroup.getMetadataID();
-                //make sure that the group is resolved and that it is pointing to the appropriate temp group
-                if (metadataID == null || (!(extGroup.getMetadataID() instanceof TempMetadataID) && discoveredMetadata.getTempGroupID(extGroup.getName()) != null)) {
-                    metadataID = resolverMetadata.getGroupID(extGroup.getName());
-                    extGroup.setMetadataID(metadataID);
-                }
-            }
-
-            CommandResolver resolver = chooseResolver(currentCommand, resolverMetadata);
-
-            // Resolve this command
-            resolver.resolveCommand(currentCommand, resolverMetadata, analysis, resolveNullLiterals);            
-        } catch(QueryMetadataException e) {
-            throw new QueryResolverException(e, e.getMessage());
-        }
-
-        // Flag that this command has been resolved.
-        currentCommand.setIsResolved(true);
-        
-        return resolverMetadata.getMetadataStore();
-    }
-
-    /**
-     * Method chooseResolver.
-     * @param command
-     * @param metadata
-     * @return CommandResolver
-     */
-    private static CommandResolver chooseResolver(Command command, QueryMetadataInterface metadata)
-        throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
-
-        switch(command.getType()) {
-            case Command.TYPE_QUERY:
-                if(command instanceof Query) {
-                    if(isXMLQuery((Query)command, metadata)) {
-                        return XML_QUERY_RESOLVER;
-                    }
-                    return SIMPLE_QUERY_RESOLVER;
-                }
-                return SET_QUERY_RESOLVER;
-            case Command.TYPE_INSERT:               return INSERT_RESOLVER;
-            case Command.TYPE_UPDATE:               return UPDATE_RESOLVER;
-            case Command.TYPE_DELETE:               return DELETE_RESOLVER;
-            case Command.TYPE_STORED_PROCEDURE:     return EXEC_RESOLVER;
-            case Command.TYPE_UPDATE_PROCEDURE:     return UPDATE_PROCEDURE_RESOLVER;
-            case Command.TYPE_XQUERY:               return X_QUERY_RESOLVER;
-            case Command.TYPE_BATCHED_UPDATE:       return BATCHED_UPDATE_RESOLVER;
-            case Command.TYPE_DYNAMIC:              return DYNAMIC_COMMAND_RESOLVER;
-            case Command.TYPE_CREATE:               return TEMP_TABLE_RESOLVER;
-            case Command.TYPE_DROP:                 return TEMP_TABLE_RESOLVER;
-            default:
-                throw new AssertionError("Unknown command type"); //$NON-NLS-1$
-        }
-    }
-
-    /**
-     * Check to verify if the query would return XML results.
-     * @param query the query to check
-     * @param metadata QueryMetadataInterface the metadata
-     */
-    public static boolean isXMLQuery(Query query, QueryMetadataInterface metadata)
-     throws MetaMatrixComponentException, QueryMetadataException, QueryResolverException {
-
-        // Check first group
-        From from = query.getFrom();
-        if(from == null){
-            //select with no from
-            return false;
-        }
-        
-        if (from.getClauses().size() != 1) {
-            return false;
-        }
-        
-        FromClause clause = (FromClause)from.getClauses().get(0);
-        
-        if (!(clause instanceof UnaryFromClause)) {
-            return false;
-        }
-        
-        GroupSymbol symbol = ((UnaryFromClause)clause).getGroup();
-        
-        ResolverUtil.resolveGroup(symbol, metadata);
-                
-        if (symbol.isProcedure()) {
-            return false;
-        }
-        
-        Object groupID = ((UnaryFromClause)clause).getGroup().getMetadataID();
-
-        return metadata.isXMLGroup(groupID);
-    }
-    
-    /**
-     * Resolve just a criteria.  The criteria will be modified so nothing is returned.
-     * @param criteria Criteria to resolve
-     * @param metadata Metadata implementation
-     */
-    public static void resolveCriteria(Criteria criteria, QueryMetadataInterface metadata)
-        throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
-
-        ResolverVisitor.resolveLanguageObject(criteria, metadata);
-    }
-
-    public static void setChildMetadata(Command subCommand, Command parent) {
-        Map childMetadataMap = parent.getTemporaryMetadata();
-        GroupContext parentContext = parent.getExternalGroupContexts();
-        
-        setChildMetadata(subCommand, childMetadataMap, parentContext);
-    }
-    
-    public static void setChildMetadata(Command subCommand, Map parentTempMetadata, GroupContext parentContext) {
-        Map tempMetadata = subCommand.getTemporaryMetadata();
-        if(tempMetadata == null) {
-            subCommand.setTemporaryMetadata(new HashMap(parentTempMetadata));
-        } else {
-            tempMetadata.putAll(parentTempMetadata);
-        }
-    
-        subCommand.setExternalGroupContexts(parentContext);
-    }
-    
-    public static Map getVariableValues(Command command, QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
-        
-        CommandResolver resolver = chooseResolver(command, metadata);
-        
-        if (resolver instanceof VariableResolver) {
-            return ((VariableResolver)resolver).getVariableValues(command, metadata);
-        }
-        
-        return Collections.EMPTY_MAP;
-    }
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/resolver/VariableResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/VariableResolver.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/VariableResolver.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,37 +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.resolver;
-
-import java.util.Map;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.lang.Command;
-
-public interface VariableResolver {
-
-    Map getVariableValues(Command command, QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException;
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageObject.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageObject.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageObject.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,61 +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;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This is the primary interface for all language objects.  It extends a few 
- * key interfaces and adds some additional methods to allow the {@link LanguageVisitor}
- * to work.
- */
-public interface LanguageObject extends Serializable, Cloneable {
-
-    /**
-     * Method for accepting a visitor.  It is the responsibility of the 
-     * language object to call back on the visitor.
-     * @param visitor Visitor being used
-     */
-    void acceptVisitor(LanguageVisitor visitor);
-		
-	/**
-	 * Implement clone to make objects cloneable.
-	 * @return Deep clone of this object
-	 */
-    Object clone();
-    
-    public static class Util {
-
-		public static <S extends LanguageObject, T extends S> ArrayList<S> deepClone(List<T> collection, Class<S> type) {
-			ArrayList<S> result = new ArrayList<S>(collection.size());
-			for (LanguageObject obj : collection) {
-				result.add(type.cast(obj.clone()));
-			}
-			return result;
-		}
-    	
-    }
-    	 
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageVisitor.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageVisitor.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,133 +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;
-
-import com.metamatrix.query.sql.lang.*;
-import com.metamatrix.query.sql.symbol.*;
-import com.metamatrix.query.sql.proc.*;
-
-/**
- * <p>The LanguageVisitor can be used to visit a LanguageObject as if it were a tree
- * and perform some action on some or all of the language objects that are visited.
- * The LanguageVisitor is extended to create a concrete visitor and some or all of 
- * the public visit methods should be overridden to provide the visitor functionality. 
- * These public visit methods SHOULD NOT be called directly.</p>
- */
-public abstract class LanguageVisitor {
-    
-    private boolean abort = false;
-
-    public void setAbort(boolean abort) {
-        this.abort = abort;
-    }
-    
-    public final boolean shouldAbort() {
-        return abort;
-    }
-
-    // Visitor methods for language objects
-    public void visit(BatchedUpdateCommand obj) {}
-    public void visit(BetweenCriteria obj) {}
-    public void visit(CaseExpression obj) {}
-    public void visit(CompareCriteria obj) {}
-    public void visit(CompoundCriteria obj) {}
-    public void visit(Delete obj) {
-        visit((ProcedureContainer)obj);
-    }
-    public void visit(ExistsCriteria obj) {}
-    public void visit(From obj) {}
-    public void visit(GroupBy obj) {}
-    public void visit(Insert obj) {
-        visit((ProcedureContainer)obj);
-    }
-    public void visit(IsNullCriteria obj) {}
-    public void visit(JoinPredicate obj) {}
-    public void visit(JoinType obj) {}
-    public void visit(Limit obj) {}
-    public void visit(MatchCriteria obj) {}
-    public void visit(NotCriteria obj) {}
-    public void visit(Option obj) {}
-    public void visit(OrderBy obj) {}
-    public void visit(Query obj) {}
-    public void visit(SearchedCaseExpression obj) {}
-    public void visit(Select obj) {}
-    public void visit(SetCriteria obj) {}
-    public void visit(SetQuery obj) {}
-    public void visit(StoredProcedure obj) {
-        visit((ProcedureContainer)obj);
-    }
-    public void visit(SubqueryCompareCriteria obj) {}
-    public void visit(SubqueryFromClause obj) {}
-    public void visit(SubquerySetCriteria obj) {}
-    public void visit(UnaryFromClause obj) {}
-    public void visit(Update obj) {
-        visit((ProcedureContainer)obj);
-    }
-    public void visit(Into obj) {}
-    public void visit(XQuery obj) {}
-    public void visit(DependentSetCriteria obj) {}
-    public void visit(Create obj) {}
-    public void visit(Drop obj) {}
-
-    // Visitor methods for symbol objects
-    public void visit(AggregateSymbol obj) {}
-    public void visit(AliasSymbol obj) {}
-    public void visit(AllInGroupSymbol obj) {}
-    public void visit(AllSymbol obj) {}
-    public void visit(Constant obj) {}
-    public void visit(ElementSymbol obj) {}
-    public void visit(ExpressionSymbol obj) {}
-    public void visit(Function obj) {}
-    public void visit(GroupSymbol obj) {}
-    public void visit(Reference obj) {}
-    public void visit(ScalarSubquery obj) {}
-    
-    // Visitor methods for procedure language objects    
-    public void visit(AssignmentStatement obj) {}
-    public void visit(Block obj) {}
-    public void visit(CommandStatement obj) {}
-    public void visit(CreateUpdateProcedureCommand obj) {}
-    public void visit(CriteriaSelector obj) {}
-    public void visit(DeclareStatement obj) {
-        visit((AssignmentStatement)obj);
-    }    
-    public void visit(HasCriteria obj) {}
-    public void visit(IfStatement obj) {}
-    public void visit(RaiseErrorStatement obj) {
-        visit((AssignmentStatement)obj);
-    }
-    public void visit(TranslateCriteria obj) {}
-    public void visit(BreakStatement obj) {}
-    public void visit(ContinueStatement obj) {}
-    public void visit(WhileStatement obj) {}
-    public void visit(LoopStatement obj) {}
-    public void visit(DynamicCommand obj) {}
-    public void visit(ProcedureContainer obj) {}
-    public void visit(SetClauseList obj) {}
-    public void visit(SetClause obj) {}
-    public void visit(OrderByItem obj) {}
-    public void visit(XMLElement obj) {}
-    public void visit(XMLAttributes obj) {}
-    public void visit(XMLForest obj) {}
-    public void visit(XMLNamespaces obj) {}
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java	2010-05-11 21:39:07 UTC (rev 2115)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java	2010-05-11 21:47:57 UTC (rev 2116)
@@ -1,81 +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;
-
-import java.lang.reflect.Field;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.teiid.connector.language.SQLReservedWords;
-
-/**
- * Special variable names in stored procedure language.
- */
-public class ProcedureReservedWords {
-
-	@Deprecated
-    public static final String INPUT = SQLReservedWords.INPUT;
-    
-    public static final String INPUTS = "INPUTS"; //$NON-NLS-1$
-
-    public static final String ROWS_UPDATED = "ROWS_UPDATED"; //$NON-NLS-1$
-
-	public static final String CHANGING = "CHANGING"; //$NON-NLS-1$
-
-    public static final String VARIABLES = "VARIABLES"; //$NON-NLS-1$
-    
-    public static final String DVARS = "DVARS"; //$NON-NLS-1$
-    
-    /**
- 	 * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
- 	 */
-    private static final Set<String> RESERVED_WORDS = new HashSet<String>();
-
-    // Initialize RESERVED_WORDS set - This is a poor man's enum.  To much legacy code expects the constants to be Strings.
- 	static {
- 		Field[] fields = SQLReservedWords.class.getDeclaredFields();
- 		for (Field field : fields) {
- 			if (field.getType() == String.class) {
- 				try {
-					RESERVED_WORDS.add((String)field.get(null));
-				} catch (Exception e) {
-				}
- 			}
- 		}
- 	}
-
-    /** Can't construct */
-    private ProcedureReservedWords() {}
-
-    /**
-     * Check whether a string is a procedure reserved word.  
-     * @param str String to check
-     * @return True if procedure reserved word, false if not or null
-     */
-    public static final boolean isProcedureReservedWord(String str) {
-        if (str == null) { 
-            return false;    
-        }
-        return RESERVED_WORDS.contains(str.toUpperCase());    
-    }
-}



More information about the teiid-commits mailing list