[teiid-commits] teiid SVN: r1916 - in trunk/engine: src/main/java/com/metamatrix and 82 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Mar 5 09:27:11 EST 2010


Author: shawkins
Date: 2010-03-05 09:26:51 -0500 (Fri, 05 Mar 2010)
New Revision: 1916

Added:
   trunk/engine/src/main/java/com/metamatrix/api/
   trunk/engine/src/main/java/com/metamatrix/api/exception/
   trunk/engine/src/main/java/com/metamatrix/api/exception/security/
   trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java
   trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java
   trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java
   trunk/engine/src/main/java/com/metamatrix/common/queue/
   trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
   trunk/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java
   trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
   trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java
   trunk/engine/src/main/java/org/teiid/cache/
   trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java
   trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/
   trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
   trunk/engine/src/test/java/com/metamatrix/common/queue/
   trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java
   trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java
   trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
   trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java
   trunk/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
Removed:
   trunk/engine/src/main/java/com/metamatrix/api/exception/
   trunk/engine/src/main/java/com/metamatrix/api/exception/security/
   trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java
   trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java
   trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java
   trunk/engine/src/main/java/com/metamatrix/common/application/AbstractClassLoaderManager.java
   trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationEnvironment.java
   trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationService.java
   trunk/engine/src/main/java/com/metamatrix/common/application/ClassLoaderManager.java
   trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java
   trunk/engine/src/main/java/com/metamatrix/common/application/ServiceLoader.java
   trunk/engine/src/main/java/com/metamatrix/common/comm/
   trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java
   trunk/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
   trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/AuthenticationToken.java
   trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/FailedAuthenticationToken.java
   trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
   trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java
   trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java
   trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SuccessfulAuthenticationToken.java
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibraryManager.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/ReservedWords.java
   trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertValueExpressionsImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java
   trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/
   trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
   trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java
   trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java
   trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java
   trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
   trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAbstractService.java
   trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
   trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
   trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java
Modified:
   trunk/engine/
   trunk/engine/pom.xml
   trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/BufferService.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
   trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java
   trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
   trunk/engine/src/main/java/com/metamatrix/query/eval/SecurityFunctionEvaluator.java
   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/UDFSource.java
   trunk/engine/src/main/java/com/metamatrix/query/function/source/SecuritySystemFunctions.java
   trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
   trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadata.java
   trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadataWrapper.java
   trunk/engine/src/main/java/com/metamatrix/query/metadata/QueryMetadataInterface.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushLimit.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
   trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
   trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/relational/InsertPlanExecutionNode.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java
   trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Insert.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SPParameter.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Update.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/proc/RaiseErrorStatement.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AggregateSymbol.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/util/UpdateProcedureGenerator.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
   trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
   trunk/engine/src/main/java/com/metamatrix/query/validator/AggregateValidationVisitor.java
   trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
   trunk/engine/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
   trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
   trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
   trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
   trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
   trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
   trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
   trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
   trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAuthorizationService.java
   trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java
   trunk/engine/src/test/java/com/metamatrix/query/analysis/TestAnalysisRecord.java
   trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
   trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
   trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java
   trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCapabilitiesUtil.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestGroupRecontext.java
   trunk/engine/src/test/java/com/metamatrix/query/parser/TestCallableStatementParsing.java
   trunk/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java
   trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
   trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
   trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
   trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java
   trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java
   trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java
   trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java
   trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFacade.java
   trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
   trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
   trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
Log:
TEIID-833 committing JCA merge



Property changes on: trunk/engine
___________________________________________________________________
Name: svn:mergeinfo
   - 

Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/pom.xml	2010-03-05 14:26:51 UTC (rev 1916)
@@ -50,11 +50,13 @@
     <dependency>
       <groupId>org.jboss.teiid</groupId>
       <artifactId>teiid-connector-api</artifactId>
+      <scope>provided</scope>
     </dependency>
     
     <dependency>
       <groupId>org.jboss.teiid</groupId>
       <artifactId>teiid-client</artifactId>
+      <scope>provided</scope>
     </dependency>
 
     <dependency>
@@ -64,20 +66,25 @@
     </dependency>
     
     <dependency>
-      <groupId>javax.transaction</groupId>
-      <artifactId>jta</artifactId>
-    </dependency>
-    
-    <dependency>
       <groupId>javax.resource</groupId>
       <artifactId>connector-api</artifactId>
-    </dependency>
+      <scope>provided</scope>
+    </dependency>    
     
     <dependency>
-    	<groupId>com.google.code.guice</groupId>
-		<artifactId>guice</artifactId>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-vfs-spi</artifactId>
+        <scope>provided</scope>
+    </dependency> 
+    
+    <dependency>    
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-vfs</artifactId>
+        <scope>provided</scope>
     </dependency>    
     
   </dependencies>
   
+
+      
 </project>
\ No newline at end of file

Copied: trunk/engine/src/main/java/com/metamatrix/api (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api)

Copied: trunk/engine/src/main/java/com/metamatrix/api/exception (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception)

Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/security (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security)

Deleted: trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java	2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.api.exception.security;
-
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-
-public class AuthorizationException extends MetaMatrixSecurityException {
-    /**
-     * No-Arg Constructor
-     */
-    public AuthorizationException(  ) {
-        super( );
-    }
-    /**
-     * Constructs an instance of the exception with the specified detail message. A detail
-     * message is a String that describes this particular exception.
-     * @param the detail message
-     */
-    public AuthorizationException(String message) {
-    	super(message);
-    }
-    /**
-     * Constructs an instance of the exception with no detail message but with a
-     * single exception.
-     * @param e the exception that is encapsulated by this exception
-     */
-    public AuthorizationException(Throwable e) {
-        super(e);
-    }
-    /**
-     * Constructs an instance of the exception with the specified detail message
-     * and a single exception. A detail message is a String that describes this
-     * particular exception.
-     * @param message the detail message
-     * @param e the exception that is encapsulated by this exception
-     */
-    public AuthorizationException( Throwable e, String message ) {
-        super(e, message);
-    }
-    /**
-     * Construct an instance with an error code and message specified.
-     *
-     * @param message The error message
-     * @param code    The error code 
-     */
-    public AuthorizationException( String code, String message ) {
-        super( code, message );
-    }
-    /**
-     * Construct an instance with a linked exception, and an error code and
-     * message, specified.
-     *
-     * @param e       An exception to chain to this exception
-     * @param message The error message
-     * @param code    The error code 
-     */
-    public AuthorizationException( Throwable e, String code, String message ) {
-        super(e, code, message );
-    }
-}
-

Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java	                        (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationException.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,81 @@
+/*
+ * 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.api.exception.security;
+
+import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
+
+public class AuthorizationException extends MetaMatrixSecurityException {
+    /**
+     * No-Arg Constructor
+     */
+    public AuthorizationException(  ) {
+        super( );
+    }
+    /**
+     * Constructs an instance of the exception with the specified detail message. A detail
+     * message is a String that describes this particular exception.
+     * @param the detail message
+     */
+    public AuthorizationException(String message) {
+    	super(message);
+    }
+    /**
+     * Constructs an instance of the exception with no detail message but with a
+     * single exception.
+     * @param e the exception that is encapsulated by this exception
+     */
+    public AuthorizationException(Throwable e) {
+        super(e);
+    }
+    /**
+     * Constructs an instance of the exception with the specified detail message
+     * and a single exception. A detail message is a String that describes this
+     * particular exception.
+     * @param message the detail message
+     * @param e the exception that is encapsulated by this exception
+     */
+    public AuthorizationException( Throwable e, String message ) {
+        super(e, message);
+    }
+    /**
+     * Construct an instance with an error code and message specified.
+     *
+     * @param message The error message
+     * @param code    The error code 
+     */
+    public AuthorizationException( String code, String message ) {
+        super( code, message );
+    }
+    /**
+     * Construct an instance with a linked exception, and an error code and
+     * message, specified.
+     *
+     * @param e       An exception to chain to this exception
+     * @param message The error message
+     * @param code    The error code 
+     */
+    public AuthorizationException( Throwable e, String code, String message ) {
+        super(e, code, message );
+    }
+}
+

Deleted: trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java	2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,87 +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.api.exception.security;
-
-public class AuthorizationMgmtException extends AuthorizationException {
-
-    /**
-     * No-Arg Constructor
-     */
-    public AuthorizationMgmtException(  ) {
-        super( );
-    }
-    /**
-     * Constructs an instance of the exception with the specified detail
-     * message. A detail message is a String that describes this particular
-     * exception.
-     * @param the detail message
-     */
-    public AuthorizationMgmtException(String message) {
-        super(message);
-    }
-
-    /**
-     * Constructs an instance of the exception with no detail message but with a
-     * single exception.
-     * @param e the exception that is encapsulated by this exception
-     */
-    public AuthorizationMgmtException(Throwable e) {
-        super(e);
-    }
-
-    /**
-     * Constructs an instance of the exception with the specified detail message
-     * and a single exception. A detail message is a String that describes this
-     * particular exception.
-     * @param e the exception that is encapsulated by this exception
-     * @param message the detail message
-     */
-    public AuthorizationMgmtException(Throwable e, String message) {
-        super(e,message);
-    }
-
-    /**
-     * Construct an instance with an error code and message specified.
-     *
-     * @param message The error message
-     * @param code    The error code 
-     */
-    public AuthorizationMgmtException( String code, String message ) {
-        super( code, message );
-    }
-
-    /**
-     * Construct an instance with a linked exception, and an error code and
-     * message, specified.
-     *
-     * @param e       An exception to chain to this exception
-     * @param message The error message
-     * @param code    The error code 
-     */
-    public AuthorizationMgmtException( Throwable e, String code, String message ) {
-        super( e, code, message );
-    }
-
-}
-
-

Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java	                        (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/AuthorizationMgmtException.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,87 @@
+/*
+ * 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.api.exception.security;
+
+public class AuthorizationMgmtException extends AuthorizationException {
+
+    /**
+     * No-Arg Constructor
+     */
+    public AuthorizationMgmtException(  ) {
+        super( );
+    }
+    /**
+     * Constructs an instance of the exception with the specified detail
+     * message. A detail message is a String that describes this particular
+     * exception.
+     * @param the detail message
+     */
+    public AuthorizationMgmtException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs an instance of the exception with no detail message but with a
+     * single exception.
+     * @param e the exception that is encapsulated by this exception
+     */
+    public AuthorizationMgmtException(Throwable e) {
+        super(e);
+    }
+
+    /**
+     * Constructs an instance of the exception with the specified detail message
+     * and a single exception. A detail message is a String that describes this
+     * particular exception.
+     * @param e the exception that is encapsulated by this exception
+     * @param message the detail message
+     */
+    public AuthorizationMgmtException(Throwable e, String message) {
+        super(e,message);
+    }
+
+    /**
+     * Construct an instance with an error code and message specified.
+     *
+     * @param message The error message
+     * @param code    The error code 
+     */
+    public AuthorizationMgmtException( String code, String message ) {
+        super( code, message );
+    }
+
+    /**
+     * Construct an instance with a linked exception, and an error code and
+     * message, specified.
+     *
+     * @param e       An exception to chain to this exception
+     * @param message The error message
+     * @param code    The error code 
+     */
+    public AuthorizationMgmtException( Throwable e, String code, String message ) {
+        super( e, code, message );
+    }
+
+}
+
+

Deleted: trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java	2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,80 +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.api.exception.security;
-
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-
-public class SessionServiceException extends MetaMatrixSecurityException {
-    /**
-     * No-Arg Constructor
-     */
-    public SessionServiceException(  ) {
-        super( );
-    }
-    /**
-     * Constructs an instance of the exception with the specified detail message. A detail
-     * message is a String that describes this particular exception.
-     * @param the detail message
-     */
-    public SessionServiceException(String message) {
-    	super(message);
-    }
-    /**
-     * Constructs an instance of the exception with no detail message but with a
-     * single exception.
-     * @param e the exception that is encapsulated by this exception
-     */
-    public SessionServiceException(Throwable e) {
-        super(e);
-    }
-    /**
-     * Constructs an instance of the exception with the specified detail message
-     * and a single exception. A detail message is a String that describes this
-     * particular exception.
-     * @param message the detail message
-     * @param e the exception that is encapsulated by this exception
-     */
-    public SessionServiceException( Throwable e, String message ) {
-        super(e, message);
-    }
-    /**
-     * Construct an instance with an error code and message specified.
-     *
-     * @param message The error message
-     * @param code    The error code 
-     */
-    public SessionServiceException( String code, String message ) {
-        super( code, message );
-    }
-    /**
-     * Construct an instance with a linked exception, and an error code and
-     * message, specified.
-     *
-     * @param e       An exception to chain to this exception
-     * @param message The error message
-     * @param code    The error code 
-     */
-    public SessionServiceException( Throwable e, String code, String message ) {
-        super( e, code, message );
-    }
-}

Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java	                        (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/security/SessionServiceException.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,80 @@
+/*
+ * 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.api.exception.security;
+
+import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
+
+public class SessionServiceException extends MetaMatrixSecurityException {
+    /**
+     * No-Arg Constructor
+     */
+    public SessionServiceException(  ) {
+        super( );
+    }
+    /**
+     * Constructs an instance of the exception with the specified detail message. A detail
+     * message is a String that describes this particular exception.
+     * @param the detail message
+     */
+    public SessionServiceException(String message) {
+    	super(message);
+    }
+    /**
+     * Constructs an instance of the exception with no detail message but with a
+     * single exception.
+     * @param e the exception that is encapsulated by this exception
+     */
+    public SessionServiceException(Throwable e) {
+        super(e);
+    }
+    /**
+     * Constructs an instance of the exception with the specified detail message
+     * and a single exception. A detail message is a String that describes this
+     * particular exception.
+     * @param message the detail message
+     * @param e the exception that is encapsulated by this exception
+     */
+    public SessionServiceException( Throwable e, String message ) {
+        super(e, message);
+    }
+    /**
+     * Construct an instance with an error code and message specified.
+     *
+     * @param message The error message
+     * @param code    The error code 
+     */
+    public SessionServiceException( String code, String message ) {
+        super( code, message );
+    }
+    /**
+     * Construct an instance with a linked exception, and an error code and
+     * message, specified.
+     *
+     * @param e       An exception to chain to this exception
+     * @param message The error message
+     * @param code    The error code 
+     */
+    public SessionServiceException( Throwable e, String code, String message ) {
+        super( e, code, message );
+    }
+}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/AbstractClassLoaderManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/AbstractClassLoaderManager.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/AbstractClassLoaderManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,118 +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.application;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import com.metamatrix.common.classloader.PostDelegatingClassLoader;
-import com.metamatrix.common.classloader.URLFilteringClassLoader;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
-import com.metamatrix.dqp.util.LogConstants;
-
-public abstract class AbstractClassLoaderManager implements ClassLoaderManager {
-	
-	private ClassLoader parentClassLoader;
-    private URLFilteringClassLoader commonExtensionClassloader;
-    private Map<String, PostDelegatingClassLoader> postdelegationClassLoaderCache = new HashMap<String, PostDelegatingClassLoader>();
-    private boolean usePostDelegationCache;
-    private MetaMatrixURLStreamHandlerFactory factory;
-    private Object lock = new Object();
-    
-    public AbstractClassLoaderManager(ClassLoader parentClassLoader, boolean usePostDelegationCache, boolean useStreamHandler) {
-    	this.usePostDelegationCache = usePostDelegationCache;
-    	this.parentClassLoader = parentClassLoader;
-    	if (useStreamHandler) {
-    		factory = new MetaMatrixURLStreamHandlerFactory();
-    	}
-    }
-    
-	public ClassLoader getCommonClassLoader(String urls) {
-		synchronized (lock) {
-			if (this.commonExtensionClassloader == null) {
-	            // since we are using the extensions, get the common extension path 
-				this.commonExtensionClassloader = new URLFilteringClassLoader(parseURLs(getCommonExtensionClassPath()), parentClassLoader, factory);
-			}
-			if (urls != null && urls.trim().length() > 0) {
-	            for (URL url : parseURLs(urls)) {
-	            	this.commonExtensionClassloader.addURL(url);
-				}
-			}
-			return this.commonExtensionClassloader;
-		}
-	}
-	
-	public ClassLoader getPostDelegationClassLoader(String urls) {
-		synchronized (lock) {
-			PostDelegatingClassLoader cl = this.postdelegationClassLoaderCache.get(urls);
-	    	if (cl == null) {
-	    		if (urls != null && urls.trim().length() > 0) {
-		            cl = new PostDelegatingClassLoader(parseURLs(urls), getCommonClassLoader(null), factory);
-		            if (usePostDelegationCache) {
-		            	this.postdelegationClassLoaderCache.put(urls, cl);
-		            }
-	    		}
-	    		if (cl == null) {
-	    			return getCommonClassLoader(null);
-	    		}
-	    	}
-	    	return cl;
-		}
-	}
-
-	public void clearCache() {
-		synchronized (lock) {
-			this.commonExtensionClassloader = null;
-			this.postdelegationClassLoaderCache.clear();
-		}
-	}
-		
-	public URL[] parseURLs(String delimitedUrls) {
-		StringTokenizer toke = new StringTokenizer(delimitedUrls, ";"); //$NON-NLS-1$
-        List<URL> urls = new ArrayList<URL>(toke.countTokens());
-        while (toke.hasMoreElements()) {
-            String urlString = toke.nextToken();
-	        try {
-				URL url = parseURL(urlString);
-				if (url != null) {
-					urls.add(url);
-				}
-			} catch (MalformedURLException e) {
-				LogManager.logError(LogConstants.CTX_EXTENSION_SOURCE, "Invalid extension classpath entry " + urlString); //$NON-NLS-1$
-			}
-        }
-                
-        return urls.toArray(new URL[urls.size()]);	
-	}
-	
-	public abstract URL parseURL(String url) throws MalformedURLException;
-	
-	public abstract String getCommonExtensionClassPath();
-		
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationEnvironment.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationEnvironment.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,93 +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.application;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-
-/**
- * The environment is available internally to the application as a means 
- * of finding application services of a particular type or to retrieve
- * other information about the application itself.  
- */
-public class ApplicationEnvironment {
-
-    private LinkedHashMap<String, ApplicationService> services = new LinkedHashMap<String, ApplicationService>();
-    
-    private CacheFactory cache;
-    
-    public ApplicationEnvironment() {
-    	
-    }
-
-    /* 
-     * @see com.metamatrix.common.application.ApplicationEnvironment#bindService(java.lang.String, com.metamatrix.common.application.ApplicationService)
-     */
-    public void bindService(String type, ApplicationService service) {
-        this.services.put(type, service);
-    }
-
-    public ApplicationService findService(String type) {
-        return this.services.get(type);
-    }
-    
-    public CacheFactory getCacheFactory() {
-		return cache;
-	}
-    
-    public void setCacheFactory(CacheFactory cache) {
-		this.cache = cache;
-	}
-    
-    /* 
-     * @see com.metamatrix.common.application.Application#installService(com.metamatrix.common.application.ApplicationService)
-     */
-    public final void installService(String type, ApplicationService service) throws ApplicationInitializationException {
-        if(service == null) {
-            return;
-        }
-        
-        try {
-            service.start(this);
-            this.bindService(type, service);
-        } catch(ApplicationLifecycleException e) {
-            throw new ApplicationInitializationException(e, CommonPlugin.Util.getString("BasicApplication.Failed_while_installing_service_of_type__1") + type); //$NON-NLS-1$
-        }
-    }
-
-    /**
-     * @see com.metamatrix.common.application.Application#stop()
-     */
-    public void stop() throws ApplicationLifecycleException {
-        for (Map.Entry<String, ApplicationService> entry : services.entrySet()) {
-            entry.getValue().stop();
-		}
-        services.clear();
-    }
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/ApplicationService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,63 +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.application;
-
-import java.util.Properties;
-
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-
-/**
- * This defines the basic interface for an application service.  The lifecycle 
- * of a service is generally as follows:
- * <ul>
- * <li>Initialize - configure the service</li>
- * <li>Start - performed by application prior to start the service running in an environment</li>
- * <li>Stop - performed by application after the service is unbound from the environment</li>
- * </ul>
- */
-public interface ApplicationService {
-
-    /**
-     * Initialize the service with the specified properties.
-     * @param props Initialialization properties
-     * @throws ApplicationInitializationException If an error occurs during initialization
-     */
-    public void initialize(Properties props) throws ApplicationInitializationException;
-
-    /**
-     * Start the service with the specified environment.  The environment can
-     * be used to find other services or resources.
-     * @param environment Environment 
-     * @throws ApplicationLifecycleException If an error occurs while starting
-     */    
-    public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException;
-    
-    /**
-     * Stop the service.
-     * @throws ApplicationLifecycleException If an error occurs while starting
-     */    
-    public void stop() throws ApplicationLifecycleException;
-    
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/ClassLoaderManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/ClassLoaderManager.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/ClassLoaderManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.application;
-
-public interface ClassLoaderManager {
-	
-	/**
-	 * Return the common class loader with the given urls appended
-	 * @param urls
-	 * @return
-	 */
-	ClassLoader getCommonClassLoader(String urls);
-	
-	/**
-	 * Return a distinct post delgation class loader - which may be cached.
-	 * @param urls
-	 * @return
-	 */
-	ClassLoader getPostDelegationClassLoader(String urls);
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,35 +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.application;
-
-import java.util.Properties;
-
-/**
- * This interface represents a source of DQP configuration information.
- */
-public interface DQPConfigSource {
-
-    public Properties getProperties();
-    
-    public ApplicationService getServiceInstance(Class<? extends ApplicationService> type);
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/common/application/ServiceLoader.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/ServiceLoader.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/ServiceLoader.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,35 +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.application;
-
-/**
- * Used as an entry mechanism for the Designer to extend service classes
- * without depending upon embedded.
- */
-public class ServiceLoader {
-
-	public ApplicationService loadService(String serviceType, ApplicationService service) {
-		return service;
-	}
-	
-}

Copied: trunk/engine/src/main/java/com/metamatrix/common/queue (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/common/queue)

Deleted: trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java	2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,288 +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.queue;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.resource.spi.work.ExecutionContext;
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkEvent;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkListener;
-import javax.resource.spi.work.WorkManager;
-import javax.resource.spi.work.WorkRejectedException;
-
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.NamedThreadFactory;
-
-/**
- * StatsCapturingWorkManager acts as a wrapper to the passed in {@link WorkManager} to 
- * capture statistics and implement an unbounded queue of work.
- */
-public class StatsCapturingWorkManager {
-		
-	private static class WorkContext {
-		ExecutionContext context;
-		long startTimeout;
-		long submitted = System.currentTimeMillis();
-		
-		public WorkContext(ExecutionContext context, long startTimeout) {
-			this.context = context;
-			this.startTimeout = startTimeout;
-		}
-		
-		long getStartTimeout() {
-			if (startTimeout == 0) {
-				return 0;
-			}
-			return Math.max(1, startTimeout + submitted - System.currentTimeMillis());
-		}
-		
-	}
-	
-	private final class WorkWrapper implements Work {
-		private final WorkManager delegate;
-		private final Work work;
-		private final WorkContext workContext;
-
-		private WorkWrapper(WorkManager delegate, Work work, WorkContext workContext) {
-			this.delegate = delegate;
-			this.work = work;
-			this.workContext = workContext;
-		}
-
-		@Override
-		public void run() {
-			Thread t = Thread.currentThread();
-			synchronized (poolLock) {
-				threads.add(t);
-			}
-			String name = t.getName();
-			t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
-			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.TRACE)) {
-				LogManager.logTrace(LogConstants.CTX_POOLING, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$ 
-			}
-			boolean success = false;
-			try {
-				work.run();
-				success = true;
-			} finally {
-				synchronized (poolLock) {
-					WorkWrapper next = null;
-					if (success) {
-						completedCount++;
-						next = queue.poll();		
-					}
-					threads.remove(t);
-					if (next == null) {
-						activeCount--;
-						if (activeCount == 0 && terminated) {
-							poolLock.notifyAll();
-						}		
-					} else {
-						try {
-							if (next.workContext == null) {
-								delegate.scheduleWork(next);
-							} else {
-								delegate.scheduleWork(next, next.workContext.getStartTimeout(), next.workContext.context, next.work instanceof WorkListener?(WorkListener)next.work:null);
-							}
-						} catch (WorkException e) {
-							handleException(next.work, e);
-						}
-					}
-				}
-				t.setName(name);
-			}
-		}
-
-		@Override
-		public void release() {
-			this.work.release();
-		}
-	}
-	
-	private static void handleException(Work work, WorkException e) {
-		if (work instanceof WorkListener) {
-			((WorkListener)work).workRejected(new WorkEvent(work, WorkEvent.WORK_REJECTED, work, new WorkRejectedException(e)));
-		} else if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.DETAIL)) {
-			LogManager.logDetail(LogConstants.CTX_POOLING, e, "Exception adding work to the WorkManager"); //$NON-NLS-1$ 
-		}
-	}
-		
-	private static ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Scheduler")); //$NON-NLS-1$
-
-	private volatile int activeCount;
-	private volatile int highestActiveCount;
-	private volatile int highestQueueSize;
-	private volatile boolean terminated;
-	private volatile int submittedCount;
-	private volatile int completedCount;
-	private Object poolLock = new Object();
-	private AtomicInteger threadCounter = new AtomicInteger();
-	private String poolName;
-	private int maximumPoolSize;
-	private Queue<WorkWrapper> queue = new LinkedList<WorkWrapper>();
-	private Set<Thread> threads = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<Thread, Boolean>()));
-	private Map<Integer, ScheduledFuture<?>> futures = new HashMap<Integer, ScheduledFuture<?>>();
-	private int idCounter;
-	
-	public StatsCapturingWorkManager(String name, int maximumPoolSize) {
-		this.maximumPoolSize = maximumPoolSize;
-		this.poolName = name;
-	}
-	
-	public void scheduleWork(final WorkManager delegate, final Work arg0) throws WorkException {
-		scheduleWork(delegate, arg0, (WorkContext)null);
-	}
-
-	private void scheduleWork(final WorkManager delegate, final Work work, WorkContext workContext) 
-	throws WorkRejectedException, WorkException {
-		boolean atMaxThreads = false;
-		boolean newMaxQueueSize = false;
-		synchronized (poolLock) {
-			checkForTermination();
-			submittedCount++;
-			atMaxThreads = activeCount == maximumPoolSize;
-			if (atMaxThreads) {
-				queue.add(new WorkWrapper(delegate, work, workContext));
-				int queueSize = queue.size();
-				if (queueSize > highestQueueSize) {
-					newMaxQueueSize = true;
-					highestQueueSize = queueSize;
-				}
-			} else {
-				activeCount++;
-				highestActiveCount = Math.max(activeCount, highestActiveCount);
-			}
-		}
-		if (atMaxThreads) {
-			if (newMaxQueueSize && maximumPoolSize > 1) {
-				LogManager.logWarning(LogConstants.CTX_POOLING, CommonPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
-			}
-			return;
-		}
-		if (workContext == null) {
-			delegate.scheduleWork(new WorkWrapper(delegate, work, null));
-		} else {
-			delegate.scheduleWork(new WorkWrapper(delegate, work, null), workContext.getStartTimeout(), workContext.context, work instanceof WorkListener?(WorkListener)work:null);
-		}
-	}
-
-	public void scheduleWork(final WorkManager delegate, final Work arg0, final ExecutionContext arg2, long delay) throws WorkException {
-		if (delay < 1) {
-			scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
-		} else {
-			synchronized (futures) {
-				final int id = idCounter++;
-				ScheduledFuture<?> sf = stpe.schedule(new Runnable() {
-					
-					@Override
-					public void run() {
-						try {
-							futures.remove(id);
-							scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
-						} catch (WorkException e) {
-							handleException(arg0, e);
-						}
-					}
-				}, delay, TimeUnit.MILLISECONDS);
-				this.futures.put(id, sf);
-			}			
-		}
-	}
-	
-	private void checkForTermination() throws WorkRejectedException {
-		if (terminated) {
-			throw new WorkRejectedException("Queue has been terminated"); //$NON-NLS-1$
-		}
-	}
-		
-	public WorkerPoolStatisticsMetadata getStats() {
-		WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
-		stats.setName(poolName);
-		stats.setQueued(queue.size());
-		stats.setHighestQueued(highestQueueSize);
-		stats.setActiveThreads(this.activeCount);
-		stats.setMaxThreads(this.maximumPoolSize);
-		stats.setTotalSubmitted(this.submittedCount);
-		stats.setHighestActiveThreads(this.highestActiveCount);
-		stats.setTotalCompleted(this.completedCount);
-		return stats;		
-	}
-	
-	public void shutdown() {
-		this.terminated = true;
-	}
-	
-	public void shutdownNow() {
-		this.shutdown();
-		synchronized (poolLock) {
-			for (Thread t : threads) {
-				t.interrupt();
-			}
-			queue.clear();
-		}
-		synchronized (futures) {
-			for (ScheduledFuture<?> future : futures.values()) {
-				future.cancel(true);
-			}
-			futures.clear();
-		}
-	}
-	
-	public boolean isTerminated() {
-		return terminated;
-	}
-	
-	public boolean awaitTermination(long timeout, TimeUnit unit)
-			throws InterruptedException {
-		long timeoutMillis = unit.toMillis(timeout);
-		long finalMillis = System.currentTimeMillis() + timeoutMillis;
-		synchronized (poolLock) {
-			while (this.activeCount > 0 || !terminated) {
-				if (timeoutMillis < 1) {
-					return false;
-				}
-				poolLock.wait(timeoutMillis);
-				timeoutMillis = finalMillis - System.currentTimeMillis();
-			}
-		}
-		return true;
-	}
-
-}

Copied: trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java	                        (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,288 @@
+/*
+ * 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.queue;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+
+import com.metamatrix.common.CommonPlugin;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.LogConstants;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.NamedThreadFactory;
+
+/**
+ * StatsCapturingWorkManager acts as a wrapper to the passed in {@link WorkManager} to 
+ * capture statistics and implement an unbounded queue of work.
+ */
+public class StatsCapturingWorkManager {
+		
+	private static class WorkContext {
+		ExecutionContext context;
+		long startTimeout;
+		long submitted = System.currentTimeMillis();
+		
+		public WorkContext(ExecutionContext context, long startTimeout) {
+			this.context = context;
+			this.startTimeout = startTimeout;
+		}
+		
+		long getStartTimeout() {
+			if (startTimeout == 0) {
+				return 0;
+			}
+			return Math.max(1, startTimeout + submitted - System.currentTimeMillis());
+		}
+		
+	}
+	
+	private final class WorkWrapper implements Work {
+		private final WorkManager delegate;
+		private final Work work;
+		private final WorkContext workContext;
+
+		private WorkWrapper(WorkManager delegate, Work work, WorkContext workContext) {
+			this.delegate = delegate;
+			this.work = work;
+			this.workContext = workContext;
+		}
+
+		@Override
+		public void run() {
+			Thread t = Thread.currentThread();
+			synchronized (poolLock) {
+				threads.add(t);
+			}
+			String name = t.getName();
+			t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
+			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.TRACE)) {
+				LogManager.logTrace(LogConstants.CTX_POOLING, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$ 
+			}
+			boolean success = false;
+			try {
+				work.run();
+				success = true;
+			} finally {
+				synchronized (poolLock) {
+					WorkWrapper next = null;
+					if (success) {
+						completedCount++;
+						next = queue.poll();		
+					}
+					threads.remove(t);
+					if (next == null) {
+						activeCount--;
+						if (activeCount == 0 && terminated) {
+							poolLock.notifyAll();
+						}		
+					} else {
+						try {
+							if (next.workContext == null) {
+								delegate.scheduleWork(next);
+							} else {
+								delegate.scheduleWork(next, next.workContext.getStartTimeout(), next.workContext.context, next.work instanceof WorkListener?(WorkListener)next.work:null);
+							}
+						} catch (WorkException e) {
+							handleException(next.work, e);
+						}
+					}
+				}
+				t.setName(name);
+			}
+		}
+
+		@Override
+		public void release() {
+			this.work.release();
+		}
+	}
+	
+	private static void handleException(Work work, WorkException e) {
+		if (work instanceof WorkListener) {
+			((WorkListener)work).workRejected(new WorkEvent(work, WorkEvent.WORK_REJECTED, work, new WorkRejectedException(e)));
+		} else if (LogManager.isMessageToBeRecorded(LogConstants.CTX_POOLING, MessageLevel.DETAIL)) {
+			LogManager.logDetail(LogConstants.CTX_POOLING, e, "Exception adding work to the WorkManager"); //$NON-NLS-1$ 
+		}
+	}
+		
+	private static ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Scheduler")); //$NON-NLS-1$
+
+	private volatile int activeCount;
+	private volatile int highestActiveCount;
+	private volatile int highestQueueSize;
+	private volatile boolean terminated;
+	private volatile int submittedCount;
+	private volatile int completedCount;
+	private Object poolLock = new Object();
+	private AtomicInteger threadCounter = new AtomicInteger();
+	private String poolName;
+	private int maximumPoolSize;
+	private Queue<WorkWrapper> queue = new LinkedList<WorkWrapper>();
+	private Set<Thread> threads = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<Thread, Boolean>()));
+	private Map<Integer, ScheduledFuture<?>> futures = new HashMap<Integer, ScheduledFuture<?>>();
+	private int idCounter;
+	
+	public StatsCapturingWorkManager(String name, int maximumPoolSize) {
+		this.maximumPoolSize = maximumPoolSize;
+		this.poolName = name;
+	}
+	
+	public void scheduleWork(final WorkManager delegate, final Work arg0) throws WorkException {
+		scheduleWork(delegate, arg0, (WorkContext)null);
+	}
+
+	private void scheduleWork(final WorkManager delegate, final Work work, WorkContext workContext) 
+	throws WorkRejectedException, WorkException {
+		boolean atMaxThreads = false;
+		boolean newMaxQueueSize = false;
+		synchronized (poolLock) {
+			checkForTermination();
+			submittedCount++;
+			atMaxThreads = activeCount == maximumPoolSize;
+			if (atMaxThreads) {
+				queue.add(new WorkWrapper(delegate, work, workContext));
+				int queueSize = queue.size();
+				if (queueSize > highestQueueSize) {
+					newMaxQueueSize = true;
+					highestQueueSize = queueSize;
+				}
+			} else {
+				activeCount++;
+				highestActiveCount = Math.max(activeCount, highestActiveCount);
+			}
+		}
+		if (atMaxThreads) {
+			if (newMaxQueueSize && maximumPoolSize > 1) {
+				LogManager.logWarning(LogConstants.CTX_POOLING, CommonPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
+			}
+			return;
+		}
+		if (workContext == null) {
+			delegate.scheduleWork(new WorkWrapper(delegate, work, null));
+		} else {
+			delegate.scheduleWork(new WorkWrapper(delegate, work, null), workContext.getStartTimeout(), workContext.context, work instanceof WorkListener?(WorkListener)work:null);
+		}
+	}
+
+	public void scheduleWork(final WorkManager delegate, final Work arg0, final ExecutionContext arg2, long delay) throws WorkException {
+		if (delay < 1) {
+			scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
+		} else {
+			synchronized (futures) {
+				final int id = idCounter++;
+				ScheduledFuture<?> sf = stpe.schedule(new Runnable() {
+					
+					@Override
+					public void run() {
+						try {
+							futures.remove(id);
+							scheduleWork(delegate, arg0, new WorkContext(arg2, WorkManager.INDEFINITE));
+						} catch (WorkException e) {
+							handleException(arg0, e);
+						}
+					}
+				}, delay, TimeUnit.MILLISECONDS);
+				this.futures.put(id, sf);
+			}			
+		}
+	}
+	
+	private void checkForTermination() throws WorkRejectedException {
+		if (terminated) {
+			throw new WorkRejectedException("Queue has been terminated"); //$NON-NLS-1$
+		}
+	}
+		
+	public WorkerPoolStatisticsMetadata getStats() {
+		WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
+		stats.setName(poolName);
+		stats.setQueued(queue.size());
+		stats.setHighestQueued(highestQueueSize);
+		stats.setActiveThreads(this.activeCount);
+		stats.setMaxThreads(this.maximumPoolSize);
+		stats.setTotalSubmitted(this.submittedCount);
+		stats.setHighestActiveThreads(this.highestActiveCount);
+		stats.setTotalCompleted(this.completedCount);
+		return stats;		
+	}
+	
+	public void shutdown() {
+		this.terminated = true;
+	}
+	
+	public void shutdownNow() {
+		this.shutdown();
+		synchronized (poolLock) {
+			for (Thread t : threads) {
+				t.interrupt();
+			}
+			queue.clear();
+		}
+		synchronized (futures) {
+			for (ScheduledFuture<?> future : futures.values()) {
+				future.cancel(true);
+			}
+			futures.clear();
+		}
+	}
+	
+	public boolean isTerminated() {
+		return terminated;
+	}
+	
+	public boolean awaitTermination(long timeout, TimeUnit unit)
+			throws InterruptedException {
+		long timeoutMillis = unit.toMillis(timeout);
+		long finalMillis = System.currentTimeMillis() + timeoutMillis;
+		synchronized (poolLock) {
+			while (this.activeCount > 0 || !terminated) {
+				if (timeoutMillis < 1) {
+					return false;
+				}
+				poolLock.wait(timeoutMillis);
+				timeoutMillis = finalMillis - System.currentTimeMillis();
+			}
+		}
+		return true;
+	}
+
+}

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,14 +25,12 @@
 package com.metamatrix.dqp.message;
 
 import java.io.Serializable;
-import java.util.Date;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.teiid.connector.xa.api.TransactionContext;
 import org.teiid.dqp.internal.process.DQPWorkContext;
 
 import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.query.sql.lang.Command;
 
 /**
@@ -54,19 +52,13 @@
 	 * The connectorBindingID that identifies the connector needed for this
 	 * query.
 	 */
-	private String connectorBindingID;
+	private String connectorName;
 
 	/**
 	 * Name of model where the connector is bound to
 	 */
 	private String modelName;
 
-	/**
-	 * For cancel and update operations, the id of the data connector which
-	 * originally handled the request.
-	 */
-	private ConnectorID connectorID;
-
 	// Transaction context for the current request
 	private TransactionContext txnContext;
 
@@ -76,11 +68,8 @@
 	// results fetch size
 	private int fetchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
 
-	// The time when the command was created by the client
-	private Date submittedTimestamp;
-
 	// The time when command begins processing on the server.
-	private Date processingTimestamp;
+	private long processingTimestamp = System.currentTimeMillis();
 
 	// whether to use ResultSet cache if there is one
 	private boolean useResultSetCache;
@@ -107,22 +96,14 @@
         return this.atomicRequestId;
     }
           
-    public String getConnectorBindingID() {
-        return connectorBindingID;
+    public String getConnectorName() {
+        return connectorName;
     }
 
-    public ConnectorID getConnectorID() {
-        return connectorID;
+    public void setConnectorName(String string) {
+        connectorName = string;
     }
-    
-    public void setConnectorID(ConnectorID connectorID) {
-        this.connectorID = connectorID;
-    }    
 
-    public void setConnectorBindingID(String string) {
-        connectorBindingID = string;
-    }
-
     public String getModelName() {
         return this.modelName;
     }
@@ -140,7 +121,7 @@
     }
 
     public boolean isTransactional(){
-        return this.txnContext != null && this.txnContext.isInTransaction();
+        return this.txnContext != null && this.txnContext.getXid() != null;
     }    
 	
 	public Command getCommand() {
@@ -163,54 +144,13 @@
 	}   
 
     /**
-     * Get time that the time when the command was created by the client.
-     * @return timestamp in millis
-     */
-    public Date getSubmittedTimestamp() {
-        return submittedTimestamp;
-    }
-    
-    /**
-     * Set time that the time when the command was created by the client.
-     * NOTE: By default, this gets set to the current time by the constructor.
-     * @param submittedTimestamp Time submitted to server.
-     */
-    public void setSubmittedTimestamp(Date submittedTimestamp) {
-        this.submittedTimestamp = submittedTimestamp;
-    }    
-    
-    /**
-     * Start the clock on submission start - this should be called when the request is originally created.
-     */
-    public void markSubmissionStart() {
-        setSubmittedTimestamp(new Date());
-    }
-    
-    
-    /**
      * Get time that the request was assigned a unique ID by the server.
      * @return timestamp in millis
      */
-    public Date getProcessingTimestamp() {
+    public long getProcessingTimestamp() {
         return processingTimestamp;
     }
 
-    /**
-     * Set time that the request is submitted on the server.
-     * @param processingTimestamp Time submitted to server.
-     */
-    public void setProcessingTimestamp(Date processingTimestamp) {
-        this.processingTimestamp = processingTimestamp;
-    }
-
-    /**
-     * Start the clock on processing times - this should be called when the query
-     * hits the QueryService or SubscriptionService.
-     */
-    public void markProcessingStart() {
-        setProcessingTimestamp(new Date());
-    }	
-	
 	public boolean useResultSetCache() {
 		//not use caching when there is a txn 
 		return useResultSetCache 

Copied: trunk/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java	                        (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,175 @@
+/*
+ * 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.message;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * <p>This class represents an identifier for a request.  However, there are some
+ * differences in what constitutes "uniqueness" for a given RequestID that 
+ * is based on context (where the id is used).  The RequestID has 2 parts:
+ * connectionID, and executionIDFor the purposes of the RequestID, the combined 
+ * representation is "connectionID.executionID" - this implies a scoping
+ * for the name parts.  The connectionID specifies a particular connection that 
+ * is making requests.  Each connection generates a unique executionID for each 
+ * request execution, so the executionID is only unique in the context of a 
+ * connectionID.  </p>
+ * 
+ * <p>When this class is used between client and server, the connectionID is implied
+ * and thus only the executionID part will be used.  The server will qualify the 
+ * executionID with a connectionID when it reaches the server.  </p>
+ * 
+ * <p>RequestIDs are immutable so no setters exist.  This allows hashcodes to be 
+ * pre-computed for faster comparison in equals.</p>  
+ */
+public class RequestID implements Externalizable {
+
+    static final long serialVersionUID = -2888539138291776071L;
+    
+    public static final String NO_CONNECTION_STR = "C"; //$NON-NLS-1$
+    private static final String SEPARATOR = "."; //$NON-NLS-1$
+
+    // Basic state
+    private String connectionID;
+    private long executionID;
+    
+    // Derived state
+    private String combinedID;
+    private int hash;
+
+    /**
+     * Necessary for implementing Externalizable 
+     */
+    public RequestID() {        
+    }
+    
+    /**
+     * Create a RequestID using all of the ID parts.
+     * @param connectionID Identifies a connection, may be null
+     * @param executionID Identifies an execution, cannot be null
+     */
+    public RequestID(String connectionID, long executionID) {
+        this.connectionID = connectionID;
+        this.executionID = executionID;
+        
+        createCombinedID();
+        computeHashCode();
+    }
+    
+    public RequestID(long connectionID, long executionID) {
+        this.connectionID = String.valueOf(connectionID);
+        this.executionID = executionID;
+        
+        createCombinedID();
+        computeHashCode();
+    }    
+    
+    /**
+     * Create a RequestID for an execution where the connection is 
+     * not specified.
+     * @param executionID Identifies an execution, cannot be null
+     */
+    public RequestID(long executionID) {
+        this(null, executionID);
+    }
+
+    
+    /**
+     * Return connectionID, may be null if connection has not been specified.
+     * @return Connection ID, may be null
+     */
+    public String getConnectionID() {
+        return this.connectionID;
+    }
+    
+    /**
+     * Return executionID, which identifies a per-connection execution.
+     * @return Execution ID
+     */
+    public long getExecutionID() {
+        return this.executionID;
+    }
+
+    /**
+     * Create a unique combined ID string from the RequestID parts. 
+     */
+    private void createCombinedID() {
+        StringBuffer combinedStr = new StringBuffer();
+        if(this.connectionID != null) {
+            combinedStr.append(this.connectionID);
+        } else {
+            combinedStr.append(NO_CONNECTION_STR);
+        }
+        combinedStr.append(SEPARATOR);               
+        combinedStr.append(this.executionID);
+                
+        this.combinedID = combinedStr.toString();
+    }
+    
+    private void computeHashCode() {
+        this.hash = combinedID.hashCode();
+    }
+    
+    public int hashCode() {
+        return this.hash;
+    }
+    
+    public boolean equals(Object obj) {
+        if(obj == this) {
+            return true;
+        } else if(obj == null || !(obj instanceof RequestID) || obj.hashCode() != this.hashCode()) {
+            return false;
+        } else {
+            return this.toString().equals(obj.toString());
+        }
+    }
+    
+    /**
+     * Return a combined string for the ID.
+     */
+    public String toString() {
+        return this.combinedID;
+    }
+
+    /**
+     * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+     */
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        connectionID = (String)in.readObject();
+        executionID = in.readLong();
+
+        createCombinedID();
+        computeHashCode();
+    }
+
+    /**
+     * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+     */
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(connectionID);
+        out.writeLong(executionID);
+    }
+}

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,24 +24,18 @@
 
 import java.util.Collection;
 
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-import com.metamatrix.api.exception.ComponentNotFoundException;
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.security.AuthorizationException;
 import com.metamatrix.api.exception.security.AuthorizationMgmtException;
-import com.metamatrix.common.application.ApplicationService;
 import com.metamatrix.platform.security.api.AuthorizationPolicy;
 import com.metamatrix.platform.security.api.AuthorizationRealm;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.eval.SecurityFunctionEvaluator;
 
 /**
  * This service provides a means to check whether a connection is authorized to access
  * various data resources.
  */
-public interface AuthorizationService extends ApplicationService, SecurityFunctionEvaluator {
+public interface AuthorizationService extends SecurityFunctionEvaluator {
 
     public static final int ACTION_READ = 0;
     public static final int ACTION_CREATE = 1;
@@ -60,14 +54,13 @@
     /**
      * Determine which of a set of resources a connection does not have permission to
      * perform the specified action.
-     * @param connectionID Connection ID identifying the connection (and thus the user credentials)
      * @param action Action connection wishes to perform
      * @param resources Resources the connection wishes to perform the action on, Collection of String
      * @param context Auditing context
      * @return Collection Subset of resources
      * @throws MetaMatrixComponentException If an error occurs in the service while checking resources
      */
-    Collection getInaccessibleResources(String connectionID, int action, Collection resources, int context) throws MetaMatrixComponentException;
+    Collection getInaccessibleResources(int action, Collection resources, int context) throws MetaMatrixComponentException;
 
     /**
      * Determine whether entitlements checking is enabled on the server.
@@ -75,24 +68,9 @@
      */
     boolean checkingEntitlements();
     
-    boolean isCallerInRole(SessionToken session, String roleName ) throws AuthorizationMgmtException;
+    boolean isCallerInRole(String roleName ) throws AuthorizationMgmtException;
     
-    
     /**
-     * Returns a Collection of String names of MetaMatrix roles to which the
-     * given principal is assigned.
-     * @param caller the session token of the principal that is attempting to access the roles.
-     * @param principal <code>MetaMatrixPrincipalName</code> for which roles are sought
-     * @return The <code>Collection</code> of role names the principal is assigned.
-     * @throws InvalidSessionException if the administrative session is invalid
-     * @throws MetaMatrixSecurityException if there is a problem internally with the MembershipService
-     * @throws AuthorizationException if administrator does not have the authority to see the requested information
-     * @throws ComponentNotFoundException if a component required by this method could not be found within the server
-     */
-    Collection<String> getRoleNamesForPrincipal(MetaMatrixPrincipalName principal)
-    throws InvalidSessionException, AuthorizationException, AuthorizationMgmtException;
-    
-    /**
      * Returns a <code>Collection</code> of <code>AuthorizationPolicy</code>s
      * that have <code>AuthorizationPermission</code>s in the given <code>AuthorizationRealm</code>.<br>
      * <strong>NOTE:</strong> It is the responsibility of the caller to determine

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/BufferService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/BufferService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/BufferService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,15 +24,17 @@
 
 import org.teiid.dqp.internal.cache.DQPContextCache;
 
-import com.metamatrix.common.application.ApplicationService;
+import com.metamatrix.cache.CacheFactory;
 import com.metamatrix.common.buffer.BufferManager;
 
 /**
  */
-public interface BufferService extends ApplicationService {
+public interface BufferService {
 
     BufferManager getBufferManager();
 
     DQPContextCache getContextCache();
+    
+    CacheFactory getCacheFactory();
  }
 

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/CommandLogMessage.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -61,7 +61,7 @@
     String applicationName;
     String principal;
     String vdbName;
-    String vdbVersion;
+    int vdbVersion;
     
     // RequestInfo
     String requestID;
@@ -82,7 +82,7 @@
                                 String applicationName,
                                 String principal,
                                 String vdbName,
-                                String vdbVersion,
+                                int vdbVersion,
                                 String sql) {
         // userCommandStart
         this.type = USER_COMMAND_START;
@@ -102,7 +102,7 @@
                                 String sessionID,
                                 String principal,
                                 String vdbName,
-                                String vdbVersion, 
+                                int vdbVersion, 
                                 int finalRowCount,
                                 boolean isCancelled,
                                 boolean errorOccurred) {

Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,392 +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.service;
-
-import java.io.File;
-import java.net.URL;
-import java.util.List;
-import java.util.Properties;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.ClassLoaderManager;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ConfigurationModelContainer;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.ConnectorBindingType;
-import com.metamatrix.common.config.api.ExtensionModule;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.platform.security.api.service.SessionListener;
-
-
-
-/** 
- * Configuration Service, this is responsible for all the configuration
- * for other services and also DQP configuration. 
- * @since 4.3
- */
-public interface ConfigurationService extends ApplicationService, ClassLoaderManager {
-    public static final String NEXT_VDB_VERSION = "NEXT_VDB_VERSION";         //$NON-NLS-1$
-    public static final String USER_DEFINED_FUNCTION_MODEL = "FunctionDefinitions.xmi"; //$NON-NLS-1$
-    /**
-     * Get the VDB contents for the "System.VDB" 
-     * @return URL - URL to System.vdb file; null if one not found
-     */
-    public URL getSystemVdb();
-    
-    public File getWorkDir();
-    
-    /**
-     * Get DQP properties
-     * @return Properties - properties
-     * @throws MetaMatrixComponentException
-     */
-    public Properties getSystemProperties();
-    
-    /**
-     * Set System property (Contents of ServerConfig.xml file)
-     * @param key
-     * @param value
-     * @throws MetaMatrixComponentException
-     */
-    public void setSystemProperty(String key, String value) throws MetaMatrixComponentException;
-
-    /**
-     * Set several System properties (Contents of ServerConfig.xml file). 
-     * Any properties not specified will remain unchanged.
-     * 
-     * @param properties The properties to set.
-     * @throws MetaMatrixComponentException
-     */
-    public void updateSystemProperties(Properties properties) throws MetaMatrixComponentException;
-
-    
-    
-    /**
-     * Get the system Configuration object loaded from the configuration object, this is currently
-     * only needed to support the exportConfiguration admin call. 
-     * @return
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    public ConfigurationModelContainer getSystemConfiguration() throws MetaMatrixComponentException;
-    
-        
-    /**
-     * Get the user defined functions file name  
-     * @return URL - URL to the User defined file; null if one not defined
-     */
-    public URL getUDFFile();
-    
-    /**
-     * Save the given vdb file into underlying persistent mechanism used by
-     * this configuration service 
-     * @param vdb - VDB to be saved
-     * @param version - Version to be saved as; when used text "NEXT_VDB_VERSION" as version 
-     * save as the next available version.
-     * @return
-     * @throws MetaMatrixComponentException
-     */
-    public void saveVDB(VDBArchive vdb, String version) throws MetaMatrixComponentException;
-
-    /**
-     * Add the VDB to the configuration 
-     * @param vdb - vdb to be added
-     * @param replaceBindings - flag which specifies action to be taken in case there are conflicts in
-     * connector bindings.
-     * @return - added VDB instance.
-     * @throws MetaMatrixComponentException
-     */
-    public VDBArchive addVDB(VDBArchive vdb, boolean replaceBindings) throws MetaMatrixComponentException;
-    
-    /**
-     * Delete the VDB from the underlying persistent mechanism used by  this
-     * configuration service
-     * @param vdbName - Name of the VDB
-     * @param vdbVersion - VDB version
-     * @throws MetaMatrixComponentException
-     */
-    public void deleteVDB(VDBArchive vdb) throws MetaMatrixComponentException;
-    
-    /**
-     * Assign a connector binding to the Model 
-     * @param vdbName - Name of the VDB
-     * @param version - version of the VDB
-     * @param modelName - Model Name
-     * @param bindings - bindings to be assigned
-     * @return modified VDB
-     */
-    public void assignConnectorBinding(String vdbName, String version, String modelName, ConnectorBinding[] bindings)  throws MetaMatrixComponentException;
-    
-    /**
-     * Get the list of VDB files available with the Configuration Service, this includes
-     * all status (active, inactive)
-     * @param vdbName - Name of the VDB
-     * @param vdbVersio - VDB version. 
-     * @return VDBArchive
-     * @throws MetaMatrixComponentException
-     */
-    public VDBArchive getVDB(String vdbName, String vdbVersion) throws MetaMatrixComponentException;
-    
-    /**
-     * Get a list of available VDBS from the configuration 
-     * @return list of {@link com.metamatrix.common.vdb.api.VDBArchive}
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    public List<VDBArchive> getVDBs() throws MetaMatrixComponentException;
-        
-    /** 
-     * Add the connector binding to the persistent store
-     * @param connectorBindingName - Connector Binding Name
-     * @param binding - Connector binding to Add
-     * @param replace - flag to replace in case a duplicate found.
-     */
-    public ConnectorBinding addConnectorBinding(String connectorBindingName, ConnectorBinding binding, boolean replace) 
-        throws MetaMatrixComponentException;    
-    
-    /** 
-     * Delete the connector binding from the persistent store
-     * @param connectorBindingName - Connector Binding Name
-     */
-    public void deleteConnectorBinding(String connectorBindingName) 
-        throws MetaMatrixComponentException;
-    
-    /** 
-     * get the connector binding from the persistent store
-     * @param connectorBindingName - Connector Binding Name
-     * @return Connector binding by the name given.
-     */
-    public ConnectorBinding getConnectorBinding(String connectorBindingName) 
-        throws MetaMatrixComponentException;
-
-    /**
-     * Get the default properties for the Connector type 
-     * @param type
-     * @return properties
-     */
-    public Properties getDefaultProperties(ConnectorBindingType type);
-    
-    /** 
-     * Update the Connector Binding, the assumption here that we kept the name same 
-     * @param binding - Connector Binding to be modified
-     * @return modified connector; usually same referenced object.
-     */
-    public ConnectorBinding updateConnectorBinding(ConnectorBinding binding) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Get the list of connector bindings available in the configuration.  
-     * @return list of {@link com.metamatrix.common.config.api.ConnectorBinding}
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    public List<ConnectorBinding> getConnectorBindings() throws MetaMatrixComponentException;
-        
-    
-    /**
-     * Get Component type for the given id  
-     * @param id
-     * @return
-     * @throws MetaMatrixComponentException
-     */
-    public ConnectorBindingType getConnectorType(String connectorType) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Add the Given component type to the persistent store 
-     * @param type
-     * @throws MetaMatrixComponentException
-     */
-    public void saveConnectorType(ConnectorBindingType type) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Delete the Given component type to the persistent store 
-     * @param connectorType - Name of the connector Type
-     * @throws MetaMatrixComponentException
-     */
-    public void deleteConnectorType(String connectorType) 
-        throws MetaMatrixComponentException;    
-
-    /**
-     * Get list of all the connector types available in the System. 
-     * @return list of {@link com.metamatrix.common.config.api.ComponentType}
-     * @throws MetaMatrixComponentException
-     */
-    public List<ComponentType> getConnectorTypes() 
-        throws MetaMatrixComponentException;
-        
-    /**
-     * Retun the context class path to be used by all the extension modules
-     * to use. if one not specified a default must be supplied. Usally this
-     * is directory where all the extension jars are stored or a URL
-     * @return String URL - url to extension path; null if extensions are not used 
-     * @since 4.3
-     */
-    public URL[] getExtensionPath();
-
-    /**
-     * Get the list of extension modules available in the store
-     * @return list of Extension Modules {@link com.metamatrix.common.config.api.ExtensionModule} 
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    public List<ExtensionModule> getExtensionModules() throws MetaMatrixComponentException;
-
-    /**
-     * Get the extension module by the given identifier 
-     * @param extModuleName - Module name
-     * @return ExtensionModule; null if not found
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    public ExtensionModule getExtensionModule(String extModuleName) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Save the given extension module 
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    public void saveExtensionModule(ExtensionModule extModule) throws MetaMatrixComponentException;
-    
-    /**
-     * Delete the extension module from the configuration with name supplied 
-     * @param extModuleName - extension module name
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    public void deleteExtensionModule(String extModuleName) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Client Connection Listener object for the service; This will get notifications
-     * about the connections currently available to DQP. 
-     * @throws MetaMatrixComponentException
-     * @since 4.3.2
-     */
-    public SessionListener getSessionListener(); 
-     
- 
-    /**
-     * Register a listener for the VDB life cycle events, and get notified for
-     * when vdb is loded and unloaded 
-     * @param listener - lister object
-     */
-    public void register(VDBLifeCycleListener listener);
-    
-    public void unregister(VDBLifeCycleListener listener);
-    
-    /**
-     * Register a listener for the connector binding life cycle events, and get notified for
-     * when connector binding is loded and unloaded 
-     * @param listener - lister object
-     */
-    public void register(ConnectorBindingLifeCycleListener listener);
-    
-    public void unregister(ConnectorBindingLifeCycleListener listener);
-        
-    /**
-     * Gets the reference URL to the Configuration File for the DQP.
-     * @return URL to configuration file; null otherwise
-     * @since 4.4
-     */
-    public URL getConfigFile();
-    
-    
-    /**
-     * Use the extension classpath defined in the connector bindins and load jars in
-     * different class loader or in the same class loader as calling code
-     * @return true - to load different class loader, false otherwise
-     */
-    public boolean useExtensionClasspath();
-    
-    
-    /**
-     * Get path(s) for VDB(s) that are availble from the configuration to the DQP
-     * engine. 
-     * @return URLs to the resources.
-     */
-    public URL[] getVDBLocations();
-    
-    
-    /**
-     * Use disk for buffering for result set management during the processing 
-     * @return true if yes to use buffering; false otherwise
-     */
-    public boolean useDiskBuffering();
-    
-    /**
-     * Get the directory to use for the disk buffering  
-     * @return must a return a location 
-     */
-    public File getDiskBufferDirectory();
-    
-
-    /**
-     * Size of Memory in MB allocated to be used by the Resultset Management before
-     * disk buffering kicks in.  
-     * @return must a return a location 
-     */
-    public String getBufferMemorySize();
-    
-    /**
-     * Return some identifier which uniquely identifies the DQP. Usually this
-     * is name given to this process 
-     * @return unique number for DQP in a given JVM
-     */
-    public String getProcessName();    
-    
-
-    /**
-     * Gets the processor batch size 
-     * @return
-     * @since 4.3
-     */
-    String getProcessorBatchSize();
-    /**
-     * Gets the connector batch size 
-     * @return
-     * @since 4.3
-     */
-    String getConnectorBatchSize();    
-    
-    /**
-     * Unload the User defined functions file.  
-     * @throws MetaMatrixComponentException
-     */
-    void unloadUDF() throws MetaMatrixComponentException;
-    
-    /**
-     * Load the UDF function model 
-     * @throws MetaMatrixComponentException
-     */
-    void loadUDF() throws MetaMatrixComponentException;
-    
-    void clearClassLoaderCache() throws MetaMatrixComponentException;
-    
-    boolean isFullyConfiguredVDB(VDBArchive vdb) throws MetaMatrixComponentException;
-    
-    String getClusterName();
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,101 +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.service;
-
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
-import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-
-
-/**
- * Defines constants used for naming DQP services.
- */
-public interface DQPServiceNames {
-
-    /** Buffer service - provides access to buffer management */
-    public static final String BUFFER_SERVICE = "dqp.buffer"; //$NON-NLS-1$
-
-    /** Metadata service - provides acecss to runtime metadata */
-    public static final String METADATA_SERVICE = "dqp.metadata"; //$NON-NLS-1$
-
-    /** Data service - provides access to data via connectors */
-    public static final String DATA_SERVICE = "dqp.data"; //$NON-NLS-1$
-
-    /** Authorization service - provides access to entitlements info */
-    public static final String AUTHORIZATION_SERVICE = "dqp.authorization"; //$NON-NLS-1$
-
-    /** VDB service - provides access to vdb information */
-    public static final String VDB_SERVICE = "dqp.vdb"; //$NON-NLS-1$
-
-    /** Transaction service - provides access to MMTtransactionManager */
-    public static final String TRANSACTION_SERVICE = "dqp.transaction"; //$NON-NLS-1$
-
-    /** Configuration Service - provides access to Configuration*/
-    public static final String CONFIGURATION_SERVICE = "dqp.configuration"; //$NON-NLS-1$
-    
-    public static final String REGISTRY_SERVICE = "platform.registry"; //$NON-NLS-1$
-    
-    public static final String SESSION_SERVICE = "dqp.session"; //$NON-NLS-1$
-    
-    public static final String MEMBERSHIP_SERVICE = "dqp.membership"; //$NON-NLS-1$
-    
-
-    /**
-     * Array of all services a DQP may use.
-     */
-    public static final String[] ALL_SERVICES = new String[] {
-        CONFIGURATION_SERVICE,
-        BUFFER_SERVICE,
-        AUTHORIZATION_SERVICE,
-        TRANSACTION_SERVICE,                                           
-        VDB_SERVICE,
-        METADATA_SERVICE,
-        DATA_SERVICE,
-        SESSION_SERVICE,
-        MEMBERSHIP_SERVICE
-    };
-    
-    public static final Class[] ALL_SERVICE_CLASSES = new Class[] {
-    	ConfigurationService.class,
-        BufferService.class,
-        AuthorizationService.class,
-        TransactionService.class,                                           
-        VDBService.class,
-        MetadataService.class,
-        DataService.class,
-        SessionServiceInterface.class,
-        MembershipServiceInterface.class
-    };
-    
-    public static final String[] SERVICE_LOGGING_CONTEXT = new String[] {
-    	null,
-        null,
-        null,
-        LogConstants.CTX_TXN_LOG,                                           
-        null,
-        null,
-        null,
-        null,
-        null
-    };
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,171 +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.service;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Properties;
-
-import org.teiid.adminapi.ConnectionPool;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-
-/**
- * Defines interface for management of the Data Services, i.e Connectors with
- * which all the physical data is accessed.
- *  
- */
-public interface DataService extends ApplicationService {
-
-    /**
-     * Select a connector to use for the given connector binding.
-     * @param connectorBindingName Connector binding identifier
-     * @return ConnectorID identifying a connector instance
-     */
-    ConnectorID selectConnector(String connectorBindingName) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Execute the given request on a <code>Connector</code>.
-     * @param request
-     * @return
-     */
-    void executeRequest(AtomicRequestMessage request, ConnectorID connector, ResultsReceiver<AtomicResultsMessage> resultListener) 
-        throws MetaMatrixComponentException;
-    
-	void cancelRequest(AtomicRequestID request, ConnectorID connectorId) throws MetaMatrixComponentException;
-
-	void closeRequest(AtomicRequestID request, ConnectorID connectorId) throws MetaMatrixComponentException;
-	
-	void requestBatch(AtomicRequestID request, ConnectorID connectorId) throws MetaMatrixComponentException;
-
-    /**
-     * Find the capabilities of this source.
-     * @param request Original request message, used to extract security information
-     * @param connector Connector to retrieve capabilities from
-     * @return All capability information as key-value pairs
-     */
-    SourceCapabilities getCapabilities(RequestMessage request, DQPWorkContext dqpWorkContext, String modelName) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Return the metadata for a given connector
-     * @param vdbName
-     * @param vdbVersion
-     * @param modelName
-     * @param importProperties
-     * @return
-     * @throws MetaMatrixComponentException 
-     */
-    MetadataStore getConnectorMetadata(String vdbName, String vdbVersion, String modelName, Properties importProperties) throws MetaMatrixComponentException;
-               
-    /**
-     * Start the Connector Binding by the name given, if it is already added and not srarted. 
-     * @param connectorBindingName
-     * @throws ApplicationLifecycleException
-     * @throws ComponentNotFoundException
-     * @since 4.3
-     */
-    void startConnectorBinding(String connectorBindingName)
-        throws ApplicationLifecycleException, MetaMatrixComponentException;
-
-    /**
-     * Stop the Connector Binding by the given name 
-     * @param connectorBindingName
-     * @throws ApplicationLifecycleException
-     * @throws ComponentNotFoundException
-     * @since 4.3
-     */
-    void stopConnectorBinding(String connectorBindingName) 
-        throws ApplicationLifecycleException, MetaMatrixComponentException;
-    
-    /**
-     * Get the list of connector bindings deployed in the system. 
-     * @return list {@link com.metamatrix.common.config.api.ConnectorBinding}
-     * @throws ComponentNotFoundException
-     * @since 4.3
-     */
-    List getConnectorBindings() throws MetaMatrixComponentException;
-    
-
-    /**
-     * Get the connector binding specifed the name 
-     * @return ConnectorBinding
-     * @throws ComponentNotFoundException
-     * @since 4.3
-     */
-    ConnectorBinding getConnectorBinding(String connectorBindingName) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Get the State of the connector binding name 
-     * @return {@link ConnectorStatus}
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    ConnectorStatus getConnectorBindingState(String connectorBindingName) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Get connector bindings queue statistics 
-     * @param connectorBindingName - Name of the connector binding
-     * @return a list of {@link com.metamatrix.common.queue.WorkerPoolStats}
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    Collection getConnectorBindingStatistics(String connectorBindingName)
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Clear any caches for the connector binding. Incase of the JDBC Connector
-     * clear the result set cache. 
-     * @param connectorBindingName
-     * @throws MetaMatrixComponentException
-     * @since 4.3
-     */
-    void clearConnectorBindingCache(String connectorBindingName) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Get connection pool statistics for connector binding 
-     * @param connectorBindingName - Name of the connector binding
-     * @return a list of {@link com.metamatrix.admin.objects.ConnectionPoolStatsImpl}
-     * @throws MetaMatrixComponentException
-     * @since 6.1
-     */
-    Collection<? extends ConnectionPool> getConnectionPoolStatistics(String connectorBindingName)
-        throws MetaMatrixComponentException;
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,44 +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.service;
-
-import java.util.Map;
-
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.metadata.CompositeMetadataStore;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-
-/**
- */
-public interface MetadataService extends ApplicationService {
-
-    QueryMetadataInterface lookupMetadata(String vdbName, String vdbVersion) throws  MetaMatrixComponentException;
-    
-    CompositeMetadataStore getMetadataObjectSource(String vdbName, String vdbVersion) throws MetaMatrixComponentException;
-    
-    Map<String, Datatype> getBuiltinDatatypes() throws MetaMatrixComponentException;
-    
-}

Copied: trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java	                        (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,117 @@
+/*
+ * 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.service;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.resource.spi.work.ExecutionContext;
+
+public class TransactionContext extends ExecutionContext implements Serializable{
+
+	private static final long serialVersionUID = -8689401273499649058L;
+
+	public enum Scope {
+		BLOCK,
+		GLOBAL,
+		LOCAL,
+		NONE,
+		REQUEST
+	}
+	
+    private String threadId;
+    private Scope transactionType = Scope.NONE;
+    private long creationTime;
+    private boolean rollback = false;
+    private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
+    private Map<String, AtomicInteger> txnSources = Collections.synchronizedMap(new HashMap<String, AtomicInteger>());
+    
+    public boolean isInTransaction() {
+        return (getXid() != null && this.txnSources.size() > 0);
+    }
+
+    public long getCreationTime() {
+		return creationTime;
+	}
+    
+    public void setCreationTime(long time) {
+		this.creationTime = time;
+	}    
+    
+    public void setTransactionType(Scope transactionType) {
+        this.transactionType = transactionType;
+    }
+
+    public Scope getTransactionType() {
+        return transactionType;
+    }
+
+    public void setThreadId(String threadId) {
+        this.threadId = threadId;
+    }
+
+    public String getThreadId() {
+        return threadId;
+    }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer();
+        this.buildString(sb);
+        return sb.toString();
+    }
+
+    private void buildString(StringBuffer sb) {
+        sb.append("xid: ").append(getXid()); //$NON-NLS-1$
+    }
+    
+    public void setRollbackOnly() {
+    	this.rollback = true;
+    }
+    
+    public boolean shouldRollback() {
+    	return this.rollback;
+    }
+    
+    public Set<String> getSuspendedBy() {
+        return this.suspendedBy;
+    }
+
+	public void incrementPartcipatingSourceCount(String source) {
+		AtomicInteger count = txnSources.get(source);
+		if (count == null) {
+			txnSources.put(source, new AtomicInteger(1));
+		}
+		else {
+			count.incrementAndGet();
+		}
+	}
+	
+	public boolean isOnePhase() {
+		return this.txnSources.size() == 1;
+	}    
+}
\ No newline at end of file

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,95 +26,53 @@
 
 import java.util.Collection;
 
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
 import org.teiid.adminapi.AdminException;
 import org.teiid.adminapi.Transaction;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
 
-import com.metamatrix.common.application.ApplicationService;
 import com.metamatrix.common.xa.MMXid;
 import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
 
 /**
  */
-public interface TransactionService extends ApplicationService {
-	public static final String TRANSACTIONS_ENABLED = "xa.enabled"; //$NON-NLS-1$
-    public static final String MAX_TIMEOUT = "xa.max_timeout"; //$NON-NLS-1$
-    public static final String TXN_STORE_DIR = "xa.txnstore_dir"; //$NON-NLS-1$
-    public static final String TXN_STATUS_PORT = "xa.txnstatus_port"; //$NON-NLS-1$
-    public static final String TXN_ENABLE_RECOVERY = "xa.enable_recovery"; //$NON-NLS-1$
+public interface TransactionService {
     
-    public static final String PROCESSNAME = DQPEmbeddedProperties.PROCESSNAME;
-    
-    public static final String DEFAULT_TXN_MGR_LOG_DIR = "txnlog"; //$NON-NLS-1$
-    public static final String DEFAULT_TXN_TIMEOUT = "120"; //$NON-NLS-1$ //2 mins
-    public static final String DEFAULT_TXN_STATUS_PORT = "0"; //$NON-NLS-1$
-    
-    TransactionManager getTransactionManager();
-
     // processor level methods
-    TransactionContext start(TransactionContext context) throws XATransactionException, SystemException;
+    TransactionContext start(TransactionContext context) throws XATransactionException;
 
-    TransactionContext commit(TransactionContext context) throws XATransactionException, SystemException;
+    TransactionContext commit(TransactionContext context) throws XATransactionException;
 
-    TransactionContext rollback(TransactionContext context) throws XATransactionException, SystemException;
+    TransactionContext rollback(TransactionContext context) throws XATransactionException;
 
     TransactionContext getOrCreateTransactionContext(String threadId);
 
     // local transaction methods
-    TransactionContext begin(String threadId) throws XATransactionException, SystemException;
+    TransactionContext begin(String threadId) throws XATransactionException;
 
-    void commit(String threadId) throws XATransactionException, SystemException;
+    void commit(String threadId) throws XATransactionException;
 
-    void rollback(String threadId) throws XATransactionException, SystemException;
+    void rollback(String threadId) throws XATransactionException;
 
-    void cancelTransactions(String threadId, boolean requestOnly) throws InvalidTransactionException, SystemException;
+    void cancelTransactions(String threadId, boolean requestOnly) throws XATransactionException;
 
     // global transaction methods
-    int prepare(final String threadId,
-            MMXid xid) throws XATransactionException;
+    int prepare(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException;
 
-	void commit(final String threadId,
-	                   MMXid xid,
-	                   boolean onePhase) throws XATransactionException;
+	void commit(final String threadId, MMXid xid, boolean onePhase, boolean singleTM) throws XATransactionException;
 	
-	void rollback(final String threadId,
-	                     MMXid xid) throws XATransactionException;
+	void rollback(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException;
 	
-	Xid[] recover(int flag) throws XATransactionException;
+	Xid[] recover(int flag, boolean singleTM) throws XATransactionException;
 	
-	void forget(final String threadId,
-	            MMXid xid) throws XATransactionException;
+	void forget(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException;
 	
-	void start(final String threadId,
-	           MMXid xid,
-	           int flags,
-	           int timeout) throws XATransactionException;
+	void start(final String threadId, MMXid xid, int flags, int timeout, boolean singleTM) throws XATransactionException;
 	
-	void end(final String threadId,
-	         MMXid xid,
-	         int flags) throws XATransactionException;
+	void end(final String threadId, MMXid xid, int flags, boolean singleTM) throws XATransactionException;
         
 	// management methods
     Collection<Transaction> getTransactions();
     
-    void terminateTransaction(Xid transactionId) throws AdminException;
-    
-    void terminateTransaction(String transactionId, String sessionId) throws AdminException;
-    
-    // Teiid managed XA
-    TransactionContext enlist(TransactionContext context,
-                              XAResource resource) throws XATransactionException;
-    
-    void registerRecoverySource(String name, XAConnectionSource resource);
-    
-    void removeRecoverySource(String name);  
-
+    void terminateTransaction(String transactionId) throws AdminException;
 }

Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.dqp.service;
-
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.vdb.api.VDBArchive;
-
-/**
- * This interface defines methods which are specific to dealing with VDBs
- * and their management in a server/dqp.
- */
-public interface VDBService extends ApplicationService {
-    
-    /**
-     * Get connector bindings for a particular vdb model.  For most models, there will be exactly one.  For 
-     * multi-source models, there may be more than one.  The {@link VDBConfiguration#getMultiSourceModels(String, String)}
-     * method can be used to determine which models are multi-source models.
-     * @param vdbName VDB name
-     * @param vdbVersion VDB version
-     * @param modelName Model name
-     * @return list of {@link java.lang.String} names of connectors
-     */
-    public List<String> getConnectorBindingNames(String vdbName, String vdbVersion, String modelName)  
-        throws MetaMatrixComponentException;
-    
-    
-    /**
-     * Get model visibility
-     * @param vdbName VDB name
-     * @param vdbVersion VDB version
-     * @param modelName The name of the model
-     * @return Visibility constant, as defined in this class
-     */
-    public int getModelVisibility(String vdbName, String vdbVersion, String modelName)  
-        throws MetaMatrixComponentException;
-
-    /**
-     * Get visibility of the file at the given path in the vdb.
-     * @param vdbName VDB name
-     * @param vdbVersion VDB version
-     * @param pathInVDB The path to the model in the VDB
-     * @return Visibility constant, as defined in this class
-     */
-    public int getFileVisibility(String vdbName, String vdbVersion, String pathInVDB)  
-        throws MetaMatrixComponentException;    
-    
-    /**
-     * Get all multi-source model names (models that can be bound to multiple connector bindings) for this VDB
-     * name and version. 
-     * @param vdbName VDB name
-     * @param vdbVersion VDB version
-     * @return List<String> of model names that are multi-source models.
-     * @since 4.2
-     */
-    public List getMultiSourceModels(String vdbName, String vdbVersion) 
-        throws MetaMatrixComponentException;
-    
-    /**
-     * Get the list of VDBs available from  the service
-     * @return List of {@link com.metamatrix.metadata.runtime.admin.vdb.VDBDefn}
-     * @since 4.3
-     */
-    public List<VDBArchive> getAvailableVDBs() 
-        throws MetaMatrixComponentException;
-            
-    /**
-     * Change the status of the VDB  
-     * @param vdbName - Name of the VDB
-     * @param vdbVersion - Version of the VDB
-     * @param status - 
-     * @since 4.3
-     */
-    public void changeVDBStatus(String vdbName, String vdbVersion, int status) 
-        throws ApplicationLifecycleException, MetaMatrixComponentException;   
-    
-    // to be removed later..
-    public String getConnectorName(String connectorBindingID) throws MetaMatrixComponentException;    
-    
-    /**
-     * 
-     * @param vdbName
-     * @param vdbVersion may be null to indicate latest/default
-     * @return
-     * @throws MetaMatrixComponentException
-     */
-    public VDBArchive getVDB(String vdbName, String vdbVersion) throws MetaMatrixComponentException;
-}

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/util/LogConstants.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,10 +22,12 @@
 
 package com.metamatrix.dqp.util;
 
+import org.teiid.connector.basic.DefaultConnectorLogger;
+
 public interface LogConstants {
 	// add the new contexts to the Log4JUtil.java class, for configuration purpose
 	public static final String CTX_DQP = "DQP"; //$NON-NLS-1$
-    public static final String CTX_CONNECTOR = "CONNECTOR"; //$NON-NLS-1$
+    public static final String CTX_CONNECTOR = DefaultConnectorLogger.CTX_CONNECTOR;
     public static final String CTX_BUFFER_MGR = "BUFFER_MGR"; //$NON-NLS-1$
     public static final String CTX_STORAGE_MGR = "STORAGE_MGR"; //$NON-NLS-1$
     public static final String CTX_TXN_LOG = "TXN_LOG"; //$NON-NLS-1$

Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,156 +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.platform.security.api;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * This class represents an immutable informational object describing
- * the attributes of a unique MetaMatrix session within a given MetaMatrix System.
- */
-public class MetaMatrixSessionInfo implements Serializable, Cloneable {
-    
-    public final static long serialVersionUID = -9120197553960136239L;
-    
-    private SessionToken sessionToken;  // immutable
-    private long lastPingTime;
-    private long timeCreated;
-    private String applicationName;
-    private Properties productInfo;
-    private String clientIp;
-    private String clientHostname;
-    private Serializable trustedToken;
-
-    /**
-     * Master constructor, allows a MetaMatrixSessionInfo to be created with
-     * any state and any timestamps.
-     */
-    public MetaMatrixSessionInfo(MetaMatrixSessionID sessionID, String userName, long timeCreated, String applicationName, Properties productInfo, String clientIp, String clientHostname){
-        this.timeCreated = timeCreated;
-        this.lastPingTime = timeCreated;
-        this.applicationName = applicationName;
-        this.sessionToken = new SessionToken(sessionID, userName);
-        this.productInfo = productInfo;
-        this.clientIp = clientIp;
-        this.clientHostname = clientHostname;
-    }
-
-    public MetaMatrixSessionID getSessionID() {
-        return this.sessionToken.getSessionID();
-    }
-
-    public String getUserName() {
-        return this.sessionToken.getUsername();
-    }
-
-    public String getApplicationName() {
-        return this.applicationName;
-    }
-
-    public long getTimeCreated() {
-        return this.timeCreated;
-    }
-
-    /**
-     * Get the time the server was last pinged by this session.
-     * Note that the session's "last ping time" will only be acurate
-     * if the session is in the ACTIVE state.
-     * @return The time the server was last pinged by this session.
-     */
-    public long getLastPingTime() {
-        return lastPingTime;
-    }
-
-    /**
-     * Used <i><b>ONLY</b></i> by the session service to set the
-     * time this session last initiated a server ping.
-     * @param lastPingTime The last time this session pinged the server.
-     */
-    public void setLastPingTime(long lastPingTime) {
-        this.lastPingTime = lastPingTime;
-    }
-
-    public SessionToken getSessionToken(){
-        return this.sessionToken;
-    }
-
-    /**
-     * Return a cloned instance of this object.
-     * @return the object that is the clone of this instance.
-     */
-    public Object clone() {
-        try {
-            // Everything is immutable, so bit-wise copy (of references) is okay!
-            return super.clone();
-        } catch ( CloneNotSupportedException e ) {
-        }
-        return null;
-    }
-
-    /**
-     * Returns a string representing the current state of the object.
-     */
-    public String toString() {
-        StringBuffer s = new StringBuffer();
-        s.append("MetaMatrixSessionInfo[ "); //$NON-NLS-1$
-        s.append(this.sessionToken.toString());
-        s.append(", "); //$NON-NLS-1$
-        s.append("application:"); //$NON-NLS-1$
-        s.append(this.applicationName);
-        s.append(", created:"); //$NON-NLS-1$
-        s.append(this.timeCreated);
-        s.append(", last pinged server:"); //$NON-NLS-1$
-        s.append(this.lastPingTime);
-        s.append("]"); //$NON-NLS-1$
-        return s.toString();
-    }
-
-    /** 
-     * @return Returns the productInfo.
-     * @since 4.3
-     */
-    public String getProductInfo(String key) {
-        return this.productInfo.getProperty(key);
-    }
-    
-    public Properties getProductInfo() {
-    	return this.productInfo;
-    }
-
-	public String getClientIp() {
-		return clientIp;
-	}
-
-	public String getClientHostname() {
-		return clientHostname;
-	}
-
-	public void setTrustedToken(Serializable trustedToken) {
-		this.trustedToken = trustedToken;
-	}
-
-	public Serializable getTrustedToken() {
-		return trustedToken;
-	}
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/AuthenticationToken.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/AuthenticationToken.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/AuthenticationToken.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,63 +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.
- */
-
-/*
- * Date: Feb 11, 2004
- * Time: 9:33:14 AM
- */
-package com.metamatrix.platform.security.api.service;
-
-import java.io.Serializable;
-
-/**
- * Interface AuthenticationToken.
- *
- * <p></p>
- */
-public interface AuthenticationToken extends Serializable {
-
-    /**
-     * Get the payload token that has been successfully authentcated by a
-     * membership domain.
-     * @return The successfully authenticated token unmodified.
-     */
-    Serializable getPayload();
-    
-    /**
-     * Get the <b>exact</b> username of the authenticated user as it
-     * is known to the authenticating membership domain.
-     * <br>Will be <code>null</code> if the user was <b>not</b>
-     * authenticated. 
-     * @return The username (including case) of this authenticated
-     * user exactly as it is known by the authenticating memebership domain.
-     * @since 5.0
-     */
-    String getUserName();
-
-    /**
-     * Find out whether or not the user was authenticated. 
-     * @return <code>true</code> iff the membership domain was able 
-     * to authenticate this user. 
-     * @since 5.0
-     */
-    boolean isAuthenticated();
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/FailedAuthenticationToken.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/FailedAuthenticationToken.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/FailedAuthenticationToken.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.
- */
-
-/*
- * Date: Dec 1, 2003
- * Time: 1:26:57 PM
- */
-package com.metamatrix.platform.security.api.service;
-
-import java.io.Serializable;
-
-/**
- * FailedAuthenticationToken
- *
- * <p>Marker indicating failed authentication attempt.  Membership SPI
- * domain implementations should wrap the <code>Serializable</code> payload
- * in an instance of this class to signify to the Membgership service that
- * the domian failed to authenticate the given payload token.</p>
- *
- * <p>This wrapper class will not be exposed outside of the Mebership framework.</p>
- */
-public final class FailedAuthenticationToken implements AuthenticationToken {
-
-    /**
-     * FailedAuthenticationToken
-     *
-     * @param payload The failed authentication token - may be null.
-     */
-    public FailedAuthenticationToken() {
-    }
-
-    /**
-     * Get the payload token that failed to authentcation by a
-     * membership domain.
-     *
-     * @return The failed authentication token unmodified - may be null.
-     */
-    public Serializable getPayload() {
-        return null;
-    }
-
-    /**
-     * Get the <b>exact</b> username of the authenticated user as it
-     * is known to the authenticating membership domain.
-     * <p><b>Will be <code>null</code> if the user was <b>not</b>
-     * authenticated. </b></p>
-     * @return The username (including case) of this authenticated
-     * user exactly as it is known by the authenticating memebership domain.
-     * @since 5.0
-     */
-    public String getUserName() {
-        return null;
-    }
-
-    /**
-     * The attempt to authenticate the given payload failed.
-     * @return <code>false</code> - always.
-     */
-    public boolean isAuthenticated() {
-        return false;
-    }
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,117 +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.platform.security.api.service;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Set;
-
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-import com.metamatrix.api.exception.security.InvalidPrincipalException;
-import com.metamatrix.api.exception.security.MembershipServiceException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-
-/**
- * This interface represents the API to the MemberShip Service,
- * and it defines the functionality that is accessible to clients.
- */
-public interface MembershipServiceInterface extends ApplicationService {
-    public static String NAME = "MembershipService"; //$NON-NLS-1$
-    
-    /**
-     * The environment property describing both the domain names and their required
-     * order of search.  Domain names are assumed to be in preferred search order
-     * and in the form "A,X,...,D" where A, X and D are domain names.
-     * This property is required (there is no default).
-     */
-    public static final String DOMAIN_ORDER = "membership.DomainOrder"; //$NON-NLS-1$
-    /**
-     * The environment property name for the class that is to be used for the names of the domains.
-     * This property is required (there is no default).
-     */
-    public static final String DOMAIN_NAME = "domainName"; //$NON-NLS-1$
-    
-    public static final String DEFAULT_ADMIN_USERNAME = "admin"; //$NON-NLS-1$
-    
-    public static final String ADMIN_PASSWORD = "membership.superUserPassword"; //$NON-NLS-1$
-    public static final String ADMIN_USERNAME = "membership.superUser"; //$NON-NLS-1$
-    public static final String DOMAIN_ACTIVE = "activate"; //$NON-NLS-1$
-    public static final String ADMIN_HOSTS = "membership.allowedHosts"; //$NON-NLS-1$
-    public static final String SECURITY_ENABLED = "membership.enabled"; //$NON-NLS-1$
-    
-    public static final String DOMAIN_PROPERTIES = "propertiesFile"; //$NON-NLS-1$
-
-	public static final String AT = "@"; //$NON-NLS-1$
-
-    /**
-     * Authenticate a user with the specified username and credential
-     * for use with the specified application. The application name may also
-     * be used by the Membership Service to determine the appropriate authentication
-     * mechanism.
-     * @param username the username that is to be authenticated
-     * @param credential the credential provided by the user that is to be used
-     * to authenticate the user for the principal name
-     * @param trustePayload
-     * @param applicationName the name of the application for which the user
-     * is authenticating
-     * @return true if the specified credentials properly authenticates for
-     * the application the user with the specified username and application
-     * @throws MetaMatrixSecurityException if there is an error within this
-     * service or during communicating with the underlying service provider
-     */
-    AuthenticationToken authenticateUser(String username, Credentials credential, Serializable trustePayload, String applicationName)
-    throws MembershipServiceException;
-
-    /**
-     * Obtain the principal object that is representative of the user with the specified username.
-     * 
-     * all names should be domain qualified.
-     */
-    MetaMatrixPrincipal getPrincipal(MetaMatrixPrincipalName principal)
-    throws MembershipServiceException, InvalidPrincipalException;
-    
-    /**
-     * Obtain the collection of groups to which this user belongs
-     * 
-     * The username should be fully qualified
-     */
-    Set<String> getGroupsForUser(String username)
-    throws MembershipServiceException, InvalidPrincipalException;
-    
-    /**
-     * Obtain the collection of group names. 
-     */
-    Set<String> getGroupNames() throws MembershipServiceException;
-
-    List<String> getDomainNames() throws MembershipServiceException;
-
-    Set<String> getGroupsForDomain(String domainName) throws MembershipServiceException;
-    
-    boolean isSuperUser(String username) throws MembershipServiceException;
-    
-    boolean isSecurityEnabled() throws MembershipServiceException;  
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionListener.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,32 +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.platform.security.api.service;
-
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-
-public interface SessionListener {
-
-	void sessionCreated(MetaMatrixSessionInfo info);
-	
-	void sessionClosed(MetaMatrixSessionInfo info);
-}

Copied: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java	                        (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,148 @@
+/*
+ * 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.platform.security.api.service;
+
+import java.util.Collection;
+import java.util.Properties;
+
+import javax.security.auth.login.LoginException;
+
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.dqp.internal.process.DQPCore;
+
+import com.metamatrix.admin.api.exception.security.InvalidSessionException;
+import com.metamatrix.api.exception.security.AuthorizationException;
+import com.metamatrix.api.exception.security.SessionServiceException;
+import com.metamatrix.platform.security.api.Credentials;
+
+/**
+ * <p>
+ * The session service deals with managing sessions; this involves creating
+ * sessions, closing sessions, terminating sessions, and updating session
+ * state.
+ * </p>
+ * <p>
+ * A session has a timestamp, information about the principal owning the
+ * session, and a "state" indicating whether it is actively in use, in use
+ * but passivated, or has been rendered invalid by being closed or terminated,
+ * or by expiring.
+ * </p>
+ * <p>
+ * Note that this service does <i>not</i> deal with authentication explicitly,
+ * but may use a membership service provider to authenticate some
+ * requests.
+ * </p>
+ */
+public interface SessionService {
+    public static String NAME = "SessionService"; //$NON-NLS-1$
+
+    public static final long DEFAULT_MAX_SESSIONS = 5000; 
+    public static final long DEFAULT_SESSION_EXPIRATION = 0; 
+    
+    public static final String MAX_SESSIONS = "session.maxSessions"; //$NON-NLS-1$
+    public static final String SESSION_EXPIRATION = "session.expirationTimeInMilli"; //$NON-NLS-1$
+    
+    /**
+     * Create a session for the given user authenticating against the given <code>Credentials</code>.
+     */
+    public SessionMetadata createSession(String userName,
+                                               Credentials credentials,
+                                               String applicationName,
+                                               Properties properties, boolean admin)
+            throws LoginException, SessionServiceException;
+
+    /**
+     * Closes the specified session.
+     *
+     * @param sessionID The MetaMatrixSessionID identifying user's session
+     * to be closed
+     * @throws InvalidSessionException If sessionID identifies an invalid
+     * session
+     * @throws SessionServiceException
+     */
+    void closeSession(long sessionID) throws InvalidSessionException;
+
+    /**
+     * Terminates the specified session.  This is an administrative action.
+     *
+     * @param terminatedSessionID The MetaMatrixSessionID identifying user's session
+     * to be terminated
+     * @param adminSessionID The session id identifying session of administrator
+     * @throws InvalidSessionException If terminatedSessionID identifies an invalid
+     * session
+     * @throws AuthorizationException if the caller denoted by <code>adminSessionID</code>
+     * does not have authority to terminate the <code>terminatedSessionID</code> session
+     * @throws SessionServiceException
+     */
+    boolean terminateSession(long terminatedSessionID, long adminSessionID);
+
+    /**
+     * Get the collection of active user sessions on the system.
+     * @return The collection of MetaMatrixSessionInfo objects of active users on
+     * the system - possibly empty, never null.
+     */
+    Collection<SessionMetadata> getActiveSessions() throws SessionServiceException;
+
+    /**
+     * Get the number of active user sessions on the system.
+     * @return int
+     */
+    int getActiveSessionsCount() throws SessionServiceException;
+
+    /**
+     * This method is intended to verify that the session is valid, and, if
+     * need be, set the session in an active state, ready to be used.
+     * @param sessionID MetaMatrixSessionID representing the session
+     * @return SessionToken object identifying the session
+     * @throws InvalidSessionException If sessionID identifies an invalid
+     * session
+     * @throws SessionServiceException
+     */
+    SessionMetadata validateSession(long sessionID)
+    throws InvalidSessionException, SessionServiceException;
+    
+    /**
+     * Get all <code>MetaMatrixSessionID</code>s that are in the ACTIVE state
+     * and currently logged in to a VDB.
+     * @param VDBName The name of the VDB.
+     * @param VDBVersion The version of the VDB.
+     * @throws SessionServiceException when transaction with database fails or unexpected exception happens
+     */
+    Collection<SessionMetadata> getSessionsLoggedInToVDB(String VDBName, int VDBVersion)
+    throws SessionServiceException;
+
+    /**
+     * Periodically called by the client to indicate the client is still alive.
+     *
+     * @param sessionID - identifies the client
+     */
+    public void pingServer(long sessionID) throws InvalidSessionException;
+    
+    
+    public void setLocalSession(long sessionID);
+    
+    SessionMetadata getActiveSession(long sessionID);
+    
+	void setDqp(DQPCore dqp);
+
+}

Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,161 +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.platform.security.api.service;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Properties;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.api.exception.security.MetaMatrixAuthenticationException;
-import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-
-/**
- * <p>
- * The session service deals with managing sessions; this involves creating
- * sessions, closing sessions, terminating sessions, and updating session
- * state.
- * </p>
- * <p>
- * A session has a timestamp, information about the principal owning the
- * session, and a "state" indicating whether it is actively in use, in use
- * but passivated, or has been rendered invalid by being closed or terminated,
- * or by expiring.
- * </p>
- * <p>
- * Note that this service does <i>not</i> deal with authentication explicitly,
- * but may use a membership service provider to authenticate some
- * requests.
- * </p>
- */
-public interface SessionServiceInterface extends ApplicationService {
-    public static String NAME = "SessionService"; //$NON-NLS-1$
-
-    public static final String DEFAULT_MAX_SESSIONS = "5000"; //$NON-NLS-1$
-    public static final String DEFAULT_SESSION_EXPIRATION = "0"; //$NON-NLS-1$
-    
-    public static final String MAX_SESSIONS = "session.maxSessions"; //$NON-NLS-1$
-    public static final String SESSION_EXPIRATION = "session.expirationTimeInMilli"; //$NON-NLS-1$
-    
-    /**
-     * Create a session for the given user authenticating against the given <code>Credentials</code>.
-     */
-    public MetaMatrixSessionInfo createSession(String userName,
-                                               Credentials credentials,
-                                               Serializable trustedToken,
-                                               String applicationName,
-                                               Properties properties)
-            throws MetaMatrixAuthenticationException, SessionServiceException;
-
-    /**
-     * Closes the specified session.
-     *
-     * @param sessionID The MetaMatrixSessionID identifying user's session
-     * to be closed
-     * @throws InvalidSessionException If sessionID identifies an invalid
-     * session
-     * @throws SessionServiceException
-     */
-    void closeSession(MetaMatrixSessionID sessionID) throws InvalidSessionException;
-
-    /**
-     * Terminates the specified session.  This is an administrative action.
-     *
-     * @param terminatedSessionID The MetaMatrixSessionID identifying user's session
-     * to be terminated
-     * @param adminSessionID The session id identifying session of administrator
-     * @throws InvalidSessionException If terminatedSessionID identifies an invalid
-     * session
-     * @throws AuthorizationException if the caller denoted by <code>adminSessionID</code>
-     * does not have authority to terminate the <code>terminatedSessionID</code> session
-     * @throws SessionServiceException
-     */
-    boolean terminateSession(MetaMatrixSessionID terminatedSessionID, MetaMatrixSessionID adminSessionID);
-
-    /**
-     * Get the collection of active user sessions on the system.
-     * @return The collection of MetaMatrixSessionInfo objects of active users on
-     * the system - possibly empty, never null.
-     */
-    Collection<MetaMatrixSessionInfo> getActiveSessions() throws SessionServiceException;
-
-    /**
-     * Get the number of active user sessions on the system.
-     * @return int
-     */
-    int getActiveSessionsCount() throws SessionServiceException;
-
-    /**
-     * Returns a MetaMatrixPrincipal object describing the owner (user) of the
-     * indicated session.
-     * @param sessionID MetaMatrixSessionID representing the session
-     * @return MetaMatrixPrincipal object describing the owner of the
-     * indicated session.
-     */
-    MetaMatrixPrincipal getPrincipal(MetaMatrixSessionID sessionID)
-    throws InvalidSessionException, SessionServiceException;
-
-    /**
-     * This method is intended to verify that the session is valid, and, if
-     * need be, set the session in an active state, ready to be used.
-     * @param sessionID MetaMatrixSessionID representing the session
-     * @return SessionToken object identifying the session
-     * @throws InvalidSessionException If sessionID identifies an invalid
-     * session
-     * @throws SessionServiceException
-     */
-    MetaMatrixSessionInfo validateSession(MetaMatrixSessionID sessionID)
-    throws InvalidSessionException, SessionServiceException;
-    
-    /**
-     * Get all <code>MetaMatrixSessionID</code>s that are in the ACTIVE state
-     * and currently logged in to a VDB.
-     * @param VDBName The name of the VDB.
-     * @param VDBVersion The version of the VDB.
-     * @throws SessionServiceException when transaction with database fails or unexpected exception happens
-     */
-    Collection<MetaMatrixSessionInfo> getSessionsLoggedInToVDB(String VDBName, String VDBVersion)
-    throws SessionServiceException;
-
-    /**
-     * Periodically called by the client to indicate the client is still alive.
-     *
-     * @param sessionID - identifies the client
-     */
-    public void pingServer(MetaMatrixSessionID sessionID) throws InvalidSessionException;
-    
-    /**
-     * Register a session listener
-     * @param listener
-     */
-    public void register(SessionListener listener);
-    
-    public void setLocalSession(MetaMatrixSessionID sessionID);
-    
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SuccessfulAuthenticationToken.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SuccessfulAuthenticationToken.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/SuccessfulAuthenticationToken.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.
- */
-
-/*
- * Date: Dec 1, 2003
- * Time: 1:26:57 PM
- */
-package com.metamatrix.platform.security.api.service;
-
-import java.io.Serializable;
-
-import com.metamatrix.platform.security.api.SecurityMessagesKeys;
-import com.metamatrix.platform.security.api.SecurityPlugin;
-
-/**
- * SuccessfulAuthenticationToken.
- *
- * <p>Marker indicating successful authentication attempt.  Membership SPI
- * domain implementations should wrap the <code>Serializable</code> payload
- * in an instance of this class to signify to the Membgership service that
- * the domian successfully authenticated the given payload token.</p>
- * 
- * <p>As well as providing a holder for the <code>Serializable</code> payload,
- * which may have been augmented or replaced by the authenticating membership
- * domain, this class provides a holder for the user name of the authenticated
- * user that may be used in the MetaMatrix system for such things as session
- * tracking and authorization policies.</p>
- * 
- * <p>This wrapper class will not be exposed outside of the Membership framework.</p>
- */
-public final class SuccessfulAuthenticationToken implements AuthenticationToken {
-    private Serializable payload;
-    private String username;
-    private String domainName;
-
-    /**
-     * SuccessfulAuthenticationToken
-     * 
-     * <p>Indicate that successful user authentication has occurred.</p>
-     * 
-     * <p>MetaMatrix must know the user name of every user connected to the system.
-     * In particular, when MetaMatrix authorization policies (entitlements) are
-     * created, the users and groups that are assigned to these policies come from
-     * the membership domain.</p>
-     *
-     * @param payload The successfully authenticated token. May be <code>null</code>.
-     * @param username The username of the <i>authenticated</i> user
-     * exactly as it is known by the authenticating membership domain. May <b>not</b>
-     * be <code>null</code>.
-     */
-    public SuccessfulAuthenticationToken(final Serializable payload, final String username) {
-        if (username == null || username.trim().length() == 0) {
-            throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0061));
-        }
-        this.payload = payload;
-        this.username = username;
-    }
-
-    /**
-     * Get the payload token that has been successfully authenticated by a
-     * membership domain.
-     * @return The successfully authenticated token unmodified.
-     */
-    public Serializable getPayload() {
-        return payload;
-    }
-
-    /**
-     * Get the <b>exact</b> username of the authenticated user as it
-     * is known to the authenticating membership domain.
-     * <p><b>Will be <code>null</code> if the user was <b>not</b>
-     * authenticated. </b></p>
-     * @return The username (including case) of this authenticated
-     * user exactly as it is known by the authenticating membership domain.
-     * @since 5.0
-     */
-    public String getUserName() {
-        return username;
-    }
-
-    /**
-     * The attempt to authenticate the given payload was successful.
-     *
-     * @return <code>true</code> - always.
-     */
-    public boolean isAuthenticated() {
-        return true;
-    }
-    
-    public String getDomainName() {
-        return domainName;
-    }
-    
-    public void setDomainName(String domainName) {
-        this.domainName = domainName;
-    }
-}

Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -44,7 +44,6 @@
 import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.function.FunctionDescriptor;
 import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
 import com.metamatrix.query.function.metadata.FunctionMethod;
 import com.metamatrix.query.processor.ProcessorDataManager;
 import com.metamatrix.query.sql.LanguageObject;
@@ -640,8 +639,7 @@
 	    } 
 	    
 		// Execute function
-		FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
-		Object result = library.invokeFunction(fd, values);
+		Object result = fd.invokeFunction(values);
 		return result;        
 	}
 	

Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/SecurityFunctionEvaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/SecurityFunctionEvaluator.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/SecurityFunctionEvaluator.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,6 +29,6 @@
     public static final String ADMIN_ROLE = "admin"; //$NON-NLS-1$
     public static final String DATA_ROLE = "data"; //$NON-NLS-1$
 
-    boolean hasRole(String connectionID, String roleType, String roleName) throws MetaMatrixComponentException;
+    boolean hasRole(String roleType, String roleName) throws MetaMatrixComponentException;
     
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,11 +23,21 @@
 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.core.util.Assertion;
+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
@@ -36,6 +46,8 @@
  */
 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;
@@ -199,4 +211,68 @@
         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());
+		}
+	}    
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,9 +24,11 @@
 
 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.sql.ReservedWords;
 import com.metamatrix.query.function.metadata.*;
 
 /**
@@ -169,7 +171,7 @@
 				str.append(", "); //$NON-NLS-1$
 			} else {
 				str.append(" "); //$NON-NLS-1$
-				str.append(ReservedWords.AS);
+				str.append(SQLReservedWords.AS);
 				str.append(" "); //$NON-NLS-1$
 			}	
 			str.append(inputParamNames.get(1));

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -46,10 +46,8 @@
  * functions are available, resolve function signatures, and invoke system
  * and user-defined functions.
  */
-public class FunctionLibrary {
-	
-	private static final boolean ALLOW_NAN_INFINITY = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.allowNanInfinity", false); //$NON-NLS-1$
-	
+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$
@@ -98,17 +96,16 @@
     // Function tree for system functions (never reloaded)
     private FunctionTree systemFunctions;
 
-    // Function tree for user-defined functions (reloadable)
+    // Function tree for user-defined functions
     private FunctionTree userFunctions;
 
 	/**
 	 * Construct the function library.  This should be called only once by the
 	 * FunctionLibraryManager.
 	 */
-	FunctionLibrary() {
-        // Put empty trees here to avoid null checks throughout the class
-        systemFunctions = new FunctionTree(Collections.EMPTY_LIST);
-        userFunctions = new FunctionTree(Collections.EMPTY_LIST);
+	public FunctionLibrary(FunctionTree systemFuncs, FunctionTree userFuncs) {
+        systemFunctions = systemFuncs;
+       	userFunctions = userFuncs;
 	}
 
     /**
@@ -156,33 +153,6 @@
         return form;
     }
 
-    /**
-     * Add the system functions to the library.  This should be done
-     * exactly once by the FunctionLibraryManager.
-     * @param source System metadata source
-     */
-    void setSystemFunctions(FunctionMetadataSource source) {
-        this.systemFunctions = new FunctionTree(source);
-    }
-
-    /**
-     * Replace the existing set of reloadable functions with a new set.  This
-     * is called by the FunctionLibraryManager every time it reloads the
-     * reloadable sources.
-     * @param sources Collection of {@link FunctionMetadataSource} objects
-     */
-    void replaceReloadableFunctions(Collection sources) {
-        // Build new function tree
-        FunctionTree reloadedFunctions = new FunctionTree(sources);
-
-        // Switch to new user-defined functions - this is not synchronized
-        // because it is merely an object reference change.  There is no
-        // way for other code to get part of the old tree and part of the new
-        // tree - they will get either one or the other.  The old tree is
-        // dropped.
-        this.userFunctions = reloadedFunctions;
-    }
-
 	/**
 	 * Find a function descriptor given a name and the types of the arguments.
 	 * This method matches based on case-insensitive function name and
@@ -344,84 +314,6 @@
     }
 
 	/**
-	 * 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(FunctionDescriptor fd, Object[] values)
-		throws InvalidFunctionException, FunctionExecutionException {
-
-        if(fd == null) {
-            throw new InvalidFunctionException(ErrorMessageKeys.FUNCTION_0001, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0001, fd));
-        }
-        
-        if (!fd.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 = fd.getInvocationMethod();
-        if(method == null) {
-            FunctionDescriptor localDescriptor = findFunction(fd.getName(), fd.getTypes());
-            if(localDescriptor == null) {
-                throw new InvalidFunctionException(ErrorMessageKeys.FUNCTION_0001, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0001, fd));
-            }
-
-            // Get local invocation method, which should never be null
-            method = localDescriptor.getInvocationMethod();
-            if (method == null){
-                throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0002, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0002, localDescriptor.getName()));
-            }
-        }
-        
-        if (fd.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, fd.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, fd.getName())); //$NON-NLS-1$
-	            	}
-	            }
-        	}
-            result = DataTypeManager.convertToRuntimeType(result);
-            result = DataTypeManager.transformValue(result, fd.getReturnType());
-            return result;
-        } catch(InvocationTargetException e) {
-            throw new FunctionExecutionException(e.getTargetException(), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, fd.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());
-		}
-	}
-
-	/**
 	 * 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.

Deleted: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibraryManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibraryManager.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibraryManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,152 +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.Iterator;
-import java.util.List;
-
-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;
-
-/**
- * Factory to obtain the local FunctionLibrary and register sources of function metadata.
- */
-public class FunctionLibraryManager {
-
-	// Reference to singleton FunctionLibrary
-	private static FunctionLibrary LIB;
-
-	// List of reloadable (user-defined) sources of metadata
-    private static List RELOADABLE_SOURCES;
-
-    // Static initializer
-    static {
-        // Create the function library instance
-        LIB = new FunctionLibrary();
-
-        // Create the system source and add it to the source list
-        FunctionMetadataSource systemSource = new SystemSource();
-
-        // Load the system source
-        LIB.setSystemFunctions(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));
-		}
-
-        // Initialize the reloadable sources
-        RELOADABLE_SOURCES = new ArrayList();
-
-    }
-
-    /**
-     * Can't construct - just a factory
-     */
-	private FunctionLibraryManager() {}
-
-    /**
-     * Factory method to obtain a reference to a function.
-     * @return Function library to find and invoke functions
-     */
-	public static FunctionLibrary getFunctionLibrary() {
-		return LIB;
-	}
-
-    /**
-     * Register a new source of function metadata.  The method
-     * {@link #reloadSources} will be called as a result.
-     * @param source A new source of function metadata
-     * @return Report of any invalid FunctionMethod objects
-     */
-    public static synchronized ActivityReport registerSource(FunctionMetadataSource source) {
-        // Add the reloadable source
-        RELOADABLE_SOURCES.add(source);
-
-        // Reload
-        return reloadSources();
-    }
-
-    /**
-     * Register a new source of function metadata.  The method
-     * {@link #reloadSources} will be called as a result.
-     * @param source A new source of function metadata
-     * @return Report of any invalid FunctionMethod objects
-     */
-    public static synchronized ActivityReport deregisterSource(FunctionMetadataSource source) {
-        // Add the reloadable source
-        RELOADABLE_SOURCES.remove(source);
-
-        // Reload
-        return reloadSources();
-    }
-    
-    /**
-     * Reload all sources.  All valid functions in the registered function sources
-     * are reloaded.  Any invalid functions are noted in the report.
-     * @return Report of any invalid FunctionMethod objects.
-     */
-    public static synchronized ActivityReport reloadSources() {
-        // Create activity report
-        ActivityReport report = new ActivityReport("Function Validation"); //$NON-NLS-1$
-
-        // Reload and re-validate all metadata sources
-        Iterator iter = RELOADABLE_SOURCES.iterator();
-        while(iter.hasNext()) {
-        	FunctionMetadataSource source = (FunctionMetadataSource) iter.next();
-
-        	// Reload - even though it is reload it is never called
-        	// other than the register methods, so it may of no use.
-        	// if need it we will get this back.
-        	//source.reloadMethods();
-
-        	// Validate
-        	validateSource(source, report);
-        }
-
-        // Upload all new reloadable functions into function library in bulk
-        LIB.replaceReloadableFunctions(RELOADABLE_SOURCES);
-
-        // Return report of failures during reload
-        return report;
-    }
-
-    /**
-     * 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);
-    }
-}

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,10 +22,10 @@
 
 package com.metamatrix.query.function;
 
-import java.io.IOException;
-import java.io.InputStream;
 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 
@@ -42,7 +42,7 @@
      * always return the newest information available.
      * @return Collection of FunctionMethod objects
      */
-    Collection getFunctionMethods();
+    Collection<FunctionMethod> getFunctionMethods();
     
     /**
      * This method determines where the invocation classes specified in the 
@@ -52,7 +52,4 @@
      * @throws ClassNotFoundException If class could not be found
      */
     Class getInvocationClass(String className) throws ClassNotFoundException;    
-    
-    
-    void loadFunctions(InputStream source) throws IOException;
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -36,13 +36,14 @@
 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.sql.ReservedWords;
 import com.metamatrix.query.util.CommandContext;
 import com.metamatrix.query.util.ErrorMessageKeys;
 
@@ -449,7 +450,7 @@
 		cal.setTime(timestamp);
 
 		// case of interval = 1, fractional seconds (nanos), don't go to branches of addField()
-		if (intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_FRAC_SECOND)) {
+		if (intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
 			int countValue = count.intValue();
 			nanos += countValue;
 
@@ -487,23 +488,23 @@
 	private static void addField(String interval, Integer count, Calendar cal) {
 		int countValue = count.intValue();
 
-        if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_FRAC_SECOND)) {
+        if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
             //nano seconds - should never get into this branch
-        } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_SECOND)) {
+        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_SECOND)) {
             cal.add(Calendar.SECOND, countValue);
-        } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_MINUTE)) {
+        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MINUTE)) {
             cal.add(Calendar.MINUTE, countValue);
-        } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_HOUR)) {
+        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_HOUR)) {
             cal.add(Calendar.HOUR_OF_DAY, countValue);
-        } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_DAY)) {
+        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_DAY)) {
             cal.add(Calendar.DAY_OF_YEAR, countValue);
-        } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_WEEK)) {
+        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_WEEK)) {
             cal.add(Calendar.WEEK_OF_YEAR, countValue);
-        } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_MONTH)) {
+        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MONTH)) {
             cal.add(Calendar.MONTH, countValue);
-        } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_QUARTER)) {
+        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_QUARTER)) {
             cal.add(Calendar.MONTH, countValue*3);
-        } else if(interval.equalsIgnoreCase(ReservedWords.SQL_TSI_YEAR)) {
+        } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_YEAR)) {
             cal.add(Calendar.YEAR, countValue);
         }
 	}
@@ -525,25 +526,25 @@
         long tsDiff = ts2 - ts1;
 
         long count = 0;
-        if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_FRAC_SECOND)) {
+        if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
             count = tsDiff;
         } else { 
         	tsDiff = tsDiff / 1000000; //convert to milliseconds
-            if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_SECOND)) {
+            if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_SECOND)) {
                 count = tsDiff / 1000;
-            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_MINUTE)) {
+            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MINUTE)) {
                 count = (tsDiff / 1000) / 60;
-            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_HOUR)) {
+            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_HOUR)) {
                 count = (tsDiff / 1000) / (60*60);
-            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_DAY)) {
+            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_DAY)) {
                 count = (tsDiff / 1000) / (60*60*24);
-            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_WEEK)) {
+            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_WEEK)) {
                 count = (tsDiff / 1000) / (60*60*24*7);
-            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_MONTH)) {
+            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MONTH)) {
                 count = (tsDiff / 1000) / (60*60*24*30);
-            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_QUARTER)) {
+            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_QUARTER)) {
                 count = (tsDiff / 1000) / (60*60*24*91);
-            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_YEAR)) {
+            } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_YEAR)) {
                 count = (tsDiff / 1000) / (60*60*24*365);
             }    
         }

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -57,7 +57,7 @@
  * are concerned with function metadata EXCEPT {@link #getFunction} which is used to find a function
  * for execution.
  */
-class FunctionTree {
+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);
@@ -83,7 +83,7 @@
      * Construct a new tree with the given source of function metadata.
      * @param source The metadata source
      */
-    FunctionTree(FunctionMetadataSource source) {
+    public FunctionTree(FunctionMetadataSource source) {
         // Load data structures
         addSource(source);
     }

Copied: trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java (from rev 1900, branches/JCA/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java	                        (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,71 @@
+/*
+ * 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);
+    }
+}

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,63 +22,24 @@
 
 package com.metamatrix.query.function;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.util.Collection;
 
-import com.metamatrix.common.classloader.PostDelegatingClassLoader;
-import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
-import com.metamatrix.query.function.metadata.FunctionMetadataReader;
 import com.metamatrix.query.function.metadata.FunctionMethod;
 
 
 public class UDFSource implements FunctionMetadataSource {
 	
-    private URL[] classpath = null;
-    private ClassLoader classLoader = null;
     private Collection <FunctionMethod> methods = null;
     
-    public UDFSource(URL url) throws IOException {
-    	loadFunctions(url.openStream());
+    public UDFSource(Collection <FunctionMethod> methods) {
+    	this.methods = methods;
     }    
     
-    public UDFSource(URL url, URL[] classpath) throws IOException{
-        this.classpath = classpath;
-        loadFunctions(url.openStream());
-    }
-    
-    public UDFSource(InputStream udfStream, URL[] classpath) throws IOException {
-        this.classpath = classpath;
-        loadFunctions(udfStream);
-    }
-    
-    public UDFSource(InputStream udfStream, ClassLoader classloader) throws IOException {
-        this.classLoader = classloader;
-        loadFunctions(udfStream);
-    }    
-    
-    
     public Collection getFunctionMethods() {
         return this.methods;
     }
 
     public Class getInvocationClass(String className) throws ClassNotFoundException {
-        // If no classpath is specified then use the default classpath
-        if (this.classLoader == null && (classpath == null || classpath.length == 0)) {
-            return Class.forName(className);
-        }
-        
-        // If the class loader is not created for the UDF functions then create 
-        // one and cache it.
-        if (classLoader == null) {
-            classLoader = new PostDelegatingClassLoader(this.classpath, Thread.currentThread().getContextClassLoader(), new MetaMatrixURLStreamHandlerFactory());                        
-        }
-        
-        return classLoader.loadClass(className);
+        return Class.forName(className);
     }
-
-    public void loadFunctions(InputStream in) throws IOException{
-        methods = FunctionMetadataReader.loadFunctionMethods(in);
-    }  
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/source/SecuritySystemFunctions.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SecuritySystemFunctions.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/source/SecuritySystemFunctions.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -32,8 +32,6 @@
 
     public static boolean hasRole(CommandContext context, Object roleType, Object roleName) throws FunctionExecutionException {
         
-        String connectionId = context.getConnectionID();
-        
         SecurityFunctionEvaluator eval = context.getSecurityFunctionEvaluator();
         
         if (eval == null) {
@@ -41,7 +39,7 @@
         }
         
         try {
-            return eval.hasRole(connectionId, (String)roleType, (String)roleName);
+            return eval.hasRole((String)roleType, (String)roleName);
         } catch (MetaMatrixComponentException err) {
             throw new FunctionExecutionException(err, err.getMessage());
         }

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -952,12 +952,4 @@
     public Class getInvocationClass(String className) throws ClassNotFoundException {
         return Class.forName(className);    
     }
-    
-    /**
-     * Never need to reload - do nothing.
-     */
-    public void loadFunctions(InputStream source) throws IOException{
-    }
-    
-    
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadata.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadata.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadata.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,6 +29,7 @@
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.query.function.FunctionLibrary;
 import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.mapping.xml.MappingNode;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -514,5 +515,10 @@
 			throws MetaMatrixComponentException, QueryMetadataException {
 		return false;
 	}
+
+	@Override
+	public FunctionLibrary getFunctionLibrary() {
+		return null;
+	}
     
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadataWrapper.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadataWrapper.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,6 +28,7 @@
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.query.function.FunctionLibrary;
 import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.mapping.xml.MappingNode;
 
@@ -362,4 +363,9 @@
 		return actualMetadata.isScalarGroup(groupID);
 	}
 
+	@Override
+	public FunctionLibrary getFunctionLibrary() {
+		return actualMetadata.getFunctionLibrary();
+	}
+
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/metadata/QueryMetadataInterface.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/QueryMetadataInterface.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/metadata/QueryMetadataInterface.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,12 +22,13 @@
 
 package com.metamatrix.query.metadata;
 
-import java.util.*;
 import java.util.Collection;
 import java.util.List;
+import java.util.Properties;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.query.function.FunctionLibrary;
 import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.mapping.xml.MappingNode;
 
@@ -675,4 +676,5 @@
     boolean isScalarGroup(Object groupID) 
     	throws MetaMatrixComponentException, QueryMetadataException;
 
+    FunctionLibrary getFunctionLibrary();
 }

Modified: 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-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -169,7 +169,7 @@
                         Object modelID = metadata.getModelID(groupID);
                         String modelName = metadata.getFullName(modelID);
                         if (metadata.isVirtualGroup(groupID)) {
-                        	InsertPlanExecutionNode ipen = new InsertPlanExecutionNode(getID());
+                        	InsertPlanExecutionNode ipen = new InsertPlanExecutionNode(getID(), metadata);
                         	ipen.setProcessorPlan((ProcessorPlan)node.getFirstChild().getProperty(Info.PROCESSOR_PLAN));
                         	ipen.setReferences(insert.getValues());
                         	processNode = ipen;

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,6 +28,7 @@
 import java.util.List;
 
 import org.teiid.connector.api.ConnectorCapabilities.SupportedJoinCriteria;
+import org.teiid.connector.language.SQLReservedWords;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -38,7 +39,6 @@
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
 import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.JoinType;
 import com.metamatrix.query.sql.lang.SetQuery.Operation;
 import com.metamatrix.query.sql.symbol.AggregateSymbol;
@@ -145,7 +145,7 @@
 
         // Check particular function
         String func = aggregate.getAggregateFunction();
-        if(func.equals(ReservedWords.COUNT)) {
+        if(func.equals(SQLReservedWords.COUNT)) {
             if(aggregate.getExpression() == null) {
                 if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_COUNT_STAR)) {
                     return false;
@@ -155,19 +155,19 @@
                     return false;
                 }                
             }
-        } else if(func.equals(ReservedWords.SUM)) {
+        } else if(func.equals(SQLReservedWords.SUM)) {
             if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_SUM)) {
                 return false;
             }
-        } else if(func.equals(ReservedWords.AVG)) {
+        } else if(func.equals(SQLReservedWords.AVG)) {
             if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_AVG)) {
                 return false;
             }
-        } else if(func.equals(ReservedWords.MIN)) {
+        } else if(func.equals(SQLReservedWords.MIN)) {
             if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_MIN)) {
                 return false;
             }
-        } else if(func.equals(ReservedWords.MAX)) {
+        } else if(func.equals(SQLReservedWords.MAX)) {
             if(! caps.supportsCapability(Capability.QUERY_AGGREGATES_MAX)) {
                 return false;
             }

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -78,7 +78,7 @@
         while(current != endNode) { 
             
             // Make translations as defined in node in each current node
-            convertNode(current, oldGroup, newGroups, symbolMap);
+            convertNode(current, oldGroup, newGroups, symbolMap, metadata);
             
             PlanNode parent = current.getParent(); 
             
@@ -159,7 +159,7 @@
     // symbols.  In that case, some additional work can be done because we can assume 
     // that an oldElement isn't being replaced by an expression using elements from 
     // multiple new groups.  
-    static void convertNode(PlanNode node, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap)
+    static void convertNode(PlanNode node, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata)
         throws QueryPlannerException {
 
         // Update groups for current node   
@@ -202,7 +202,7 @@
         
         if(type == NodeConstants.Types.SELECT) { 
             Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
-            crit = convertCriteria(crit, symbolMap);
+            crit = convertCriteria(crit, symbolMap, metadata);
             node.setProperty(NodeConstants.Info.SELECT_CRITERIA, crit);
             
             if (!singleMapping) {
@@ -222,7 +222,7 @@
             List<Criteria> joinCrits = (List<Criteria>) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
             if(joinCrits != null && !joinCrits.isEmpty()) {
             	Criteria crit = new CompoundCriteria(joinCrits);
-            	crit = convertCriteria(crit, symbolMap);
+            	crit = convertCriteria(crit, symbolMap, metadata);
             	if (crit instanceof CompoundCriteria) {
             		node.setProperty(NodeConstants.Info.JOIN_CRITERIA, ((CompoundCriteria)crit).getCriteria());
             	} else {
@@ -274,14 +274,14 @@
         return expression;
     }   
         
-    static Criteria convertCriteria(Criteria criteria, final Map symbolMap)
+    static Criteria convertCriteria(Criteria criteria, final Map symbolMap, QueryMetadataInterface metadata)
         throws QueryPlannerException {
 
         ExpressionMappingVisitor.mapExpressions(criteria, symbolMap);
         
         // Simplify criteria if possible
         try {
-            return QueryRewriter.rewriteCriteria(criteria, null, null, null);
+            return QueryRewriter.rewriteCriteria(criteria, null, null, metadata);
         } catch(QueryValidatorException e) {
             throw new QueryPlannerException(e, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0023, criteria));
         }

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -194,7 +194,7 @@
             }
             PlanNode limit = NodeEditor.findNodePreOrder(node, NodeConstants.Types.TUPLE_LIMIT, NodeConstants.Types.SET_OP);
             if (limit != null) {
-                processLimit(limit, unionCommand);
+                processLimit(limit, unionCommand, metadata);
             }
             int count = 0;
             for (PlanNode child : setOpNode.getChildren()) {
@@ -219,7 +219,7 @@
 		query.setFrom(new From());
 		buildQuery(accessRoot, node, query, metadata, capFinder);
 		if (query.getCriteria() instanceof CompoundCriteria) {
-            query.setCriteria(QueryRewriter.optimizeCriteria((CompoundCriteria)query.getCriteria()));
+            query.setCriteria(QueryRewriter.optimizeCriteria((CompoundCriteria)query.getCriteria(), metadata));
         }
 		if (!CapabilitiesUtil.useAnsiJoin(RuleRaiseAccess.getModelIDFromAccess(accessRoot, metadata), metadata, capFinder)) {
 			simplifyFromClause(query);
@@ -334,7 +334,7 @@
             }
             case NodeConstants.Types.TUPLE_LIMIT:
             {
-                processLimit(node, query);
+                processLimit(node, query, metadata);
                 break;
             }
         }        
@@ -371,7 +371,7 @@
 	}
 
     private void processLimit(PlanNode node,
-                              QueryCommand query) {
+                              QueryCommand query, QueryMetadataInterface metadata) {
         Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
         if (limit != null) {
             if (query.getLimit() != null) {
@@ -385,7 +385,7 @@
         if (offset != null) {
             if (query.getLimit() != null) {
                 Expression oldoffset = query.getLimit().getOffset();
-                query.getLimit().setOffset(RulePushLimit.getSum(offset, oldoffset)); 
+                query.getLimit().setOffset(RulePushLimit.getSum(offset, oldoffset, metadata.getFunctionLibrary())); 
             } else {
                 query.setLimit(new Limit(offset, null));
             }

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -93,7 +93,7 @@
             return plan;
         }
         
-        if (tryToCopy(plan, new Set[2])) {
+        if (tryToCopy(plan, new Set[2], metadata)) {
             //Push any newly created criteria nodes and try to copy them afterwards
             rules.push(RuleConstants.COPY_CRITERIA);
             rules.push(RuleConstants.PUSH_NON_JOIN_CRITERIA);
@@ -123,13 +123,14 @@
                                  Map tgtMap,
                                  List joinCriteria,
                                  Set combinedCriteria,
-                                 boolean checkForGroupReduction) {
+                                 boolean checkForGroupReduction,
+                                 QueryMetadataInterface metadata) {
         int startGroups = GroupsUsedByElementsVisitor.getGroups(crit).size();
         
         Criteria tgtCrit = (Criteria) crit.clone();
         
         try {
-            tgtCrit = FrameUtil.convertCriteria(tgtCrit, tgtMap);
+            tgtCrit = FrameUtil.convertCriteria(tgtCrit, tgtMap, metadata);
         } catch (QueryPlannerException err) {
             LogManager.logDetail(LogConstants.CTX_QUERY_PLANNER, err, "Could not remap target criteria in RuleCopyCriteria"); //$NON-NLS-1$
             return false;
@@ -164,7 +165,7 @@
      * @param node
      * @return true if criteria has been created
      */
-    private boolean tryToCopy(PlanNode node, Set[] criteriaInfo) {
+    private boolean tryToCopy(PlanNode node, Set[] criteriaInfo, QueryMetadataInterface metadata) {
         boolean changedTree = false;
         
         if (node == null) {
@@ -176,14 +177,14 @@
             JoinType jt = (JoinType)node.getProperty(NodeConstants.Info.JOIN_TYPE);
             
             if (jt == JoinType.JOIN_FULL_OUTER) {
-                return visitChildern(node, criteriaInfo, changedTree);
+                return visitChildern(node, criteriaInfo, changedTree, metadata);
             }
             
             Set[] leftChildCriteria = new Set[2];
             Set[] rightChildCriteria = new Set[2];
             
-            changedTree |= tryToCopy(node.getFirstChild(), leftChildCriteria);
-            changedTree |= tryToCopy(node.getLastChild(), rightChildCriteria);
+            changedTree |= tryToCopy(node.getFirstChild(), leftChildCriteria, metadata);
+            changedTree |= tryToCopy(node.getLastChild(), rightChildCriteria, metadata);
 
             List joinCrits = (List) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
             Set combinedCriteria = null;
@@ -214,11 +215,11 @@
     
                 List newJoinCrits = new LinkedList();
     
-                changedTree = createCriteriaFromSelectCriteria(changedTree, combinedCriteria, toCopy, srcToTgt, newJoinCrits);
+                changedTree = createCriteriaFromSelectCriteria(changedTree, combinedCriteria, toCopy, srcToTgt, newJoinCrits, metadata);
                 
                 srcToTgt = buildElementMap(allCriteria);
                             
-                changedTree = createCriteriaFromJoinCriteria(changedTree, joinCrits, combinedCriteria, srcToTgt, newJoinCrits);
+                changedTree = createCriteriaFromJoinCriteria(changedTree, joinCrits, combinedCriteria, srcToTgt, newJoinCrits, metadata);
                 
                 joinCrits.addAll(newJoinCrits);
             }
@@ -235,7 +236,7 @@
             return changedTree;
         }
         
-        changedTree = visitChildern(node, criteriaInfo, changedTree);
+        changedTree = visitChildern(node, criteriaInfo, changedTree, metadata);
 
         //visit select nodes on the way back up
         switch (node.getType()) {
@@ -281,7 +282,8 @@
                                                    List joinCrits,
                                                    Set combinedCriteria,
                                                    Map srcToTgt,
-                                                   List newJoinCrits) {
+                                                   List newJoinCrits,
+                                                   QueryMetadataInterface metadata) {
         if (srcToTgt.size() == 0) {
             return changedTree;
         }
@@ -289,7 +291,7 @@
         while (i.hasNext()) {
             Criteria crit = (Criteria)i.next();
             
-            if (copyCriteria(crit, srcToTgt, newJoinCrits, combinedCriteria, true)) {
+            if (copyCriteria(crit, srcToTgt, newJoinCrits, combinedCriteria, true, metadata)) {
             	changedTree = true;
             	if (crit instanceof CompareCriteria) {
             		CompareCriteria cc = (CompareCriteria)crit;
@@ -317,14 +319,15 @@
                                                      Set combinedCriteria,
                                                      Set toCopy,
                                                      Map srcToTgt,
-                                                     List newJoinCrits) {
+                                                     List newJoinCrits,
+                                                     QueryMetadataInterface metadata) {
         if (srcToTgt.size() == 0) {
             return changedTree;
         }
         Iterator i = toCopy.iterator();
         while (i.hasNext()) {
             Criteria crit = (Criteria)i.next();
-            changedTree |= copyCriteria(crit, srcToTgt, newJoinCrits, combinedCriteria, false);            
+            changedTree |= copyCriteria(crit, srcToTgt, newJoinCrits, combinedCriteria, false, metadata);            
         }
         return changedTree;
     }
@@ -352,12 +355,13 @@
 
     private boolean visitChildern(PlanNode node,
                                   Set[] criteriaInfo,
-                                  boolean changedTree) {
+                                  boolean changedTree,
+                                  QueryMetadataInterface metadata) {
         if (node.getChildCount() > 0) {
             List children = node.getChildren();
             for (int i = 0; i < children.size(); i++) {
                 PlanNode childNode = (PlanNode)children.get(i);
-                changedTree |= tryToCopy(childNode, i==0?criteriaInfo:new Set[2]);
+                changedTree |= tryToCopy(childNode, i==0?criteriaInfo:new Set[2], metadata);
             }
         }
         return changedTree;

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -58,7 +58,7 @@
 
         // Merge chains
         for (PlanNode critNode : criteriaChains) {
-            mergeChain(critNode);
+            mergeChain(critNode, metadata);
         }
 
         return plan;
@@ -93,7 +93,7 @@
         }
     }
 
-    static void mergeChain(PlanNode chainRoot) {
+    static void mergeChain(PlanNode chainRoot, QueryMetadataInterface metadata) {
 
         // Remove all of chain except root, collect crit from each
         CompoundCriteria critParts = new CompoundCriteria();
@@ -115,7 +115,7 @@
 
         }
         
-        Criteria combinedCrit = QueryRewriter.optimizeCriteria(critParts);
+        Criteria combinedCrit = QueryRewriter.optimizeCriteria(critParts, metadata);
 
         if (isDependentSet) {
             chainRoot.setProperty(NodeConstants.Info.IS_DEPENDENT_SET, Boolean.TRUE);

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -35,6 +35,8 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.query.QueryPlannerException;
@@ -57,7 +59,6 @@
 import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.resolver.util.ResolverVisitor;
 import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.LanguageObject.Util;
 import com.metamatrix.query.sql.lang.CompareCriteria;
 import com.metamatrix.query.sql.lang.Criteria;
@@ -235,7 +236,7 @@
 		for (Expression expr : aggMap.values()) {
 			ExpressionMappingVisitor.mapExpressions(expr, projectedMap);
 		}
-		mapExpressions(groupNode.getParent(), aggMap);
+		mapExpressions(groupNode.getParent(), aggMap, metadata);
 	}
 
 	private boolean canPushGroupByToUnionChild(QueryMetadataInterface metadata,
@@ -350,14 +351,14 @@
         	if (pushdown) {
         		projectedViewSymbols.add(agg);
         	} else {
-        		if (agg.getAggregateFunction().equals(ReservedWords.COUNT)) {
+        		if (agg.getAggregateFunction().equals(SQLReservedWords.COUNT)) {
         			SearchedCaseExpression count = new SearchedCaseExpression(Arrays.asList(new IsNullCriteria(agg.getExpression())), Arrays.asList(new Constant(Integer.valueOf(0))));
         			count.setElseExpression(new Constant(Integer.valueOf(1)));
         			count.setType(DataTypeManager.DefaultDataClasses.INTEGER);
     				projectedViewSymbols.add(new ExpressionSymbol("stagedAgg", count)); //$NON-NLS-1$
         		} else { //min, max, sum
         			Expression ex = agg.getExpression();
-        			ex = ResolverUtil.convertExpression(ex, DataTypeManager.getDataTypeName(agg.getType()));
+        			ex = ResolverUtil.convertExpression(ex, DataTypeManager.getDataTypeName(agg.getType()), metadata);
         			projectedViewSymbols.add(new ExpressionSymbol("stagedAgg", ex)); //$NON-NLS-1$
         		}
         	}
@@ -500,7 +501,7 @@
 		} else {
 		    // if the source has no rows we need to insert a select node with criteria count(*)>0
 		    PlanNode selectNode = NodeFactory.getNewNode(NodeConstants.Types.SELECT);
-		    AggregateSymbol count = new AggregateSymbol("stagedAgg", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+		    AggregateSymbol count = new AggregateSymbol("stagedAgg", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
 		    aggregates.add(count); //consider the count aggregate for the push down call below
 		    selectNode.setProperty(NodeConstants.Info.SELECT_CRITERIA, new CompareCriteria(count, CompareCriteria.GT,
 		                                                                                   new Constant(new Integer(0))));
@@ -536,7 +537,7 @@
             try {
                 Set<AggregateSymbol> newAggs = new HashSet<AggregateSymbol>();
                 Map<AggregateSymbol, Expression> aggMap = buildAggregateMap(aggregates, metadata, newAggs);
-                mapExpressions(groupNode.getParent(), aggMap);
+                mapExpressions(groupNode.getParent(), aggMap, metadata);
                 aggregates.clear();
                 aggregates.addAll(newAggs);
             } catch (QueryResolverException err) {
@@ -668,27 +669,25 @@
             Expression newExpression = null;
 
             String aggFunction = partitionAgg.getAggregateFunction();
-            if (aggFunction.equals(ReservedWords.COUNT)) {
+            if (aggFunction.equals(SQLReservedWords.COUNT)) {
                 //COUNT(x) -> CONVERT(SUM(COUNT(x)), INTEGER)
-                AggregateSymbol newAgg = new AggregateSymbol("stagedAgg", ReservedWords.SUM, false, partitionAgg); //$NON-NLS-1$
+                AggregateSymbol newAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.SUM, false, partitionAgg); //$NON-NLS-1$
 
                 // Build conversion function to convert SUM (which returns LONG) back to INTEGER
                 Constant convertTargetType = new Constant(DataTypeManager.getDataTypeName(partitionAgg.getType()),
                                                           DataTypeManager.DefaultDataClasses.STRING);
-                Function convertFunc = new Function(FunctionLibrary.CONVERT, new Expression[] {
-                    newAgg, convertTargetType
-                });
+                Function convertFunc = new Function(FunctionLibrary.CONVERT, new Expression[] {newAgg, convertTargetType});
                 ResolverVisitor.resolveLanguageObject(convertFunc, metadata);
 
                 newExpression = convertFunc;  
                 nestedAggregates.add(partitionAgg);
-            } else if (aggFunction.equals(ReservedWords.AVG)) {
+            } else if (aggFunction.equals(SQLReservedWords.AVG)) {
                 //AVG(x) -> SUM(SUM(x)) / SUM(COUNT(x))
-                AggregateSymbol countAgg = new AggregateSymbol("stagedAgg", ReservedWords.COUNT, false, partitionAgg.getExpression()); //$NON-NLS-1$
-                AggregateSymbol sumAgg = new AggregateSymbol("stagedAgg", ReservedWords.SUM, false, partitionAgg.getExpression()); //$NON-NLS-1$
+                AggregateSymbol countAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.COUNT, false, partitionAgg.getExpression()); //$NON-NLS-1$
+                AggregateSymbol sumAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.SUM, false, partitionAgg.getExpression()); //$NON-NLS-1$
                 
-                AggregateSymbol sumSumAgg = new AggregateSymbol("stagedAgg", ReservedWords.SUM, false, sumAgg); //$NON-NLS-1$
-                AggregateSymbol sumCountAgg = new AggregateSymbol("stagedAgg", ReservedWords.SUM, false, countAgg); //$NON-NLS-1$
+                AggregateSymbol sumSumAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.SUM, false, sumAgg); //$NON-NLS-1$
+                AggregateSymbol sumCountAgg = new AggregateSymbol("stagedAgg", SQLReservedWords.SUM, false, countAgg); //$NON-NLS-1$
 
                 Function divideFunc = new Function("/", new Expression[] {sumSumAgg, sumCountAgg}); //$NON-NLS-1$
                 ResolverVisitor.resolveLanguageObject(divideFunc, metadata);
@@ -707,11 +706,11 @@
         return aggMap;
     }
     
-    static void mapExpressions(PlanNode node, Map<? extends Expression, ? extends Expression> exprMap) 
+    static void mapExpressions(PlanNode node, Map<? extends Expression, ? extends Expression> exprMap, QueryMetadataInterface metadata) 
     throws QueryPlannerException {
         
         while (node != null) {
-            FrameUtil.convertNode(node, null, null, exprMap);
+            FrameUtil.convertNode(node, null, null, exprMap, metadata);
             
             switch (node.getType()) {
                 case NodeConstants.Types.SOURCE:

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushLimit.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushLimit.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushLimit.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,7 +31,7 @@
 import com.metamatrix.api.exception.query.QueryPlannerException;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.FunctionLibrary;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
 import com.metamatrix.query.optimizer.relational.OptimizerRule;
@@ -120,7 +120,7 @@
             {
                 //combine the limits
                 Expression minLimit = getMinValue((Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT), (Expression)child.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT)); 
-                Expression offSet = getSum((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)child.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT)); 
+                Expression offSet = getSum((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)child.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), metadata.getFunctionLibrary()); 
                 
                 NodeEditor.removeChildNode(limitNode, child);
                 
@@ -142,7 +142,7 @@
                     PlanNode newLimit = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
                     Expression limit = (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
                     Expression offset = (Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT);
-                    newLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset));
+                    newLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset, metadata.getFunctionLibrary()));
                     grandChild.addAsParent(newLimit);
                     limitNodes.add(newLimit);
                 }
@@ -205,7 +205,7 @@
                 
                 // since we're pushing underneath the offset, we want enough rows to satisfy both the limit and the row offset
                 
-                pushedLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset)); 
+                pushedLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset, metadata.getFunctionLibrary())); 
                 
                 if (accessNode.getChildCount() == 0) {
                     accessNode.addFirstChild(pushedLimit);
@@ -224,7 +224,7 @@
      * @param limitNode
      * @param child
      */
-    static Expression getSum(Expression expr1, Expression expr2) {
+    static Expression getSum(Expression expr1, Expression expr2, FunctionLibrary functionLibrary) {
         if (expr1 == null) {
             return expr2;
         }
@@ -233,7 +233,7 @@
         }
         
         Function newExpr = new Function("+", new Expression[] {expr1, expr2}); //$NON-NLS-1$
-        newExpr.setFunctionDescriptor(FunctionLibraryManager.getFunctionLibrary().findFunction("+", new Class[] {DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER})); //$NON-NLS-1$
+        newExpr.setFunctionDescriptor(functionLibrary.findFunction("+", new Class[] {DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER})); //$NON-NLS-1$
         newExpr.setType(newExpr.getFunctionDescriptor().getReturnType());
         return newExpr;
     }

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -112,7 +112,7 @@
                 switch (sourceNode.getType()) {
                     case NodeConstants.Types.SOURCE:
                     {
-                        moved = pushAcrossFrame(sourceNode, critNode);
+                        moved = pushAcrossFrame(sourceNode, critNode, metadata);
                         break;
                     }
                     case NodeConstants.Types.JOIN:
@@ -255,7 +255,7 @@
         NodeEditor.removeChildNode(critNode.getParent(), critNode);
         destination.addAsParent(critNode);
         if (groupSelects && destination == sourceNode) {
-        	RuleMergeCriteria.mergeChain(critNode);
+        	RuleMergeCriteria.mergeChain(critNode, metadata);
         }
 	}
 
@@ -331,7 +331,7 @@
 		return sourceNode;
 	}
 
-	boolean pushAcrossFrame(PlanNode sourceNode, PlanNode critNode)
+	boolean pushAcrossFrame(PlanNode sourceNode, PlanNode critNode, QueryMetadataInterface metadata)
 		throws QueryPlannerException {
         
         //ensure that the criteria can be pushed further
@@ -347,7 +347,7 @@
             	//only allow criteria without subqueires - node cloning doesn't allow for the proper creation of 
             	//multiple nodes with the same subqueries
                 if (child == sourceNode.getFirstChild() && critNode.getSubqueryContainers().isEmpty()) {
-                    return pushAcrossSetOp(critNode, child);
+                    return pushAcrossSetOp(critNode, child, metadata);
                 } 
                 //this could be an access node in the middle of the source and set op,
                 //it is an odd case that is not supported for now
@@ -356,7 +356,7 @@
         }
         
 		// See if we can move it towards the SOURCE node
-        return moveNodeAcrossFrame(critNode, sourceNode);
+        return moveNodeAcrossFrame(critNode, sourceNode, metadata);
 	}
 
 	/**
@@ -376,7 +376,7 @@
 		return true;
 	}
 
-	boolean moveNodeAcrossFrame(PlanNode critNode, PlanNode sourceNode)
+	boolean moveNodeAcrossFrame(PlanNode critNode, PlanNode sourceNode, QueryMetadataInterface metadata)
 		throws QueryPlannerException {
 
 		Assertion.isNotNull(critNode.getParent());
@@ -393,7 +393,7 @@
         
         SymbolMap symbolMap = (SymbolMap) sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
         
-        if (!createConvertedSelectNode(critNode, sourceNode.getGroups().iterator().next(), projectNode, symbolMap)) {
+        if (!createConvertedSelectNode(critNode, sourceNode.getGroups().iterator().next(), projectNode, symbolMap, metadata)) {
             return false;
         }
 		
@@ -479,7 +479,7 @@
 	    return copyNode;
 	}
 
-	boolean pushAcrossSetOp(PlanNode critNode, PlanNode setOp)
+	boolean pushAcrossSetOp(PlanNode critNode, PlanNode setOp, QueryMetadataInterface metadata)
 		throws QueryPlannerException {
         
         // Find source node above union and grab the symbol map
@@ -505,7 +505,7 @@
 	        }
 		    
 			// Move the node
-			if(createConvertedSelectNode(critNode, virtualGroup, projectNode, childMap)) {
+			if(createConvertedSelectNode(critNode, virtualGroup, projectNode, childMap, metadata)) {
                 movedCount++;
             }
 			
@@ -535,7 +535,8 @@
     private boolean createConvertedSelectNode(PlanNode critNode,
     							   GroupSymbol sourceGroup,
                                    PlanNode projectNode,
-                                   SymbolMap symbolMap) throws QueryPlannerException {
+                                   SymbolMap symbolMap,
+                                   QueryMetadataInterface metadata) throws QueryPlannerException {
         // If projectNode has children, then it is from a SELECT without a FROM and the criteria should not be pushed
         if(projectNode.getChildCount() == 0) {
             return false;
@@ -560,7 +561,7 @@
             copyNode.setProperty(NodeConstants.Info.IS_HAVING, Boolean.TRUE);
         }
 
-        FrameUtil.convertNode(copyNode, sourceGroup, null, symbolMap.asMap());  
+        FrameUtil.convertNode(copyNode, sourceGroup, null, symbolMap.asMap(), metadata);  
         PlanNode intermediateParent = NodeEditor.findParent(projectNode, NodeConstants.Types.ACCESS, NodeConstants.Types.SOURCE | NodeConstants.Types.SET_OP);
         if (intermediateParent != null) {
             intermediateParent.addAsParent(copyNode);

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,6 +28,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.query.QueryPlannerException;
@@ -42,7 +44,6 @@
 import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
 import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
 import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.Criteria;
 import com.metamatrix.query.sql.lang.JoinType;
 import com.metamatrix.query.sql.lang.OrderBy;
@@ -276,8 +277,8 @@
 
 	static boolean areAggregatesCardinalityDependent(Set<AggregateSymbol> aggs) {
 		for (AggregateSymbol aggregateSymbol : aggs) {
-			if (aggregateSymbol.getAggregateFunction().equalsIgnoreCase(ReservedWords.COUNT) || 
-					aggregateSymbol.getAggregateFunction().equalsIgnoreCase(ReservedWords.AVG)) {
+			if (aggregateSymbol.getAggregateFunction().equalsIgnoreCase(SQLReservedWords.COUNT) || 
+					aggregateSymbol.getAggregateFunction().equalsIgnoreCase(SQLReservedWords.AVG)) {
 				return true;
 			}
 		}

Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,10 +24,11 @@
 
 import java.io.StringReader;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.api.exception.query.QueryParserException;
 import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Criteria;
 import com.metamatrix.query.sql.lang.Option;
@@ -126,7 +127,7 @@
             // Check for OPTION
             Option option = null;
             int closeBracket = sql.lastIndexOf(XML_CLOSE_BRACKET);
-            int optionIndex = sql.toUpperCase().lastIndexOf(ReservedWords.OPTION);
+            int optionIndex = sql.toUpperCase().lastIndexOf(SQLReservedWords.OPTION);
             if (optionIndex != -1 && optionIndex > closeBracket){
                 String optionSQL = sql.substring(optionIndex);
                 option = getOption(optionSQL, parseInfo);

Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,10 +27,11 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.core.util.Assertion;
 import com.metamatrix.core.util.StringUtil;
 import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.FromClause;
 import com.metamatrix.query.sql.lang.JoinType;
@@ -201,17 +202,17 @@
             return JoinType.JOIN_INNER;
         }   
         String joinType = joinTypeToken.image;
-        if(joinType.equalsIgnoreCase(ReservedWords.INNER)) {
+        if(joinType.equalsIgnoreCase(SQLReservedWords.INNER)) {
             return JoinType.JOIN_INNER;
-        } else if(joinType.equalsIgnoreCase(ReservedWords.CROSS)) {
+        } else if(joinType.equalsIgnoreCase(SQLReservedWords.CROSS)) {
             return JoinType.JOIN_CROSS;         
-        } else if(joinType.equalsIgnoreCase(ReservedWords.LEFT)) {
+        } else if(joinType.equalsIgnoreCase(SQLReservedWords.LEFT)) {
             return JoinType.JOIN_LEFT_OUTER;
-        } else if(joinType.equalsIgnoreCase(ReservedWords.RIGHT)) {
+        } else if(joinType.equalsIgnoreCase(SQLReservedWords.RIGHT)) {
             return JoinType.JOIN_RIGHT_OUTER;
-        } else if(joinType.equalsIgnoreCase(ReservedWords.FULL)) {
+        } else if(joinType.equalsIgnoreCase(SQLReservedWords.FULL)) {
             return JoinType.JOIN_FULL_OUTER;
-        } else if(joinType.equalsIgnoreCase(ReservedWords.UNION)) {
+        } else if(joinType.equalsIgnoreCase(SQLReservedWords.UNION)) {
             return JoinType.JOIN_UNION;
         } else {
             Object[] params = new Object[] { joinType };
@@ -230,23 +231,23 @@
             int num = info.anonExprCount++;
             return "expr" + (num == 0 ? "" : ""+num); //$NON-NLS-1$   //$NON-NLS-2$   //$NON-NLS-3$
 
-        } else if(functionType.equals(ReservedWords.COUNT)) { 
+        } else if(functionType.equals(SQLReservedWords.COUNT)) { 
             int num = info.anonCountCount++;
             return "count" + (num == 0 ? "" : ""+num);//$NON-NLS-1$   //$NON-NLS-2$   //$NON-NLS-3$
 
-        } else if(functionType.equals(ReservedWords.SUM)) { 
+        } else if(functionType.equals(SQLReservedWords.SUM)) { 
             int num = info.anonSumCount++;
             return "sum" + (num == 0 ? "" : ""+num);//$NON-NLS-1$   //$NON-NLS-2$   //$NON-NLS-3$
 
-        } else if(functionType.equals(ReservedWords.AVG)) { 
+        } else if(functionType.equals(SQLReservedWords.AVG)) { 
             int num = info.anonAvgCount++;
             return "avg" + (num == 0 ? "" : ""+num);//$NON-NLS-1$   //$NON-NLS-2$   //$NON-NLS-3$
 
-        } else if(functionType.equals(ReservedWords.MIN)) { 
+        } else if(functionType.equals(SQLReservedWords.MIN)) { 
             int num = info.anonMinCount++;
             return "min" + (num == 0 ? "" : ""+num);//$NON-NLS-1$   //$NON-NLS-2$   //$NON-NLS-3$
 
-        } else if(functionType.equals(ReservedWords.MAX)) { 
+        } else if(functionType.equals(SQLReservedWords.MAX)) { 
             int num = info.anonMaxCount++;
             return "max" + (num == 0 ? "" : ""+num);//$NON-NLS-1$   //$NON-NLS-2$   //$NON-NLS-3$
         } else {

Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -30,6 +30,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.api.exception.query.QueryProcessingException;
@@ -157,10 +159,14 @@
             
             if (dynamicCommand.getUsing() != null
                             && !dynamicCommand.getUsing().isEmpty()) {
-                metadataStore.addTempGroup(ProcedureReservedWords.USING, new LinkedList(dynamicCommand.getUsing().getClauseMap().keySet()));
-                GroupSymbol using = new GroupSymbol(ProcedureReservedWords.USING);
-                using.setMetadataID(metadataStore.getTempGroupID(ProcedureReservedWords.USING));
+                metadataStore.addTempGroup(SQLReservedWords.USING, new LinkedList(dynamicCommand.getUsing().getClauseMap().keySet()));
+                GroupSymbol using = new GroupSymbol(SQLReservedWords.USING);
+                using.setMetadataID(metadataStore.getTempGroupID(SQLReservedWords.USING));
                 command.addExternalGroupToContext(using);
+                metadataStore.addTempGroup(ProcedureReservedWords.DVARS, new LinkedList(dynamicCommand.getUsing().getClauseMap().keySet()));
+                using = new GroupSymbol(ProcedureReservedWords.DVARS);
+                using.setMetadataID(metadataStore.getTempGroupID(ProcedureReservedWords.DVARS));
+                command.addExternalGroupToContext(using);
             }
 
 			// Resolve any groups
@@ -233,8 +239,8 @@
 				LogManager.logTrace(LogConstants.CTX_DQP,
 						new Object[] { this, " The using variable ", //$NON-NLS-1$
 						setClause.getSymbol(), " has value :", assignment }); //$NON-NLS-1$
-				localContext.setValue(setClause.getSymbol(),
-						assignment);
+				localContext.setValue(setClause.getSymbol(), assignment);
+				localContext.setValue(new ElementSymbol(SQLReservedWords.USING + ElementSymbol.SEPARATOR + setClause.getSymbol().getShortName()), assignment);
 			}
 		}
 	}

Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -35,6 +35,7 @@
 import com.metamatrix.common.buffer.TupleBatch;
 import com.metamatrix.common.buffer.TupleSource;
 import com.metamatrix.query.execution.QueryExecPlugin;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.rewriter.QueryRewriter;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.util.CommandContext;
@@ -107,15 +108,15 @@
 	}
 
     protected boolean prepareNextCommand(Command atomicCommand) throws MetaMatrixComponentException, MetaMatrixProcessingException {
-    	return prepareCommand(atomicCommand, this, this.getContext());
+    	return prepareCommand(atomicCommand, this, this.getContext(), this.getContext().getMetadata());
     }
 
-	static boolean prepareCommand(Command atomicCommand, RelationalNode node, CommandContext context)
+	static boolean prepareCommand(Command atomicCommand, RelationalNode node, CommandContext context, QueryMetadataInterface metadata)
 			throws ExpressionEvaluationException, MetaMatrixComponentException,
 			MetaMatrixProcessingException, CriteriaEvaluationException {
         try {
             // Defect 16059 - Rewrite the command once the references have been replaced with values.
-            QueryRewriter.evaluateAndRewrite(atomicCommand, node.getDataManager(), context);
+            QueryRewriter.evaluateAndRewrite(atomicCommand, node.getDataManager(), context, metadata);
         } catch (QueryValidatorException e) {
             throw new MetaMatrixProcessingException(e, QueryExecPlugin.Util.getString("AccessNode.rewrite_failed", atomicCommand)); //$NON-NLS-1$
         }

Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -97,7 +97,7 @@
             boolean needProcessing = false;
             if(shouldEvaluate != null && shouldEvaluate.get(i)) {
                 updateCommand = (Command) updateCommand.clone();
-                needProcessing = AccessNode.prepareCommand(updateCommand, this, context);
+                needProcessing = AccessNode.prepareCommand(updateCommand, this, context, context.getMetadata());
             } else {
                 needProcessing = RelationalNodeUtil.shouldExecute(updateCommand, true);
             }

Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,6 +28,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.api.exception.query.ExpressionEvaluationException;
@@ -47,7 +49,6 @@
 import com.metamatrix.query.function.aggregate.Sum;
 import com.metamatrix.query.processor.ProcessorDataManager;
 import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.OrderBy;
 import com.metamatrix.query.sql.symbol.AggregateSymbol;
 import com.metamatrix.query.sql.symbol.Expression;
@@ -163,19 +164,19 @@
                     }
                 	aggProjectionIndexes[i] = index;
                     String function = aggSymbol.getAggregateFunction();
-                    if(function.equals(ReservedWords.COUNT)) {
+                    if(function.equals(SQLReservedWords.COUNT)) {
                         functions[i] = new Count();
-                    } else if(function.equals(ReservedWords.SUM)) {
+                    } else if(function.equals(SQLReservedWords.SUM)) {
                         functions[i] = new Sum();
-                    } else if(function.equals(ReservedWords.AVG)) {
+                    } else if(function.equals(SQLReservedWords.AVG)) {
                         functions[i] = new Avg();
-                    } else if(function.equals(ReservedWords.MIN)) {
+                    } else if(function.equals(SQLReservedWords.MIN)) {
                         functions[i] = new Min();
                     } else {
                         functions[i] = new Max();
                     }
 
-                    if(aggSymbol.isDistinct() && !function.equals(ReservedWords.MIN) && !function.equals(ReservedWords.MAX)) {
+                    if(aggSymbol.isDistinct() && !function.equals(SQLReservedWords.MIN) && !function.equals(SQLReservedWords.MAX)) {
                         functions[i] = new DuplicateFilter(functions[i], getBufferManager(), getConnectionID());
                     }
                     

Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/InsertPlanExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/InsertPlanExecutionNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/InsertPlanExecutionNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,6 +31,7 @@
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.common.buffer.BlockedException;
 import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.sql.symbol.Reference;
 
 public class InsertPlanExecutionNode extends PlanExecutionNode {
@@ -40,9 +41,11 @@
     private int batchRow = 1;
     private int insertCount = 0;
     private TupleBatch currentBatch;
+    private QueryMetadataInterface metadata;
 	
-	public InsertPlanExecutionNode(int nodeID) {
+	public InsertPlanExecutionNode(int nodeID, QueryMetadataInterface metadata) {
 		super(nodeID);
+		this.metadata = metadata;
 	}
 	
 	public void setReferences(List<Reference> references) {
@@ -82,13 +85,13 @@
 			return false;
 		}
 		//assign the reference values.
-		PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext());
+		PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext(), this.metadata);
 		this.batchRow++;
 		return true;
 	}
 	
 	public Object clone(){
-		InsertPlanExecutionNode clonedNode = new InsertPlanExecutionNode(super.getID());
+		InsertPlanExecutionNode clonedNode = new InsertPlanExecutionNode(super.getID(), this.metadata);
 		copy(this, clonedNode);
         return clonedNode;
 	}

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -106,7 +106,7 @@
         TempMetadataStore childMetadata = new TempMetadataStore();
         QueryMetadataInterface resolveMetadata = new TempMetadataAdapter(metadata, childMetadata);
 
-        GroupContext externalGroups = findChildCommandMetadata(procCommand, subCommand, childMetadata, resolveMetadata);
+        GroupContext externalGroups = findChildCommandMetadata(procCommand, childMetadata, resolveMetadata);
         
         QueryResolver.setChildMetadata(subCommand, childMetadata.getData(), externalGroups);
         
@@ -132,20 +132,27 @@
      * 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 metadata Metadata access
      * @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, Command subCommand, TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata)
+    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
             
-        GroupContext externalGroups = new GroupContext();
+        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);
@@ -159,6 +166,7 @@
         }
 
         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());
@@ -170,10 +178,9 @@
         }
 
         addScalarGroup(ProcedureReservedWords.CHANGING, discoveredMetadata, externalGroups, changingElements);
+		return externalGroups;
+	}
         
-        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)
      */

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -75,8 +75,7 @@
     
     @Override
     public GroupContext findChildCommandMetadata(ProcedureContainer container,
-    		Command subCommand, TempMetadataStore discoveredMetadata,
-    		QueryMetadataInterface metadata) throws QueryMetadataException,
+    		TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata) throws QueryMetadataException,
     		QueryResolverException, MetaMatrixComponentException {
     	//defect 16451: don't expose input and changing variables to delete procedures
     	return null;

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,30 +22,30 @@
 
 package com.metamatrix.query.resolver.command;
 
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+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.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataID;
+import com.metamatrix.query.resolver.CommandResolver;
+import com.metamatrix.query.resolver.util.ResolverUtil;
+import com.metamatrix.query.resolver.util.ResolverVisitor;
+import com.metamatrix.query.sql.ProcedureReservedWords;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.DynamicCommand;
+import com.metamatrix.query.sql.lang.SetClause;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
 
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-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.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-
 public class DynamicCommandResolver implements CommandResolver {
 
     /** 
@@ -85,8 +85,8 @@
         if (dynamicCmd.getUsing() != null && !dynamicCmd.getUsing().isEmpty()) {
             for (SetClause clause : dynamicCmd.getUsing().getClauses()) {
                 ElementSymbol id = clause.getSymbol();
-                id.setName(ProcedureReservedWords.USING + SingleElementSymbol.SEPARATOR + id.getShortName());
-                id.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.USING));
+                id.setName(ProcedureReservedWords.DVARS + SingleElementSymbol.SEPARATOR + id.getShortName());
+                id.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.DVARS));
                 id.setType(clause.getValue().getType());
                 id.setMetadataID(new TempMetadataID(id.getCanonicalName(), id.getType()));
             }

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -209,8 +209,7 @@
     
     @Override
     public GroupContext findChildCommandMetadata(ProcedureContainer container,
-    		Command subCommand, TempMetadataStore discoveredMetadata,
-    		QueryMetadataInterface metadata) throws QueryMetadataException,
+    		TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata) throws QueryMetadataException,
     		QueryResolverException, MetaMatrixComponentException {
 
         StoredProcedure storedProcedureCommand = (StoredProcedure) container;
@@ -276,7 +275,7 @@
                     Expression result = null;
                     
                     try {
-                        result = ResolverUtil.convertExpression(expr, tgtType);
+                        result = ResolverUtil.convertExpression(expr, tgtType, metadata);
                     } catch (QueryResolverException e) {
                         throw new QueryResolverException(e, QueryPlugin.Util.getString("ExecResolver.Param_convert_fail", new Object[] { srcType, tgtType}));                                     //$NON-NLS-1$
                     }                                                       

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -102,7 +102,7 @@
             resolveVariables(metadata, insert, groups);
         }
 
-        resolveTypes(insert);
+        resolveTypes(insert, metadata);
         
         if (!insert.getGroup().isResolved()) { //define the implicit temp group
             if(insert.getQueryExpression() != null) {
@@ -113,7 +113,7 @@
             resolveVariables(metadata, insert, groups);
             
             //ensure that the types match
-            resolveTypes(insert);
+            resolveTypes(insert, metadata);
         }
         
         if (insert.getQueryExpression() != null && metadata.isVirtualGroup(insert.getGroup().getMetadataID())) {
@@ -151,7 +151,7 @@
      * @param insert
      * @throws QueryResolverException
      */
-    public void resolveTypes(Insert insert) throws QueryResolverException {
+    public void resolveTypes(Insert insert, TempMetadataAdapter metadata) throws QueryResolverException {
         
         boolean usingQuery = insert.getQueryExpression() != null;
         
@@ -183,7 +183,7 @@
             if(element.getType() != null && expression.getType() != null) {
                 String elementTypeName = DataTypeManager.getDataTypeName(element.getType());
                 if (!usingQuery) {
-                    newValues.add(ResolverUtil.convertExpression(expression, elementTypeName));
+                    newValues.add(ResolverUtil.convertExpression(expression, elementTypeName, metadata));
                 } else if (element.getType() != expression.getType()
                            && !DataTypeManager.isImplicitConversion(DataTypeManager.getDataTypeName(expression.getType()),
                                                                     DataTypeManager.getDataTypeName(element.getType()))) {
@@ -249,9 +249,11 @@
             String varName = varSymbol.getShortCanonicalName();
             String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
             String inputKey = ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + varName;
-            
+            String inputsKey = ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + varName;
             result.put(changingKey, new Constant(Boolean.TRUE));
-            result.put(inputKey, valIter.next());
+            Object value = valIter.next();
+            result.put(inputKey, value);
+            result.put(inputsKey, value);
         }
         
         Collection insertElmnts = ResolverUtil.resolveElementsInGroup(insert.getGroup(), metadata);
@@ -267,9 +269,10 @@
             String varName = varSymbol.getShortCanonicalName();
             String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
             String inputKey = ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + varName;
-            
+            String inputsKey = ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + varName;
             result.put(changingKey, new Constant(Boolean.FALSE));
             result.put(inputKey, value);
+            result.put(inputsKey, value);
         }
         
         return result;

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -34,6 +34,7 @@
 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.resolver.CommandResolver;
@@ -89,7 +90,7 @@
             }
         }
 
-        setQuery.setProjectedTypes(firstProjectTypes);
+        setQuery.setProjectedTypes(firstProjectTypes, metadata.getMetadata());
         
         // ORDER BY clause
         if(setQuery.getOrderBy() != null) {
@@ -97,7 +98,7 @@
             ResolverUtil.resolveOrderBy(setQuery.getOrderBy(), setQuery, metadata);
         } 
 
-        setProjectedTypes(setQuery, firstProjectTypes);
+        setProjectedTypes(setQuery, firstProjectTypes, metadata.getMetadata());
         
         if (setQuery.getLimit() != null) {
             ResolverUtil.resolveLimit(setQuery.getLimit());
@@ -107,7 +108,7 @@
     }
 
     private void setProjectedTypes(SetQuery setQuery,
-                                   List firstProjectTypes) throws QueryResolverException {
+                                   List firstProjectTypes, QueryMetadataInterface metadata) throws QueryResolverException {
         for (QueryCommand subCommand : setQuery.getQueryCommands()) {
             if (!(subCommand instanceof SetQuery)) {
                 continue;
@@ -126,8 +127,8 @@
                     }
                 }
             }
-            child.setProjectedTypes(firstProjectTypes);
-            setProjectedTypes(child, firstProjectTypes);
+            child.setProjectedTypes(firstProjectTypes, metadata);
+            setProjectedTypes(child, firstProjectTypes, metadata);
         }
     }
     

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -92,6 +92,7 @@
 	        	GroupSymbol groupSymbol = (GroupSymbol) groupIter.next();
 	        	String groupName = groupSymbol.getName();
 	        	if(!groupName.equalsIgnoreCase(ProcedureReservedWords.INPUT) &&
+	        		!groupName.equalsIgnoreCase(ProcedureReservedWords.INPUTS) &&
 		        	 !groupName.equalsIgnoreCase(ProcedureReservedWords.CHANGING) ) {
 		        	 // set the groupSymbol on the procedure
 		        	 ResolverUtil.resolveGroup(groupSymbol, metadata);
@@ -277,7 +278,7 @@
                         throw new QueryResolverException(QueryPlugin.Util.getString("ResolveVariablesVisitor.datatype_for_the_expression_not_resolvable")); //$NON-NLS-1$
                     }
                     String varTypeName = DataTypeManager.getDataTypeName(varType);
-                    assStmt.setExpression(ResolverUtil.convertExpression(expr, varTypeName));                    
+                    assStmt.setExpression(ResolverUtil.convertExpression(expr, varTypeName, metadata));                    
                 }
                 
                 break;

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -102,10 +102,10 @@
             String varName = leftSymbol.getShortCanonicalName();
             String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + varName;
             String inputKey = ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + varName;
-            
+            String inputsKey = ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + varName;
             result.put(changingKey, new Constant(Boolean.TRUE));
             result.put(inputKey, entry.getValue());
-            
+            result.put(inputsKey, entry.getValue());
             updateVars.add(leftSymbol);
         }
         

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -43,7 +43,6 @@
 import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.function.FunctionDescriptor;
 import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
 import com.metamatrix.query.metadata.GroupInfo;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.metadata.StoredProcedureInfo;
@@ -187,10 +186,10 @@
      * @return
      * @throws QueryResolverException 
      */
-    public static Expression convertExpression(Expression sourceExpression, String targetTypeName) throws QueryResolverException {
+    public static Expression convertExpression(Expression sourceExpression, String targetTypeName, QueryMetadataInterface metadata) throws QueryResolverException {
         return convertExpression(sourceExpression,
                                  DataTypeManager.getDataTypeName(sourceExpression.getType()),
-                                 targetTypeName);
+                                 targetTypeName, metadata);
     }
 
     /**
@@ -203,14 +202,14 @@
      * @return
      * @throws QueryResolverException 
      */
-    public static Expression convertExpression(Expression sourceExpression, String sourceTypeName, String targetTypeName) throws QueryResolverException {
+    public static Expression convertExpression(Expression sourceExpression, String sourceTypeName, String targetTypeName, QueryMetadataInterface metadata) throws QueryResolverException {
         if (sourceTypeName.equals(targetTypeName)) {
             return sourceExpression;
         }
         
         if(canImplicitlyConvert(sourceTypeName, targetTypeName) 
                         || (sourceExpression instanceof Constant && convertConstant(sourceTypeName, targetTypeName, (Constant)sourceExpression) != null)) {
-            return getConversion(sourceExpression, sourceTypeName, targetTypeName, true);
+            return getConversion(sourceExpression, sourceTypeName, targetTypeName, true, metadata.getFunctionLibrary());
         }
 
         //Expression is wrong type and can't convert
@@ -258,10 +257,9 @@
     public static Function getConversion(Expression sourceExpression,
                                             String sourceTypeName,
                                             String targetTypeName,
-                                            boolean implicit) {
+                                            boolean implicit, FunctionLibrary library) {
         Class<?> srcType = DataTypeManager.getDataTypeClass(sourceTypeName);
 
-        FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
         FunctionDescriptor fd = library.findTypedConversionFunction(srcType, DataTypeManager.getDataTypeClass(targetTypeName));
 
         Function conversion = new Function(fd.getName(), new Expression[] { sourceExpression, new Constant(targetTypeName) });
@@ -777,7 +775,7 @@
 	 * @throws QueryResolverException if a conversion is necessary but none can
 	 * be found
 	 */
-	static Expression resolveSubqueryPredicateCriteria(Expression expression, SubqueryContainer crit)
+	static Expression resolveSubqueryPredicateCriteria(Expression expression, SubqueryContainer crit, QueryMetadataInterface metadata)
 		throws QueryResolverException {
 	
 		// Check that type of the expression is same as the type of the
@@ -796,7 +794,7 @@
 		String subqueryTypeName = DataTypeManager.getDataTypeName(subqueryType);
 		Expression result = null;
 	    try {
-	        result = convertExpression(expression, exprTypeName, subqueryTypeName);
+	        result = convertExpression(expression, exprTypeName, subqueryTypeName, metadata);
 	    } catch (QueryResolverException qre) {
 	        throw new QueryResolverException(qre, ErrorMessageKeys.RESOLVER_0033, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0033, crit));
 	    }
@@ -841,7 +839,7 @@
             throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, keyElementName));
         }
 		result.setKeyElement(keyElement);
-		args[3] = convertExpression(args[3], DataTypeManager.getDataTypeName(keyElement.getType()));
+		args[3] = convertExpression(args[3], DataTypeManager.getDataTypeName(keyElement.getType()), metadata);
 		return result;
 	}
 

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -44,11 +44,11 @@
 import com.metamatrix.query.function.FunctionDescriptor;
 import com.metamatrix.query.function.FunctionForm;
 import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
 import com.metamatrix.query.metadata.GroupInfo;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.LanguageVisitor;
+import com.metamatrix.query.sql.ProcedureReservedWords;
 import com.metamatrix.query.sql.lang.BetweenCriteria;
 import com.metamatrix.query.sql.lang.CompareCriteria;
 import com.metamatrix.query.sql.lang.GroupContext;
@@ -206,6 +206,13 @@
         
         //copy the match information
         ElementSymbol resolvedSymbol = match.element;
+        if (isExternal //convert input to inputs
+        		&& metadata.isScalarGroup(resolvedSymbol.getGroupSymbol().getMetadataID())
+        		&& ProcedureReservedWords.INPUT.equals(groupContext)) {
+        	resolvedSymbol = new ElementSymbol(ProcedureReservedWords.INPUTS + ElementSymbol.SEPARATOR + elementShortName);
+        	resolveElementSymbol(resolvedSymbol);
+        	elementSymbol.setOutputName(resolvedSymbol.getOutputName());
+        } 
         elementSymbol.setIsExternalReference(isExternal);
         elementSymbol.setType(resolvedSymbol.getType());
         elementSymbol.setMetadataID(resolvedSymbol.getMetadataID());
@@ -264,7 +271,7 @@
 
     public void visit(SubqueryCompareCriteria obj) {
         try {
-            obj.setLeftExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getLeftExpression(), obj));
+            obj.setLeftExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getLeftExpression(), obj, metadata));
         } catch(QueryResolverException e) {
             handleException(e);
         }
@@ -273,7 +280,7 @@
 
     public void visit(SubquerySetCriteria obj) {
         try {
-            obj.setExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getExpression(), obj));
+            obj.setExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getExpression(), obj, metadata));
         } catch(QueryResolverException e) {
             handleException(e);
         }
@@ -289,7 +296,7 @@
     
     public void visit(Function obj) {
         try {
-            resolveFunction(obj);
+            resolveFunction(obj, this.metadata.getFunctionLibrary());
         } catch(QueryResolverException e) {
         	if (unresolvedFunctions == null) {
         		unresolvedFunctions = new LinkedHashMap<Function, QueryResolverException>();
@@ -320,7 +327,7 @@
     	String type = DataTypeManager.getDataTypeName(obj.getSymbol().getType());
     	try {
     		setDesiredType(obj.getValue(), obj.getSymbol().getType(), obj);
-            obj.setValue(ResolverUtil.convertExpression(obj.getValue(), type));                    
+            obj.setValue(ResolverUtil.convertExpression(obj.getValue(), type, metadata));                    
         } catch(QueryResolverException e) {
             handleException(new QueryResolverException(e, QueryPlugin.Util.getString("SetClause.resolvingError", new Object[] {obj.getValue(), obj.getSymbol(), type}))); //$NON-NLS-1$
         } 
@@ -367,7 +374,7 @@
 	/**
 	 * Resolve function such that all functions are resolved and type-safe.
 	 */
-	void resolveFunction(Function function)
+	void resolveFunction(Function function, FunctionLibrary library)
 	    throws QueryResolverException, MetaMatrixComponentException {
 	
 	    // Check whether this function is already resolved
@@ -388,8 +395,6 @@
 	            hasArgWithoutType = true;
 	        }
 	    }
-	        
-	    FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
 	
 	    //special case handling for convert of an untyped reference
 	    if (FunctionLibrary.isConvert(function) && hasArgWithoutType) {
@@ -543,9 +548,9 @@
 	
 	    String commonType = ResolverUtil.getCommonType(new String[] {expTypeName, lowerTypeName, upperTypeName});
 	    if (commonType != null) {
-	        criteria.setExpression(ResolverUtil.convertExpression(exp, expTypeName, commonType));
-	        criteria.setLowerExpression(ResolverUtil.convertExpression(lower, lowerTypeName, commonType));
-	        criteria.setUpperExpression(ResolverUtil.convertExpression(upper, upperTypeName, commonType));
+	        criteria.setExpression(ResolverUtil.convertExpression(exp, expTypeName, commonType, metadata));
+	        criteria.setLowerExpression(ResolverUtil.convertExpression(lower, lowerTypeName, commonType, metadata));
+	        criteria.setUpperExpression(ResolverUtil.convertExpression(upper, upperTypeName, commonType, metadata));
 	    } else {
 	        // Couldn't find a common type to implicitly convert to
 	        throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0027, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0027, expTypeName, lowerTypeName, criteria));
@@ -575,7 +580,7 @@
 	    if(rightExpression instanceof Constant) {
 	        // Auto-convert constant string on right to expected type on left
 	        try {
-	            ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, leftTypeName));
+	            ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, leftTypeName, metadata));
 	            return;
 	        } catch (QueryResolverException qre) {
 	            //ignore
@@ -586,7 +591,7 @@
 	    if(leftExpression instanceof Constant) {
 	        // Auto-convert constant string on left to expected type on right
 	        try {
-	            ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, rightTypeName));
+	            ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, rightTypeName, metadata));
 	            return;                                           
 	        } catch (QueryResolverException qre) {
 	            //ignore
@@ -596,12 +601,12 @@
 	    // Try to apply a conversion generically
 		
 	    if(ResolverUtil.canImplicitlyConvert(leftTypeName, rightTypeName)) {
-			ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, rightTypeName) );
+			ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, rightTypeName, metadata) );
 			return;
 		}
 	
 		if(ResolverUtil.canImplicitlyConvert(rightTypeName, leftTypeName)) {
-			ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, leftTypeName) );
+			ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, leftTypeName, metadata) );
 			return;
 	    }
 	
@@ -611,8 +616,8 @@
 	        // Neither are aggs, but types can't be reconciled
 	        throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0027, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0027, new Object[] { leftTypeName, rightTypeName, ccrit }));
 		}
-		ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, commonType) );
-		ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, commonType) );
+		ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, commonType, metadata) );
+		ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, commonType, metadata) );
 	}
 
 	void resolveMatchCriteria(MatchCriteria mcrit)
@@ -644,12 +649,12 @@
 	            if(!(expr instanceof AggregateSymbol) &&
 	                ResolverUtil.canImplicitlyConvert(type, DataTypeManager.DefaultDataTypes.STRING)) {
 	
-	                result = ResolverUtil.convertExpression(expr, type, DataTypeManager.DefaultDataTypes.STRING);
+	                result = ResolverUtil.convertExpression(expr, type, DataTypeManager.DefaultDataTypes.STRING, metadata);
 	                
 	            } else if (!(expr instanceof AggregateSymbol) &&
 	                ResolverUtil.canImplicitlyConvert(type, DataTypeManager.DefaultDataTypes.CLOB)){
 	                    
-	                result = ResolverUtil.convertExpression(expr, type, DataTypeManager.DefaultDataTypes.CLOB);
+	                result = ResolverUtil.convertExpression(expr, type, DataTypeManager.DefaultDataTypes.CLOB, metadata);
 	
 	            } else {
 	                throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0029, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0029, mcrit));
@@ -687,7 +692,7 @@
 	            String valTypeName = DataTypeManager.getDataTypeName(value.getType());
 	            if(ResolverUtil.canImplicitlyConvert(valTypeName, exprTypeName)) {
 	                // Apply cast and replace current value
-	                newVals.add(ResolverUtil.convertExpression(value, valTypeName, exprTypeName) );
+	                newVals.add(ResolverUtil.convertExpression(value, valTypeName, exprTypeName, metadata) );
 	                changed = true;
 	            } else {
 	                convertLeft = true;
@@ -716,7 +721,7 @@
 	            }
 	
 	            // Convert left expression to type of values in the set
-	            scrit.setExpression(ResolverUtil.convertExpression(scrit.getExpression(), exprTypeName, setTypeName ));
+	            scrit.setExpression(ResolverUtil.convertExpression(scrit.getExpression(), exprTypeName, setTypeName, metadata));
 	
 	        } else {
 	            throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0031, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0031, scrit));
@@ -799,16 +804,16 @@
 	    if (thenTypeName == null) {
 	        throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0068, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0068, "THEN/ELSE", obj)); //$NON-NLS-1$
 	    }
-	    obj.setExpression(ResolverUtil.convertExpression(obj.getExpression(), whenTypeName));
+	    obj.setExpression(ResolverUtil.convertExpression(obj.getExpression(), whenTypeName, metadata));
 	    ArrayList whens = new ArrayList(whenCount);
 	    ArrayList thens = new ArrayList(whenCount);
 	    for (int i = 0; i < whenCount; i++) {
-	        whens.add(ResolverUtil.convertExpression(obj.getWhenExpression(i), whenTypeName));
-	        thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName));
+	        whens.add(ResolverUtil.convertExpression(obj.getWhenExpression(i), whenTypeName, metadata));
+	        thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName, metadata));
 	    }
 	    obj.setWhen(whens, thens);
 	    if (elseExpr != null) {
-	        obj.setElseExpression(ResolverUtil.convertExpression(elseExpr, thenTypeName));
+	        obj.setElseExpression(ResolverUtil.convertExpression(elseExpr, thenTypeName, metadata));
 	    }
 	    // Set this CASE expression's type to the common THEN type, and we're done.
 	    obj.setType(DataTypeManager.getDataTypeClass(thenTypeName));
@@ -887,11 +892,11 @@
 	    }
 	    ArrayList thens = new ArrayList(whenCount);
 	    for (int i = 0; i < whenCount; i++) {
-	        thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName));
+	        thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName, metadata));
 	    }
 	    obj.setWhen(obj.getWhen(), thens);
 	    if (elseExpr != null) {
-	        obj.setElseExpression(ResolverUtil.convertExpression(elseExpr, thenTypeName));
+	        obj.setElseExpression(ResolverUtil.convertExpression(elseExpr, thenTypeName, metadata));
 	    }
 	    // Set this CASE expression's type to the common THEN type, and we're done.
 	    obj.setType(DataTypeManager.getDataTypeClass(thenTypeName));

Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -42,6 +42,7 @@
 import java.util.StringTokenizer;
 
 import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.language.SQLReservedWords;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixException;
@@ -49,7 +50,6 @@
 import com.metamatrix.api.exception.query.CriteriaEvaluationException;
 import com.metamatrix.api.exception.query.ExpressionEvaluationException;
 import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.api.exception.query.InvalidFunctionException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.api.exception.query.QueryValidatorException;
@@ -61,7 +61,6 @@
 import com.metamatrix.query.execution.QueryExecPlugin;
 import com.metamatrix.query.function.FunctionDescriptor;
 import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
 import com.metamatrix.query.function.FunctionMethods;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.metadata.TempMetadataAdapter;
@@ -73,7 +72,6 @@
 import com.metamatrix.query.resolver.util.ResolverVisitor;
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.LanguageObject.Util;
 import com.metamatrix.query.sql.lang.AbstractSetCriteria;
 import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
@@ -190,8 +188,8 @@
 		this.procCommand = procCommand;
 	}
     
-    public static Command evaluateAndRewrite(Command command, ProcessorDataManager dataMgr, CommandContext context) throws MetaMatrixProcessingException, MetaMatrixComponentException {
-    	QueryRewriter queryRewriter = new QueryRewriter(null, context, null);
+    public static Command evaluateAndRewrite(Command command, ProcessorDataManager dataMgr, CommandContext context, QueryMetadataInterface metadata) throws MetaMatrixProcessingException, MetaMatrixComponentException {
+    	QueryRewriter queryRewriter = new QueryRewriter(metadata, context, null);
     	queryRewriter.dataMgr = dataMgr;
     	queryRewriter.rewriteSubcommands = true;
     	try {
@@ -917,7 +915,7 @@
         
         List symbols = query.getSelect().getProjectedSymbols();
         
-        List newSymbols = SetQuery.getTypedProjectedSymbols(symbols, actualSymbolTypes);
+        List newSymbols = SetQuery.getTypedProjectedSymbols(symbols, actualSymbolTypes, this.metadata);
         
         query.getSelect().setSymbols(newSymbols);
     } 
@@ -932,7 +930,7 @@
                 }
                 correctProjectedTypes(setQuery.getProjectedTypes(), (Query)command);
             }
-            setQuery.setProjectedTypes(null);
+            setQuery.setProjectedTypes(null, null);
         }
         
         setQuery.setLeftQuery((QueryCommand)rewriteCommand(setQuery.getLeftQuery(), true));
@@ -1075,9 +1073,9 @@
      * @param criteria
      * @return
      */
-    public static Criteria optimizeCriteria(CompoundCriteria criteria) {
+    public static Criteria optimizeCriteria(CompoundCriteria criteria, QueryMetadataInterface metadata) {
         try {
-            return new QueryRewriter(null, null, null).rewriteCriteria(criteria, false);
+            return new QueryRewriter(metadata, null, null).rewriteCriteria(criteria, false);
         } catch (QueryValidatorException err) {
             //shouldn't happen
             return criteria;
@@ -1362,7 +1360,7 @@
 
         // Create a function of the two constants and evaluate it
         Expression combinedConst = null;
-        FunctionLibrary funcLib = FunctionLibraryManager.getFunctionLibrary();
+        FunctionLibrary funcLib = this.metadata.getFunctionLibrary();
         FunctionDescriptor descriptor = funcLib.findFunction(oppFunc, new Class[] { rightExpr.getType(), const1.getType() });
         if (descriptor == null){
             //See defect 9380 - this can be caused by const2 being a null Constant, for example (? + 1) < null
@@ -1373,13 +1371,10 @@
         if (rightExpr instanceof Constant) {
             Constant const2 = (Constant)rightExpr;
             try {
-                Object result = funcLib.invokeFunction(
-                    descriptor, new Object[] { const2.getValue(), const1.getValue() } );
+                Object result = descriptor.invokeFunction(new Object[] { const2.getValue(), const1.getValue() } );
                 combinedConst = new Constant(result, descriptor.getReturnType());
-            } catch(InvalidFunctionException e) {
+            } catch(FunctionExecutionException e) {
             	throw new QueryValidatorException(e, ErrorMessageKeys.REWRITER_0003, QueryExecPlugin.Util.getString(ErrorMessageKeys.REWRITER_0003, e.getMessage()));
-        	} catch(FunctionExecutionException e) {
-            	throw new QueryValidatorException(e, ErrorMessageKeys.REWRITER_0003, QueryExecPlugin.Util.getString(ErrorMessageKeys.REWRITER_0003, e.getMessage()));
         	}
         } else {
             Function conversion = new Function(descriptor.getName(), new Expression[] { rightExpr, const1 });
@@ -1601,21 +1596,18 @@
             return crit;
         }
         String format = (String)((Constant)formatExpr).getValue();
-        FunctionLibrary funcLib = FunctionLibraryManager.getFunctionLibrary();
+        FunctionLibrary funcLib = this.metadata.getFunctionLibrary();
         FunctionDescriptor descriptor = funcLib.findFunction(inverseFunction, new Class[] { rightExpr.getType(), formatExpr.getType() });
         if(descriptor == null){
             return crit;
         }
     	Object value = ((Constant)rightExpr).getValue();
     	try {
-    		Object result = funcLib.invokeFunction(descriptor, new Object[] {((Constant)rightExpr).getValue(), format});
-    		result = funcLib.invokeFunction(leftFunction.getFunctionDescriptor(), new Object[] { result, format } );
+    		Object result = descriptor.invokeFunction(new Object[] {((Constant)rightExpr).getValue(), format});
+    		result = leftFunction.getFunctionDescriptor().invokeFunction(new Object[] { result, format } );
     		if (((Comparable)value).compareTo(result) != 0) {
     			return getSimpliedCriteria(crit, leftExpr, crit.getOperator() != CompareCriteria.EQ, true);
     		}
-    	} catch(InvalidFunctionException e) {
-            String errorMsg = QueryExecPlugin.Util.getString("QueryRewriter.criteriaError", crit); //$NON-NLS-1$
-            throw new QueryValidatorException(e, errorMsg);
     	} catch(FunctionExecutionException e) {
             //Not all numeric formats are invertable, so just return the criteria as it may still be valid
             return crit;
@@ -1900,7 +1892,7 @@
                 Expression value = (Expression)variables.get(es.getCanonicalName());
 
                 if (value == null) {
-	                if (grpName.equals(ProcedureReservedWords.INPUT)) {
+	                if ((grpName.equals(ProcedureReservedWords.INPUT) || grpName.equals(ProcedureReservedWords.INPUTS))) {
 	                	return new Constant(null, es.getType());
 	                } 
 	                if (grpName.equals(ProcedureReservedWords.CHANGING)) {
@@ -1952,12 +1944,12 @@
 	}
     
     private Expression rewriteExpression(AggregateSymbol expression) {
-    	if (!expression.getAggregateFunction().equals(ReservedWords.COUNT)
-				&& !expression.getAggregateFunction().equals(ReservedWords.SUM)
+    	if (!expression.getAggregateFunction().equals(SQLReservedWords.COUNT)
+				&& !expression.getAggregateFunction().equals(SQLReservedWords.SUM)
 				&& EvaluatableVisitor.willBecomeConstant(expression.getExpression())) {
 			try {
 				return new ExpressionSymbol(expression.getName(), ResolverUtil
-						.convertExpression(expression.getExpression(),DataTypeManager.getDataTypeName(expression.getType())));
+						.convertExpression(expression.getExpression(),DataTypeManager.getDataTypeName(expression.getType()), metadata));
 			} catch (QueryResolverException e) {
 				//should not happen, so throw as a runtime
 				throw new MetaMatrixRuntimeException(e);
@@ -1989,6 +1981,7 @@
 			function.setName(actualName);
 		}
 		
+		FunctionLibrary funcLibrary = this.metadata.getFunctionLibrary();
 		Integer code = FUNCTION_MAP.get(functionLowerName);
 		if (code != null) {
 			switch (code) {
@@ -1997,7 +1990,7 @@
 						new Expression[] {new Constant(" "), function.getArg(0)}); //$NON-NLS-1$
 				//resolve the function
 				FunctionDescriptor descriptor = 
-		        	FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.REPEAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER});
+					funcLibrary.findFunction(SourceSystemFunctions.REPEAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER});
 				result.setFunctionDescriptor(descriptor);
 				result.setType(DataTypeManager.DefaultDataClasses.STRING);
 				function = result;
@@ -2005,10 +1998,10 @@
 			}
 			case 1: {//from_unixtime(a) => timestampadd(SQL_TSI_SECOND, a, new Timestamp(0)) 
 				Function result = new Function(FunctionLibrary.TIMESTAMPADD,
-						new Expression[] {new Constant(ReservedWords.SQL_TSI_SECOND), function.getArg(0), new Constant(new Timestamp(0)) });
+						new Expression[] {new Constant(SQLReservedWords.SQL_TSI_SECOND), function.getArg(0), new Constant(new Timestamp(0)) });
 				//resolve the function
 				FunctionDescriptor descriptor = 
-		        	FunctionLibraryManager.getFunctionLibrary().findFunction(FunctionLibrary.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
+					funcLibrary.findFunction(FunctionLibrary.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
 				result.setFunctionDescriptor(descriptor);
 				result.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
 				function = result;
@@ -2030,7 +2023,7 @@
 							new Expression[] {function.getArg(0), function.getArg(1) });
 					//resolve the function
 					FunctionDescriptor descriptor = 
-			        	FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.IFNULL, new Class[] { function.getType(), function.getType()  });
+						funcLibrary.findFunction(SourceSystemFunctions.IFNULL, new Class[] { function.getType(), function.getType()  });
 					result.setFunctionDescriptor(descriptor);
 					result.setType(function.getType());
 					function = result;
@@ -2046,14 +2039,14 @@
 					newArgs[i].setType(args[i].getType());
 					Assertion.assertTrue(args[i].getType() == DataTypeManager.DefaultDataClasses.STRING);
 			        FunctionDescriptor descriptor = 
-			        	FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.IFNULL, new Class[] { args[i].getType(), DataTypeManager.DefaultDataClasses.STRING });
+			        	funcLibrary.findFunction(SourceSystemFunctions.IFNULL, new Class[] { args[i].getType(), DataTypeManager.DefaultDataClasses.STRING });
 			        newArgs[i].setFunctionDescriptor(descriptor);
 				}
 				
 				Function concat = new Function(SourceSystemFunctions.CONCAT, newArgs);
 				concat.setType(DataTypeManager.DefaultDataClasses.STRING);
 				FunctionDescriptor descriptor = 
-		        	FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.CONCAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
+					funcLibrary.findFunction(SourceSystemFunctions.CONCAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
 				concat.setFunctionDescriptor(descriptor);
 				
 				List when = Arrays.asList(new Criteria[] {new CompoundCriteria(CompoundCriteria.AND, new IsNullCriteria(args[0]), new IsNullCriteria(args[1]))});
@@ -2067,33 +2060,33 @@
 			case 5: {
 				if (function.getType() != DataTypeManager.DefaultDataClasses.TIMESTAMP) {
 					FunctionDescriptor descriptor = 
-			        	FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
+						funcLibrary.findFunction(SourceSystemFunctions.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
 					function.setFunctionDescriptor(descriptor);
 					Class<?> type = function.getType();
 					function.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
-					function.getArgs()[2] = ResolverUtil.getConversion(function.getArg(2), DataTypeManager.getDataTypeName(type), DataTypeManager.DefaultDataTypes.TIMESTAMP, false);
-					function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false);
+					function.getArgs()[2] = ResolverUtil.getConversion(function.getArg(2), DataTypeManager.getDataTypeName(type), DataTypeManager.DefaultDataTypes.TIMESTAMP, false, funcLibrary);
+					function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false, funcLibrary);
 				}
 				break;
 			}
 			case 6:
 			case 7: {
 				FunctionDescriptor descriptor = 
-		        	FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.PARSETIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
+					funcLibrary.findFunction(SourceSystemFunctions.PARSETIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
 				function.setName(SourceSystemFunctions.PARSETIMESTAMP);
 				function.setFunctionDescriptor(descriptor);
 				Class<?> type = function.getType();
 				function.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
-				function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false);
+				function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false, funcLibrary);
 				break;
 			}
 			case 8:
 			case 9: {
 				FunctionDescriptor descriptor = 
-		        	FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.FORMATTIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP, DataTypeManager.DefaultDataClasses.STRING });
+					funcLibrary.findFunction(SourceSystemFunctions.FORMATTIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP, DataTypeManager.DefaultDataClasses.STRING });
 				function.setName(SourceSystemFunctions.FORMATTIMESTAMP);
 				function.setFunctionDescriptor(descriptor);
-				function.getArgs()[0] = ResolverUtil.getConversion(function.getArg(0), DataTypeManager.getDataTypeName(function.getArg(0).getType()), DataTypeManager.DefaultDataTypes.TIMESTAMP, false);
+				function.getArgs()[0] = ResolverUtil.getConversion(function.getArg(0), DataTypeManager.getDataTypeName(function.getArg(0).getType()), DataTypeManager.DefaultDataTypes.TIMESTAMP, false, funcLibrary);
 				break;
 			}
 			}
@@ -2366,7 +2359,7 @@
         for (SingleElementSymbol ses : actualSymbols) {
             actualTypes.add(ses.getType());
         }
-        List<SingleElementSymbol> selectSymbols = SetQuery.getTypedProjectedSymbols(ResolverUtil.resolveElementsInGroup(inlineGroup, tma), actualTypes);
+        List<SingleElementSymbol> selectSymbols = SetQuery.getTypedProjectedSymbols(ResolverUtil.resolveElementsInGroup(inlineGroup, tma), actualTypes, tma);
         Iterator<SingleElementSymbol> iter = actualSymbols.iterator();
         for (SingleElementSymbol ses : selectSymbols) {
         	ses = (SingleElementSymbol)ses.clone();
@@ -2471,7 +2464,7 @@
         Boolean result = null;
         for (ElementSymbol var : ElementCollectorVisitor.getElements(expr, false)) {
             String grpName = var.getGroupSymbol().getName();
-            if (var.isExternalReference() && grpName.equals(ProcedureReservedWords.INPUT)) {
+            if (var.isExternalReference() && (grpName.equalsIgnoreCase(ProcedureReservedWords.INPUT) || grpName.equalsIgnoreCase(ProcedureReservedWords.INPUTS))) {
                 
                 String changingKey = ProcedureReservedWords.CHANGING + ElementSymbol.SEPARATOR + var.getShortCanonicalName();
                 

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,15 +22,21 @@
 
 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 {
 
-    public static final String INPUT = "INPUT"; //$NON-NLS-1$
+	@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$
 
@@ -38,29 +44,25 @@
 
     public static final String VARIABLES = "VARIABLES"; //$NON-NLS-1$
     
-    public static final String USING = "USING"; //$NON-NLS-1$
-
-    public static final String[] ALL_WORDS = new String[] {
-        INPUT,
-        ROWS_UPDATED,
-        CHANGING,
-        VARIABLES,
-        USING
-    };        
-
+    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 PROCEDURE_RESERVED_WORDS = new HashSet();
+ 	 * 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 PROCEDURE_RESERVED_WORDS set
-    static {
-        // Iterate through the reserved words and capitalize all of them
-        for ( int i=0; i!=ProcedureReservedWords.ALL_WORDS.length; ++i ) {
-            String reservedWord = ProcedureReservedWords.ALL_WORDS[i];
-            ProcedureReservedWords.PROCEDURE_RESERVED_WORDS.add( reservedWord.toUpperCase() );    
-        } 
-    }
+    // 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() {}
@@ -74,6 +76,6 @@
         if (str == null) { 
             return false;    
         }
-        return PROCEDURE_RESERVED_WORDS.contains(str.toUpperCase());    
+        return RESERVED_WORDS.contains(str.toUpperCase());    
     }
 }

Deleted: trunk/engine/src/main/java/com/metamatrix/query/sql/ReservedWords.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/ReservedWords.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/ReservedWords.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,296 +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.util.Set;
-import java.util.HashSet;
-
-public class ReservedWords {
-
-    public static final String ANY = "ANY"; //$NON-NLS-1$
-    public static final String ALL = "ALL"; //$NON-NLS-1$
-    public static final String ALL_COLS = "*"; //$NON-NLS-1$
-    public static final String AND = "AND"; //$NON-NLS-1$
-    public static final String AS = "AS"; //$NON-NLS-1$
-    public static final String ASC = "ASC"; //$NON-NLS-1$
-	public static final String AVG = "AVG"; //$NON-NLS-1$
-    public static final String BEGIN = "BEGIN"; //$NON-NLS-1$
-    public static final String BETWEEN = "BETWEEN"; //$NON-NLS-1$
-	public static final String BIGDECIMAL = "BIGDECIMAL"; //$NON-NLS-1$
-	public static final String BIGINTEGER = "BIGINTEGER"; //$NON-NLS-1$
-    public static final String BLOB = "BLOB"; //$NON-NLS-1$
-    public static final String BREAK = "BREAK"; //$NON-NLS-1$
-	public static final String BY = "BY"; //$NON-NLS-1$
-    public static final String BYTE = "BYTE"; //$NON-NLS-1$
-    public static final String CASE = "CASE"; //$NON-NLS-1$
-	public static final String CAST = "CAST"; //$NON-NLS-1$
-	public static final String CHAR = "CHAR"; //$NON-NLS-1$
-    public static final String CLOB = "CLOB"; //$NON-NLS-1$
-    public static final String CONVERT = "CONVERT"; //$NON-NLS-1$
-    public static final String CONTINUE = "CONTINUE"; //$NON-NLS-1$
-	public static final String COUNT = "COUNT"; //$NON-NLS-1$
-    public static final String CRITERIA = "CRITERIA"; //$NON-NLS-1$
-    public static final String CREATE = "CREATE"; //$NON-NLS-1$
-    public static final String CROSS = "CROSS"; //$NON-NLS-1$
-    public static final String DATE = "DATE"; //$NON-NLS-1$
-    public static final String DEBUG = "DEBUG"; //$NON-NLS-1$
-    public static final String DECLARE = "DECLARE";     //$NON-NLS-1$
-	public static final String DELETE = "DELETE"; //$NON-NLS-1$
-    public static final String DESC = "DESC"; //$NON-NLS-1$
-	public static final String DISTINCT = "DISTINCT"; //$NON-NLS-1$
-	public static final String DOUBLE = "DOUBLE"; //$NON-NLS-1$
-    public static final String DROP = "DROP"; //$NON-NLS-1$
-	public static final String ELSE = "ELSE";	 //$NON-NLS-1$
-	public static final String END = "END"; //$NON-NLS-1$
-	public static final String ERROR = "ERROR";	 //$NON-NLS-1$
-    public static final String ESCAPE = "ESCAPE"; //$NON-NLS-1$
-    public static final String EXCEPT = "EXCEPT"; //$NON-NLS-1$
-    public static final String EXEC = "EXEC"; //$NON-NLS-1$
-    public static final String EXECUTE = "EXECUTE"; //$NON-NLS-1$
-    public static final String EXISTS = "EXISTS"; //$NON-NLS-1$
-    public static final String FALSE = "FALSE"; //$NON-NLS-1$
-    public static final String FLOAT = "FLOAT"; //$NON-NLS-1$
-    public static final String FOR = "FOR";     //$NON-NLS-1$
-	public static final String FROM = "FROM"; //$NON-NLS-1$
-    public static final String FULL = "FULL"; //$NON-NLS-1$
-	public static final String GROUP = "GROUP"; //$NON-NLS-1$
-	public static final String HAS = "HAS";	 //$NON-NLS-1$
-    public static final String HAVING = "HAVING"; //$NON-NLS-1$
-    public static final String IF = "IF";     //$NON-NLS-1$
-    public static final String IN = "IN"; //$NON-NLS-1$
-    public static final String INNER = "INNER"; //$NON-NLS-1$
-    public static final String INSERT = "INSERT"; //$NON-NLS-1$
-    public static final String INTEGER = "INTEGER"; //$NON-NLS-1$
-    public static final String INTERSECT = "INTERSECT"; //$NON-NLS-1$
-    public static final String INTO = "INTO"; //$NON-NLS-1$
-    public static final String IS = "IS";     //$NON-NLS-1$
-    public static final String JOIN = "JOIN"; //$NON-NLS-1$
-    public static final String LEFT = "LEFT"; //$NON-NLS-1$
-    public static final String LIKE = "LIKE"; //$NON-NLS-1$
-    public static final String LIMIT = "LIMIT"; //$NON-NLS-1$
-    public static final String LOCAL = "LOCAL"; //$NON-NLS-1$
-    public static final String LONG = "LONG"; //$NON-NLS-1$
-    public static final String LOOP = "LOOP"; //$NON-NLS-1$
-    public static final String MAKEDEP = "MAKEDEP"; //$NON-NLS-1$
-    public static final String MAKENOTDEP = "MAKENOTDEP"; //$NON-NLS-1$
-	public static final String MIN = "MIN"; //$NON-NLS-1$
-	public static final String MAX = "MAX"; //$NON-NLS-1$
-    public static final String NOCACHE = "NOCACHE"; //$NON-NLS-1$
-    public static final String NOT = "NOT"; //$NON-NLS-1$
-    public static final String NULL = "NULL"; //$NON-NLS-1$
-    public static final String OBJECT = "OBJECT"; //$NON-NLS-1$
-	public static final String ON = "ON"; //$NON-NLS-1$
-    public static final String OR = "OR"; //$NON-NLS-1$
-	public static final String ORDER = "ORDER"; //$NON-NLS-1$
-    public static final String OPTION = "OPTION"; //$NON-NLS-1$
-    public static final String OUTER = "OUTER"; //$NON-NLS-1$
-    public static final String PROCEDURE = "PROCEDURE"; //$NON-NLS-1$
-    public static final String PLANONLY = "PLANONLY"; //$NON-NLS-1$
-    public static final String RIGHT = "RIGHT"; //$NON-NLS-1$
-	public static final String SELECT = "SELECT"; //$NON-NLS-1$
-    public static final String SET = "SET"; //$NON-NLS-1$
-    public static final String SHORT = "SHORT"; //$NON-NLS-1$
-    public static final String SHOWPLAN = "SHOWPLAN"; //$NON-NLS-1$
-    public static final String SOME = "SOME"; //$NON-NLS-1$
-    public static final String SQL_TSI_FRAC_SECOND = "SQL_TSI_FRAC_SECOND"; //$NON-NLS-1$
-    public static final String SQL_TSI_SECOND = "SQL_TSI_SECOND"; //$NON-NLS-1$
-    public static final String SQL_TSI_MINUTE = "SQL_TSI_MINUTE"; //$NON-NLS-1$
-    public static final String SQL_TSI_HOUR = "SQL_TSI_HOUR"; //$NON-NLS-1$
-    public static final String SQL_TSI_DAY = "SQL_TSI_DAY"; //$NON-NLS-1$
-    public static final String SQL_TSI_WEEK = "SQL_TSI_WEEK"; //$NON-NLS-1$
-    public static final String SQL_TSI_MONTH = "SQL_TSI_MONTH"; //$NON-NLS-1$
-    public static final String SQL_TSI_QUARTER = "SQL_TSI_QUARTER"; //$NON-NLS-1$
-    public static final String SQL_TSI_YEAR = "SQL_TSI_YEAR"; //$NON-NLS-1$
-    public static final String STRING = "STRING"; //$NON-NLS-1$
-	public static final String SUM = "SUM"; //$NON-NLS-1$
-    public static final String TABLE = "TABLE"; //$NON-NLS-1$
-    public static final String TEMPORARY = "TEMPORARY"; //$NON-NLS-1$
-    public static final String THEN = "THEN"; //$NON-NLS-1$
-    public static final String TIME = "TIME"; //$NON-NLS-1$
-	public static final String TIMESTAMP = "TIMESTAMP"; //$NON-NLS-1$
-    public static final String TIMESTAMPADD = "TIMESTAMPADD"; //$NON-NLS-1$
-    public static final String TIMESTAMPDIFF = "TIMESTAMPDIFF"; //$NON-NLS-1$
-	public static final String TRANSLATE = "TRANSLATE";	 //$NON-NLS-1$
-    public static final String TRUE = "TRUE"; //$NON-NLS-1$
-    public static final String UNION = "UNION"; //$NON-NLS-1$
-    public static final String UNKNOWN = "UNKNOWN"; //$NON-NLS-1$
-	public static final String UPDATE = "UPDATE"; //$NON-NLS-1$
-	public static final String USING = "USING";	 //$NON-NLS-1$
-    public static final String VALUES = "VALUES"; //$NON-NLS-1$
-    public static final String VIRTUAL = "VIRTUAL"; //$NON-NLS-1$
-    public static final String VIRTUAL_DEP_JOIN = "VIRTUALDEP";  //$NON-NLS-1$  
-    public static final String WHEN = "WHEN";     //$NON-NLS-1$
-    public static final String WITH = "WITH";     //$NON-NLS-1$
-	public static final String WHERE = "WHERE"; //$NON-NLS-1$
-    public static final String WHILE = "WHILE"; //$NON-NLS-1$
-    public static final String XML = "XML"; //$NON-NLS-1$
-
-    public static final String[] ALL_WORDS = new String[] {
-        ALL,
-        ALL_COLS,
-        AND,
-        ANY,
-        AS,
-        ASC,
-        AVG,
-        BEGIN,
-        BETWEEN,
-        BIGINTEGER,
-        BIGDECIMAL,
-        BLOB,
-        BREAK,
-        BY,
-        BYTE,
-        CASE,
-        CAST,
-        CHAR,
-        CLOB,
-        CONVERT,
-        CONTINUE,
-        COUNT,
-		CREATE,
-		CRITERIA,
-        CROSS,
-        DATE,
-        DEBUG,
-        DECLARE,
-        DELETE,
-        DESC,
-        DISTINCT,
-        DOUBLE,
-        DROP,
-        ELSE,
-        END,
-        ERROR,        
-        ESCAPE,
-        EXCEPT,
-        EXEC,
-        EXECUTE,
-        EXISTS,
-        FALSE,
-        FLOAT,
-		FOR,
-        FROM,
-        FULL,
-        GROUP,
-        HAS,
-        HAVING,
-        IF,
-        IN,
-        INNER,
-        INSERT,
-        INTEGER,
-        INTERSECT,
-        INTO,
-        IS,    
-        JOIN,
-        LEFT,
-        LIKE,
-        LIMIT,
-        LOCAL,
-        LONG,
-        LOOP,
-        MAKEDEP,
-        MAKENOTDEP,
-        MIN,
-        MAX,
-        NOCACHE,
-        NOT,
-        NULL,
-        OBJECT,
-        ON,
-        OR,
-        ORDER,
-        OPTION,
-        OUTER,
-        PLANONLY,
-		PROCEDURE,
-        RIGHT,
-        SELECT,
-        SET,
-        SHORT,
-        SHOWPLAN,
-        SOME,
-        SQL_TSI_FRAC_SECOND,
-        SQL_TSI_SECOND,
-        SQL_TSI_MINUTE,
-        SQL_TSI_HOUR,
-        SQL_TSI_DAY,
-        SQL_TSI_WEEK,
-        SQL_TSI_MONTH,
-        SQL_TSI_QUARTER,
-        SQL_TSI_YEAR,        
-        STRING,
-        SUM,
-        TABLE,
-        TEMPORARY,
-        THEN,
-		TIME,
-		TIMESTAMP,
-        TIMESTAMPADD,
-        TIMESTAMPDIFF,
-		TRANSLATE,
-        TRUE,
-        UNION,
-        UNKNOWN,
-        UPDATE,
-        USING,   
-        VALUES,
-        VIRTUAL,
-        VIRTUAL_DEP_JOIN,
-        WHEN,
-        WITH,    
-        WHERE,
-        WHILE,
-        XML,
-    };        
-
-    /**
- 	 * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
- 	 */
-    private static final Set RESERVED_WORDS = new HashSet();
-
-    // Initialize RESERVED_WORDS set
- 	static {
- 	    // Iterate through the reserved words and capitalize all of them
- 	    for ( int i=0; i!=ReservedWords.ALL_WORDS.length; ++i ) {
- 	    	String reservedWord = ReservedWords.ALL_WORDS[i];
- 	    	ReservedWords.RESERVED_WORDS.add( reservedWord.toUpperCase() );    
- 	    } 
- 	}
-
- 	/** Can't construct */
- 	private ReservedWords() {}   
-
- 	/**
- 	 * Check whether a string is a reserved word.  
- 	 * @param str String to check
- 	 * @return True if reserved word, false if not or null
- 	 */
- 	public static final boolean isReservedWord(String str) {
- 		if(str == null) { 
- 			return false;    
- 		}
- 		return RESERVED_WORDS.contains(str.toUpperCase());    
- 	}
-}

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Insert.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Insert.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Insert.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -239,6 +239,9 @@
             ElementSymbol symbol = (ElementSymbol)((ElementSymbol)variables.get( j )).clone();
             symbol.setName(ProcedureReservedWords.INPUT + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
             map.put(symbol, values.get( j ) );
+            symbol = (ElementSymbol)((ElementSymbol)variables.get( j )).clone();
+            symbol.setName(ProcedureReservedWords.INPUTS + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
+            map.put(symbol, values.get( j ) );
         } // for 
         return map;
     }

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,6 +24,8 @@
 
 import java.util.*;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.core.util.HashCodeUtil;
 import com.metamatrix.query.sql.*;
 import com.metamatrix.core.util.EquivalenceUtil;
@@ -36,8 +38,8 @@
  */
 public class Option implements LanguageObject {
     
-    public final static String MAKEDEP = ReservedWords.MAKEDEP; 
-    public final static String MAKENOTDEP = ReservedWords.MAKENOTDEP; 
+    public final static String MAKEDEP = SQLReservedWords.MAKEDEP; 
+    public final static String MAKENOTDEP = SQLReservedWords.MAKENOTDEP; 
     public final static String OPTIONAL = "optional"; //$NON-NLS-1$
 
 	private boolean showPlan = false;

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SPParameter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SPParameter.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SPParameter.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -179,23 +179,6 @@
     }
 
     /**
-     * This is a helper method to get the value of this parameter when the expression
-     * is a constant.  It may throw IllegalStateException if used when the expression
-     * is not a Constant.
-     * @return Value of this parameter
-     */
-    public Object getValue() {
-        if(this.expression == null) {
-            return null;
-        }
-        try {
-            return Evaluator.evaluate(this.expression);
-        } catch (MetaMatrixException err) {
-            throw new MetaMatrixRuntimeException(err);
-        }
-    }
-
-    /**
      * Set the positional index of this parameter
      * @param index The positional index of this parameter
      */

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -62,6 +62,7 @@
     private QueryCommand rightQuery;
     
     private List<Class<?>> projectedTypes = null;  //set during resolving
+    private QueryMetadataInterface metadata = null; // set during resolving
      
     /**
      * Construct query with operation type
@@ -123,12 +124,12 @@
 	    Query query = getProjectedQuery();
 	    List projectedSymbols = query.getProjectedSymbols();
         if (projectedTypes != null) {
-            return getTypedProjectedSymbols(projectedSymbols, projectedTypes);
+            return getTypedProjectedSymbols(projectedSymbols, projectedTypes, metadata);
         } 
         return projectedSymbols;
     }
     
-    public static List getTypedProjectedSymbols(List acutal, List projectedTypes) {
+    public static List getTypedProjectedSymbols(List acutal, List projectedTypes, QueryMetadataInterface metadata) {
         List newProject = new ArrayList();
         for (int i = 0; i < acutal.size(); i++) {
             SingleElementSymbol originalSymbol = (SingleElementSymbol)acutal.get(i);
@@ -145,7 +146,7 @@
                 } 
                 
                 try {
-                    symbol = new ExpressionSymbol(originalSymbol.getShortName(), ResolverUtil.convertExpression(expr, DataTypeManager.getDataTypeName(type)));
+                    symbol = new ExpressionSymbol(originalSymbol.getShortName(), ResolverUtil.convertExpression(expr, DataTypeManager.getDataTypeName(type), metadata));
                 } catch (QueryResolverException err) {
                     throw new MetaMatrixRuntimeException(err);
                 }
@@ -182,7 +183,7 @@
         }
         
         if (this.projectedTypes != null) {
-        	copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes));
+        	copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes), this.metadata);
         }
          
         return copy;
@@ -252,8 +253,9 @@
     /** 
      * @param projectedSymbols The projectedSymbols to set.
      */
-    public void setProjectedTypes(List<Class<?>> projectedTypes) {
+    public void setProjectedTypes(List<Class<?>> projectedTypes, QueryMetadataInterface metadata) {
         this.projectedTypes = projectedTypes;
+        this.metadata = metadata;
     }
 
     /** 

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Update.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Update.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Update.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -267,7 +267,9 @@
             ElementSymbol symbol = (ElementSymbol)(setClause.getSymbol()).clone();
             symbol.setName(ProcedureReservedWords.INPUT + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
             map.put( symbol, setClause.getValue() );
-            
+            symbol = (ElementSymbol)(setClause.getSymbol()).clone();
+            symbol.setName(ProcedureReservedWords.INPUTS + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
+            map.put( symbol, setClause.getValue() );
         } // for
         
         return map;

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/proc/RaiseErrorStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/RaiseErrorStatement.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/proc/RaiseErrorStatement.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
 
 package com.metamatrix.query.sql.proc;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
 import com.metamatrix.query.sql.symbol.Expression;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
@@ -57,10 +58,10 @@
          * matter that it has an invalid ID or GroupSymbol.  Setting the type to
          * String allows for the expression to be converted to String as necessary.
          */
-        ElementSymbol result = new ElementSymbol(ReservedWords.ERROR);
-        result.setMetadataID(ReservedWords.ERROR);
+        ElementSymbol result = new ElementSymbol(SQLReservedWords.ERROR);
+        result.setMetadataID(SQLReservedWords.ERROR);
         result.setType(String.class);
-        result.setGroupSymbol(new GroupSymbol(ReservedWords.ERROR));
+        result.setGroupSymbol(new GroupSymbol(SQLReservedWords.ERROR));
         return result;
     }
     

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AggregateSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AggregateSymbol.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AggregateSymbol.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,12 +27,13 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.core.util.EquivalenceUtil;
 import com.metamatrix.core.util.HashCodeUtil;
 import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.util.ErrorMessageKeys;
 
 /**
@@ -66,11 +67,11 @@
 
 	static {
 		AGGREGATE_FUNCTIONS = new HashSet();
-		AGGREGATE_FUNCTIONS.add(ReservedWords.COUNT);
-		AGGREGATE_FUNCTIONS.add(ReservedWords.SUM);
-		AGGREGATE_FUNCTIONS.add(ReservedWords.AVG);
-		AGGREGATE_FUNCTIONS.add(ReservedWords.MIN);
-		AGGREGATE_FUNCTIONS.add(ReservedWords.MAX);
+		AGGREGATE_FUNCTIONS.add(SQLReservedWords.COUNT);
+		AGGREGATE_FUNCTIONS.add(SQLReservedWords.SUM);
+		AGGREGATE_FUNCTIONS.add(SQLReservedWords.AVG);
+		AGGREGATE_FUNCTIONS.add(SQLReservedWords.MIN);
+		AGGREGATE_FUNCTIONS.add(SQLReservedWords.MAX);
 
 		SUM_TYPES = new HashMap();
 		SUM_TYPES.put(DataTypeManager.DefaultDataClasses.BYTE, DataTypeManager.DefaultDataClasses.LONG);
@@ -109,7 +110,7 @@
 	/**
 	 * Construct an aggregate symbol with all given data.
 	 * @param name Name of the function
-	 * @param aggregateFunction Aggregate function type ({@link com.metamatrix.query.sql.ReservedWords#COUNT}, etc)
+	 * @param aggregateFunction Aggregate function type ({@link org.teiid.connector.language.SQLReservedWords#COUNT}, etc)
 	 * @param isDistinct True if DISTINCT flag is set
 	 * @param expression Contained expression
 	 */
@@ -119,16 +120,16 @@
 		setAggregateFunction(aggregateFunction);
 		this.distinct = isDistinct;
 	}
-
+	
 	/**
 	 * Set the aggregate function.  If the aggregate function is an invalid value, an
 	 * IllegalArgumentException is thrown.
 	 * @param aggregateFunction Aggregate function type
-	 * @see com.metamatrix.query.sql.ReservedWords#COUNT
-	 * @see com.metamatrix.query.sql.ReservedWords#SUM
-	 * @see com.metamatrix.query.sql.ReservedWords#AVG
-	 * @see com.metamatrix.query.sql.ReservedWords#MIN
-	 * @see com.metamatrix.query.sql.ReservedWords#MAX
+	 * @see org.teiid.connector.language.SQLReservedWords#COUNT
+	 * @see org.teiid.connector.language.SQLReservedWords#SUM
+	 * @see org.teiid.connector.language.SQLReservedWords#AVG
+	 * @see org.teiid.connector.language.SQLReservedWords#MIN
+	 * @see org.teiid.connector.language.SQLReservedWords#MAX
 	 */
 	private void setAggregateFunction(String aggregateFunction) {
 		// Validate aggregate
@@ -142,11 +143,11 @@
 	 * Get the aggregate function type - this will map to one of the reserved words
 	 * for the aggregate functions.
 	 * @return Aggregate function type
-	 * @see com.metamatrix.query.sql.ReservedWords#COUNT
-	 * @see com.metamatrix.query.sql.ReservedWords#SUM
-	 * @see com.metamatrix.query.sql.ReservedWords#AVG
-	 * @see com.metamatrix.query.sql.ReservedWords#MIN
-	 * @see com.metamatrix.query.sql.ReservedWords#MAX
+	 * @see org.teiid.connector.language.SQLReservedWords#COUNT
+	 * @see org.teiid.connector.language.SQLReservedWords#SUM
+	 * @see org.teiid.connector.language.SQLReservedWords#AVG
+	 * @see org.teiid.connector.language.SQLReservedWords#MIN
+	 * @see org.teiid.connector.language.SQLReservedWords#MAX
 	 */
 	public String getAggregateFunction() {
 		return this.aggregate;
@@ -167,12 +168,12 @@
 	 * @return Type of the symbol
 	 */
 	public Class getType() {
-		if(this.aggregate.equals(ReservedWords.COUNT)) {
+		if(this.aggregate.equals(SQLReservedWords.COUNT)) {
 			return COUNT_TYPE;
-		} else if(this.aggregate.equals(ReservedWords.SUM) ) {
+		} else if(this.aggregate.equals(SQLReservedWords.SUM) ) {
 			Class expressionType = this.getExpression().getType();
 			return (Class) SUM_TYPES.get(expressionType);
-        } else if (this.aggregate.equals(ReservedWords.AVG)) {
+        } else if (this.aggregate.equals(SQLReservedWords.AVG)) {
             Class expressionType = this.getExpression().getType();
             return (Class) AVG_TYPES.get(expressionType);
 		} else {

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/UpdateProcedureGenerator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/UpdateProcedureGenerator.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/UpdateProcedureGenerator.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -186,7 +186,7 @@
                     // Construct properly named INPUT variable based on short name of virtual element
                     String virtualElementName = metadata.getFullName(virtualElements.get(i));
                     String virtualElementShortName = metadata.getShortElementName(virtualElementName);
-                    ElementSymbol inputElement = new ElementSymbol(ProcedureReservedWords.INPUT + "." + virtualElementShortName); //$NON-NLS-1$
+                    ElementSymbol inputElement = new ElementSymbol(ProcedureReservedWords.INPUTS + "." + virtualElementShortName); //$NON-NLS-1$
                     values.add(inputElement);
                 }
             }

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,11 +29,13 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.connector.language.SQLReservedWords.Tokens;
+
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.core.util.StringUtil;
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.BetweenCriteria;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -177,43 +179,43 @@
         parts.add(SPACE);
         
         if (obj.isNegated()) {
-            parts.add(ReservedWords.NOT);
+            parts.add(SQLReservedWords.NOT);
             parts.add(SPACE);
         }
-        parts.add(ReservedWords.BETWEEN);
+        parts.add(SQLReservedWords.BETWEEN);
         parts.add(SPACE);
         parts.add(registerNode(obj.getLowerExpression()));
 
         parts.add(SPACE);
-        parts.add(ReservedWords.AND);
+        parts.add(SQLReservedWords.AND);
         parts.add(SPACE);
         parts.add(registerNode(obj.getUpperExpression()));
     }
 
     public void visit(CaseExpression obj) {
-        parts.add(ReservedWords.CASE);
+        parts.add(SQLReservedWords.CASE);
         parts.add(SPACE);
         parts.add(registerNode(obj.getExpression()) ); 
         parts.add(SPACE);
 
         for (int i = 0; i < obj.getWhenCount(); i++) {
-            parts.add(ReservedWords.WHEN);
+            parts.add(SQLReservedWords.WHEN);
             parts.add(SPACE);
             parts.add(registerNode(obj.getWhenExpression(i)) );
             parts.add(SPACE);
-            parts.add(ReservedWords.THEN);
+            parts.add(SQLReservedWords.THEN);
             parts.add(SPACE);
             parts.add(registerNode(obj.getThenExpression(i)));
             parts.add(SPACE);
         }
 
         if (obj.getElseExpression() != null) {
-            parts.add(ReservedWords.ELSE);
+            parts.add(SQLReservedWords.ELSE);
             parts.add(SPACE);
             parts.add(registerNode(obj.getElseExpression()));
             parts.add(SPACE);
         }
-        parts.add(ReservedWords.END);
+        parts.add(SQLReservedWords.END);
     }
 
     public void visit(CompareCriteria obj) {
@@ -233,9 +235,9 @@
         int operator = obj.getOperator();
         String operatorStr = ""; //$NON-NLS-1$
         if(operator == CompoundCriteria.AND) {
-            operatorStr = ReservedWords.AND;
+            operatorStr = SQLReservedWords.AND;
         } else if(operator == CompoundCriteria.OR) {
-            operatorStr = ReservedWords.OR;
+            operatorStr = SQLReservedWords.OR;
         }
 
         // Get criteria
@@ -283,17 +285,17 @@
 
     public void visit(Delete obj) {
 		//add delete clause
-		parts.add(ReservedWords.DELETE);
+		parts.add(SQLReservedWords.DELETE);
 		parts.add(SPACE);
 		//add from clause
-		parts.add(ReservedWords.FROM);
+		parts.add(SQLReservedWords.FROM);
 		parts.add(SPACE);
 		parts.add(registerNode(obj.getGroup()));
 
 		//add where clause
 		if(obj.getCriteria() != null) {
 			parts.add(SPACE);
-			parts.add(ReservedWords.WHERE);
+			parts.add(SQLReservedWords.WHERE);
 			parts.add(SPACE);
 			parts.add(registerNode(obj.getCriteria()));
 		}
@@ -311,10 +313,10 @@
         // operator and beginning of list
         parts.add(SPACE);
         if (obj.isNegated()) {
-            parts.add(ReservedWords.NOT);
+            parts.add(SQLReservedWords.NOT);
             parts.add(SPACE);
         }
-        parts.add(ReservedWords.IN);
+        parts.add(SQLReservedWords.IN);
         parts.add(" (<dependent values>)"); //$NON-NLS-1$
     }
 
@@ -323,13 +325,13 @@
         List clauses = obj.getClauses();
         if(clauses.size() == 1) {
             replaceStringParts(new Object[] {
-                ReservedWords.FROM, SPACE,
+                SQLReservedWords.FROM, SPACE,
                 registerNode( (FromClause) clauses.get(0) ) });
         } else if(clauses.size() > 1) {
             parts = new Object[2 + clauses.size() + (clauses.size()-1)];
 
             // Add first clause
-            parts[0] = ReservedWords.FROM;
+            parts[0] = SQLReservedWords.FROM;
             parts[1] = SPACE;
             Iterator clauseIter = clauses.iterator();
             parts[2] = registerNode((FromClause) clauseIter.next());
@@ -343,7 +345,7 @@
             replaceStringParts(parts);
         } else {
             // Shouldn't happen, but being tolerant
-            replaceStringParts(new Object[] { ReservedWords.FROM });
+            replaceStringParts(new Object[] { SQLReservedWords.FROM });
         }
     }
 
@@ -352,15 +354,15 @@
         List symbols = obj.getSymbols();
         if(symbols.size() == 1) {
             replaceStringParts(new Object[] {
-                ReservedWords.GROUP, SPACE, ReservedWords.BY, SPACE,
+                SQLReservedWords.GROUP, SPACE, SQLReservedWords.BY, SPACE,
                 registerNode( (Expression) symbols.get(0) ) });
         } else if(symbols.size() > 1) {
             parts = new Object[4 + symbols.size() + (symbols.size()-1)];
 
             // Add first clause
-            parts[0] = ReservedWords.GROUP;
+            parts[0] = SQLReservedWords.GROUP;
             parts[1] = SPACE;
-            parts[2] = ReservedWords.BY;
+            parts[2] = SQLReservedWords.BY;
             parts[3] = SPACE;
             Iterator symbolIter = symbols.iterator();
             parts[4] = registerNode((Expression) symbolIter.next());
@@ -374,7 +376,7 @@
             replaceStringParts(parts);
         } else {
             // Shouldn't happen, but being tolerant
-            replaceStringParts(new Object[] { ReservedWords.GROUP, SPACE, ReservedWords.BY });
+            replaceStringParts(new Object[] { SQLReservedWords.GROUP, SPACE, SQLReservedWords.BY });
         }
     }
 
@@ -384,7 +386,7 @@
         if ( obj.getQueryExpression() != null ) {
             parts.add(registerNode(obj.getQueryExpression()));
         } else {
-            parts.add(ReservedWords.VALUES);
+            parts.add(SQLReservedWords.VALUES);
             parts.add(" ("); //$NON-NLS-1$
             Iterator valueIter = obj.getValues().iterator();
             while(valueIter.hasNext()) {
@@ -405,13 +407,13 @@
     }
 
     public void visit(Create obj) {
-        parts.add(ReservedWords.CREATE);
+        parts.add(SQLReservedWords.CREATE);
         parts.add(SPACE);
-        parts.add(ReservedWords.LOCAL);
+        parts.add(SQLReservedWords.LOCAL);
         parts.add(SPACE);
-        parts.add(ReservedWords.TEMPORARY);
+        parts.add(SQLReservedWords.TEMPORARY);
         parts.add(SPACE);
-        parts.add(ReservedWords.TABLE);
+        parts.add(SQLReservedWords.TABLE);
         parts.add(SPACE);
         parts.add(registerNode(obj.getTable()));
         parts.add(SPACE);
@@ -434,17 +436,17 @@
     }
     
     public void visit(Drop obj) {
-        parts.add(ReservedWords.DROP);
+        parts.add(SQLReservedWords.DROP);
         parts.add(SPACE);
-        parts.add(ReservedWords.TABLE);
+        parts.add(SQLReservedWords.TABLE);
         parts.add(SPACE);
         parts.add(registerNode(obj.getTable()));
     }
     
     private void formatBasicInsert(Insert obj) {
-        parts.add(ReservedWords.INSERT);
+        parts.add(SQLReservedWords.INSERT);
         parts.add(SPACE);
-        parts.add(ReservedWords.INTO);
+        parts.add(SQLReservedWords.INTO);
         parts.add(SPACE);
         parts.add(registerNode(obj.getGroup()));
         parts.add(SPACE);
@@ -473,13 +475,13 @@
         Object exprPart = registerNode(expr);
         parts.add(exprPart);
         parts.add(SPACE);
-        parts.add(ReservedWords.IS);
+        parts.add(SQLReservedWords.IS);
         parts.add(SPACE);
         if (obj.isNegated()) {
-            parts.add(ReservedWords.NOT);
+            parts.add(SQLReservedWords.NOT);
             parts.add(SPACE);
         }
-        parts.add(ReservedWords.NULL);
+        parts.add(SQLReservedWords.NULL);
     }
 
     public void visit(JoinPredicate obj) {
@@ -518,7 +520,7 @@
         List joinCriteria = obj.getJoinCriteria();
 		if(joinCriteria != null && joinCriteria.size() > 0) {
             parts.add(SPACE);
-			parts.add(ReservedWords.ON);
+			parts.add(SQLReservedWords.ON);
             parts.add(SPACE);
 			Iterator critIter = joinCriteria.iterator();
 			while(critIter.hasNext()) {
@@ -533,7 +535,7 @@
 
 				if(critIter.hasNext()) {
 					parts.add(SPACE);
-					parts.add(ReservedWords.AND);
+					parts.add(SQLReservedWords.AND);
 					parts.add(SPACE);
 				}
 			}
@@ -570,21 +572,21 @@
     public void visit(JoinType obj) {
         Object[] parts = null;
         if(obj.equals(JoinType.JOIN_INNER)) {
-            parts = new Object[] { ReservedWords.INNER, SPACE, ReservedWords.JOIN };
+            parts = new Object[] { SQLReservedWords.INNER, SPACE, SQLReservedWords.JOIN };
         } else if(obj.equals(JoinType.JOIN_CROSS)) {
-            parts = new Object[] { ReservedWords.CROSS, SPACE, ReservedWords.JOIN };
+            parts = new Object[] { SQLReservedWords.CROSS, SPACE, SQLReservedWords.JOIN };
         } else if(obj.equals(JoinType.JOIN_LEFT_OUTER)) {
-            parts = new Object[] { ReservedWords.LEFT, SPACE, ReservedWords.OUTER, SPACE, ReservedWords.JOIN };
+            parts = new Object[] { SQLReservedWords.LEFT, SPACE, SQLReservedWords.OUTER, SPACE, SQLReservedWords.JOIN };
         } else if(obj.equals(JoinType.JOIN_RIGHT_OUTER)) {
-            parts = new Object[] { ReservedWords.RIGHT, SPACE, ReservedWords.OUTER, SPACE, ReservedWords.JOIN };
+            parts = new Object[] { SQLReservedWords.RIGHT, SPACE, SQLReservedWords.OUTER, SPACE, SQLReservedWords.JOIN };
         } else if(obj.equals(JoinType.JOIN_FULL_OUTER)) {
-            parts = new Object[] { ReservedWords.FULL, SPACE, ReservedWords.OUTER, SPACE, ReservedWords.JOIN };
+            parts = new Object[] { SQLReservedWords.FULL, SPACE, SQLReservedWords.OUTER, SPACE, SQLReservedWords.JOIN };
         } else if(obj.equals(JoinType.JOIN_UNION)) {
-            parts = new Object[] { ReservedWords.UNION, SPACE, ReservedWords.JOIN };
+            parts = new Object[] { SQLReservedWords.UNION, SPACE, SQLReservedWords.JOIN };
         } else if (obj.equals(JoinType.JOIN_SEMI)) {
-            parts = new Object[] { "SEMI", SPACE, ReservedWords.JOIN }; //$NON-NLS-1$
+            parts = new Object[] { "SEMI", SPACE, SQLReservedWords.JOIN }; //$NON-NLS-1$
         } else if (obj.equals(JoinType.JOIN_ANTI_SEMI)) {
-            parts = new Object[] { "ANTI SEMI", SPACE, ReservedWords.JOIN }; //$NON-NLS-1$
+            parts = new Object[] { "ANTI SEMI", SPACE, SQLReservedWords.JOIN }; //$NON-NLS-1$
         }
 
         replaceStringParts(parts);
@@ -595,17 +597,17 @@
 
         parts.add(SPACE);
         if (obj.isNegated()) {
-            parts.add(ReservedWords.NOT);
+            parts.add(SQLReservedWords.NOT);
             parts.add(SPACE);
         }
-        parts.add(ReservedWords.LIKE);
+        parts.add(SQLReservedWords.LIKE);
         parts.add(SPACE);
 
         parts.add(registerNode(obj.getRightExpression()));
 
         if(obj.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) {
             parts.add(SPACE);
-            parts.add(ReservedWords.ESCAPE);
+            parts.add(SQLReservedWords.ESCAPE);
             parts.add(" '"); //$NON-NLS-1$
             parts.add("" + obj.getEscapeChar()); //$NON-NLS-1$
             parts.add("'"); //$NON-NLS-1$
@@ -613,34 +615,34 @@
     }
 
     public void visit(NotCriteria obj) {
-        parts.add(ReservedWords.NOT);
+        parts.add(SQLReservedWords.NOT);
         parts.add(" ("); //$NON-NLS-1$
         parts.add(registerNode(obj.getCriteria()));
         parts.add(")"); //$NON-NLS-1$
     }
 
     public void visit(Option obj) {
-        parts.add(ReservedWords.OPTION);
+        parts.add(SQLReservedWords.OPTION);
 
 		if(obj.getShowPlan()) {
 			parts.add(" "); //$NON-NLS-1$
-			parts.add(ReservedWords.SHOWPLAN);
+			parts.add(SQLReservedWords.SHOWPLAN);
 		}
 
         if(obj.getPlanOnly()) {
             parts.add(" "); //$NON-NLS-1$
-            parts.add(ReservedWords.PLANONLY);
+            parts.add(SQLReservedWords.PLANONLY);
         }
 
 		if(obj.getDebug()) {
 			parts.add(" "); //$NON-NLS-1$
-			parts.add(ReservedWords.DEBUG);
+			parts.add(SQLReservedWords.DEBUG);
 		}
         
         Collection groups = obj.getDependentGroups();
         if(groups != null && groups.size() > 0) {
             parts.add(" "); //$NON-NLS-1$
-            parts.add(ReservedWords.MAKEDEP);
+            parts.add(SQLReservedWords.MAKEDEP);
             parts.add(" "); //$NON-NLS-1$
 
             Iterator iter = groups.iterator();
@@ -657,7 +659,7 @@
         groups = obj.getNotDependentGroups();
         if(groups != null && groups.size() > 0) {
             parts.add(" "); //$NON-NLS-1$
-            parts.add(ReservedWords.MAKENOTDEP);
+            parts.add(SQLReservedWords.MAKENOTDEP);
             parts.add(" "); //$NON-NLS-1$
 
             Iterator iter = groups.iterator();
@@ -674,7 +676,7 @@
         groups = obj.getNoCacheGroups();
         if(groups != null && groups.size() > 0) {
             parts.add(" "); //$NON-NLS-1$
-            parts.add(ReservedWords.NOCACHE);
+            parts.add(SQLReservedWords.NOCACHE);
             parts.add(" "); //$NON-NLS-1$
 
             Iterator iter = groups.iterator();
@@ -688,15 +690,15 @@
             }
         }else if(obj.isNoCache()){
             parts.add(" "); //$NON-NLS-1$
-            parts.add(ReservedWords.NOCACHE);
+            parts.add(SQLReservedWords.NOCACHE);
         }
 
     }
 
     public void visit(OrderBy obj) {
-        parts.add(ReservedWords.ORDER);
+        parts.add(SQLReservedWords.ORDER);
         parts.add(SPACE);
-        parts.add(ReservedWords.BY);
+        parts.add(SQLReservedWords.BY);
 		parts.add(SPACE);
 		for (Iterator<OrderByItem> iterator = obj.getOrderByItems().iterator(); iterator.hasNext();) {
 			OrderByItem item = iterator.next();
@@ -718,20 +720,20 @@
 	    }
         if(!obj.isAscending()) {
             parts.add(SPACE);
-            parts.add(ReservedWords.DESC);
+            parts.add(SQLReservedWords.DESC);
         } // Don't print default "ASC"
     }
     
     public void visit(DynamicCommand obj) {
-        parts.add(ReservedWords.EXECUTE);
+        parts.add(SQLReservedWords.EXECUTE);
         parts.add(SPACE);
-        parts.add(ReservedWords.STRING);
+        parts.add(SQLReservedWords.STRING);
         parts.add(SPACE);
         parts.add(registerNode(obj.getSql()));
 
         if(obj.isAsClauseSet()){
             parts.add(SPACE);
-            parts.add(ReservedWords.AS);
+            parts.add(SQLReservedWords.AS);
             parts.add(SPACE);
             for (int i = 0; i < obj.getAsColumns().size(); i++) {
                 ElementSymbol symbol = (ElementSymbol)obj.getAsColumns().get(i);
@@ -747,21 +749,21 @@
 
         if(obj.getIntoGroup() != null){
             parts.add(SPACE);
-            parts.add(ReservedWords.INTO);
+            parts.add(SQLReservedWords.INTO);
             parts.add(SPACE);
             parts.add(registerNode(obj.getIntoGroup()));
         }
 
         if(obj.getUsing() != null && !obj.getUsing().isEmpty()) {
             parts.add(SPACE);
-            parts.add(ReservedWords.USING);
+            parts.add(SQLReservedWords.USING);
             parts.add(SPACE);
             parts.add(registerNode(obj.getUsing()));
         }
 
         if (obj.getUpdatingModelCount() > 0) {
             parts.add(SPACE);
-            parts.add(ReservedWords.UPDATE);
+            parts.add(SQLReservedWords.UPDATE);
             parts.add(SPACE);
             if (obj.getUpdatingModelCount() > 1) {
                 parts.add("*"); //$NON-NLS-1$
@@ -795,7 +797,7 @@
 
         if(obj.getInto() != null){
             parts.add(SPACE);
-            parts.add(ReservedWords.INTO);
+            parts.add(SQLReservedWords.INTO);
             parts.add(SPACE);
             parts.add(registerNode(obj.getInto()));
         }
@@ -808,7 +810,7 @@
         // Where clause
         if(obj.getCriteria() != null) {
             parts.add(SPACE);
-            parts.add(ReservedWords.WHERE);
+            parts.add(SQLReservedWords.WHERE);
             parts.add(SPACE);
             parts.add(registerNode(obj.getCriteria()));
         }
@@ -822,7 +824,7 @@
 		// Having clause
 		if(obj.getHaving() != null) {
             parts.add(SPACE);
-            parts.add(ReservedWords.HAVING);
+            parts.add(SQLReservedWords.HAVING);
             parts.add(SPACE);
             parts.add(registerNode(obj.getHaving()));
 		}
@@ -846,33 +848,33 @@
     }
 
     public void visit(SearchedCaseExpression obj) {
-        parts.add(ReservedWords.CASE);
+        parts.add(SQLReservedWords.CASE);
         for (int i = 0; i < obj.getWhenCount(); i++) {
             parts.add(SPACE);
-            parts.add(ReservedWords.WHEN);
+            parts.add(SQLReservedWords.WHEN);
             parts.add(SPACE);
             parts.add(registerNode(obj.getWhenCriteria(i)));
             parts.add(SPACE);
-            parts.add(ReservedWords.THEN);
+            parts.add(SQLReservedWords.THEN);
             parts.add(SPACE);
             parts.add(registerNode(obj.getThenExpression(i)));
         }
         parts.add(SPACE);
         if (obj.getElseExpression() != null) {
-            parts.add(ReservedWords.ELSE);
+            parts.add(SQLReservedWords.ELSE);
             parts.add(SPACE);
             parts.add(registerNode(obj.getElseExpression()));
             parts.add(SPACE);
         }
-        parts.add(ReservedWords.END);
+        parts.add(SQLReservedWords.END);
     }
 
     public void visit(Select obj) {
-        parts.add(ReservedWords.SELECT);
+        parts.add(SQLReservedWords.SELECT);
         parts.add(SPACE);
 
 		if(obj.isDistinct()) {
-			parts.add(ReservedWords.DISTINCT);
+			parts.add(SQLReservedWords.DISTINCT);
 			parts.add(SPACE);
 		}
 
@@ -893,10 +895,10 @@
 		// operator and beginning of list
 		parts.add(SPACE);
         if (obj.isNegated()) {
-            parts.add(ReservedWords.NOT);
+            parts.add(SQLReservedWords.NOT);
             parts.add(SPACE);
         }
-		parts.add(ReservedWords.IN);
+		parts.add(SQLReservedWords.IN);
 		parts.add(" ("); //$NON-NLS-1$
 
 		// value list
@@ -935,7 +937,7 @@
         parts.add(SPACE);
 
         if(obj.isAll()) {
-            parts.add(ReservedWords.ALL);
+            parts.add(SQLReservedWords.ALL);
             parts.add(SPACE);
         }
 
@@ -978,7 +980,7 @@
     public void visit(StoredProcedure obj) {
     	addCacheHint(obj);
         //exec clause
-        parts.add(ReservedWords.EXEC);
+        parts.add(SQLReservedWords.EXEC);
 		parts.add(SPACE);
 		parts.add(obj.getProcedureName());
 		parts.add("("); //$NON-NLS-1$
@@ -1046,10 +1048,10 @@
         // operator and beginning of list
         parts.add(SPACE);
         if (obj.isNegated()) {
-            parts.add(ReservedWords.NOT);
+            parts.add(SQLReservedWords.NOT);
             parts.add(SPACE);
         }
-        parts.add(ReservedWords.IN);
+        parts.add(SQLReservedWords.IN);
         parts.add(" ("); //$NON-NLS-1$
         parts.add(registerNode(obj.getCommand()));
         parts.add(")"); //$NON-NLS-1$
@@ -1064,13 +1066,13 @@
 
     public void visit(Update obj) {
         // Update clause
-        parts.add(ReservedWords.UPDATE);
+        parts.add(SQLReservedWords.UPDATE);
 		parts.add(SPACE);
         parts.add(registerNode(obj.getGroup()));
 		parts.add(SPACE);
 
         // Set clause
-        parts.add(ReservedWords.SET);
+        parts.add(SQLReservedWords.SET);
         parts.add(SPACE);
 
         parts.add(registerNode(obj.getChangeList()));
@@ -1078,7 +1080,7 @@
 		// Where clause
 		if(obj.getCriteria() != null) {
 			parts.add(SPACE);
-			parts.add(ReservedWords.WHERE);
+			parts.add(SQLReservedWords.WHERE);
 			parts.add(SPACE);
 			parts.add(registerNode(obj.getCriteria()));
 		}
@@ -1101,12 +1103,12 @@
 		parts.add("("); //$NON-NLS-1$
 
 		if(obj.isDistinct()) {
-			parts.add(ReservedWords.DISTINCT);
+			parts.add(SQLReservedWords.DISTINCT);
 			parts.add(" "); //$NON-NLS-1$
 		}
 
 		if(obj.getExpression() == null) {
-			parts.add(ReservedWords.ALL_COLS);
+			parts.add(Tokens.ALL_COLS);
 		} else {
 			parts.add(registerNode(obj.getExpression()));
 		}
@@ -1116,7 +1118,7 @@
     public void visit(AliasSymbol obj) {
         parts.add(registerNode(obj.getSymbol()));
         parts.add(SPACE);
-        parts.add(ReservedWords.AS);
+        parts.add(SQLReservedWords.AS);
         parts.add(SPACE);
         parts.add(escapeSinglePart(obj.getOutputName()));
     }
@@ -1136,7 +1138,7 @@
         	constantParts = new Object[] {"?"}; //$NON-NLS-1$
         } else if(obj.isNull()) {
         	if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
-    			constantParts = new Object[] {ReservedWords.UNKNOWN};
+    			constantParts = new Object[] {SQLReservedWords.UNKNOWN};
         	} else {
     			constantParts = new Object[] {"null"}; //$NON-NLS-1$
         	}
@@ -1144,7 +1146,7 @@
             if(Number.class.isAssignableFrom(type)) {
                 constantParts = new Object[] { obj.getValue().toString() };
             } else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
-                constantParts = new Object[] { obj.getValue().equals(Boolean.TRUE) ? ReservedWords.TRUE : ReservedWords.FALSE}; 
+                constantParts = new Object[] { obj.getValue().equals(Boolean.TRUE) ? SQLReservedWords.TRUE : SQLReservedWords.FALSE}; 
 		    } else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
                 constantParts = new Object[] { "{ts'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
             } else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
@@ -1206,18 +1208,18 @@
 			// Hide this function, which is implicit
             parts.add(registerNode(args[0]));
 
-		} else if(name.equalsIgnoreCase(ReservedWords.CONVERT) || name.equalsIgnoreCase(ReservedWords.CAST)) {
+		} else if(name.equalsIgnoreCase(SQLReservedWords.CONVERT) || name.equalsIgnoreCase(SQLReservedWords.CAST)) {
 			parts.add(name);
 			parts.add("("); //$NON-NLS-1$
 
 			if(args != null && args.length > 0) {
 				parts.add(registerNode(args[0]));
 
-				if(name.equalsIgnoreCase(ReservedWords.CONVERT)) {
+				if(name.equalsIgnoreCase(SQLReservedWords.CONVERT)) {
 					parts.add(", "); //$NON-NLS-1$
 				} else {
 					parts.add(" "); //$NON-NLS-1$
-					parts.add(ReservedWords.AS);
+					parts.add(SQLReservedWords.AS);
 					parts.add(" "); //$NON-NLS-1$
 				}
 
@@ -1244,7 +1246,7 @@
 			}
 			parts.add(")"); //$NON-NLS-1$
 
-        } else if(name.equalsIgnoreCase(ReservedWords.TIMESTAMPADD) || name.equalsIgnoreCase(ReservedWords.TIMESTAMPDIFF)) {
+        } else if(name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPADD) || name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPDIFF)) {
             parts.add(name);
             parts.add("("); //$NON-NLS-1$
 
@@ -1287,7 +1289,7 @@
 
         if(alias != null) {
             parts.add(SPACE);
-            parts.add(ReservedWords.AS);
+            parts.add(SQLReservedWords.AS);
             parts.add(SPACE);
             parts.add(escapeSinglePart(alias));
         }
@@ -1306,12 +1308,12 @@
     public void visit(Block obj) {
     	List statements = obj.getStatements();
     	if(statements.size() == 1) {
-    		replaceStringParts(new Object[] { ReservedWords.BEGIN, "\n", //$NON-NLS-1$
-			registerNode((Statement)obj.getStatements().get(0)), "\n", ReservedWords.END}); //$NON-NLS-1$
+    		replaceStringParts(new Object[] { SQLReservedWords.BEGIN, "\n", //$NON-NLS-1$
+			registerNode((Statement)obj.getStatements().get(0)), "\n", SQLReservedWords.END}); //$NON-NLS-1$
     	} else if(statements.size() > 1) {
 	        List parts = new ArrayList();
             // Add first clause
-            parts.add(ReservedWords.BEGIN);
+            parts.add(SQLReservedWords.BEGIN);
             parts.add("\n"); //$NON-NLS-1$
             Iterator stmtIter = statements.iterator();
             while(stmtIter.hasNext()) {
@@ -1319,12 +1321,12 @@
 	            parts.add(registerNode((Statement) stmtIter.next()));
                 parts.add("\n"); //$NON-NLS-1$
             }
-            parts.add(ReservedWords.END);
+            parts.add(SQLReservedWords.END);
             replaceStringParts(parts.toArray());
         } else {
             // Shouldn't happen, but being tolerant
-            replaceStringParts(new Object[] { ReservedWords.BEGIN, "\n", //$NON-NLS-1$
-            							ReservedWords.END });
+            replaceStringParts(new Object[] { SQLReservedWords.BEGIN, "\n", //$NON-NLS-1$
+            							SQLReservedWords.END });
         }
     }
 
@@ -1334,19 +1336,19 @@
     }
 
     public void visit(CreateUpdateProcedureCommand obj) {
-        parts.add(ReservedWords.CREATE);
+        parts.add(SQLReservedWords.CREATE);
         parts.add(SPACE);
         if(!obj.isUpdateProcedure()){
-            parts.add(ReservedWords.VIRTUAL);
+            parts.add(SQLReservedWords.VIRTUAL);
             parts.add(SPACE);
         }
-        parts.add(ReservedWords.PROCEDURE);
+        parts.add(SQLReservedWords.PROCEDURE);
         parts.add("\n"); //$NON-NLS-1$
         parts.add(registerNode(obj.getBlock()));
     }
 
     public void visit(DeclareStatement obj) {
-		parts.add(ReservedWords.DECLARE);
+		parts.add(SQLReservedWords.DECLARE);
 		parts.add(SPACE);
         parts.add(obj.getVariableType());
         parts.add(SPACE);
@@ -1367,14 +1369,14 @@
     }
 
     public void visit(IfStatement obj) {
-        parts.add(ReservedWords.IF);
+        parts.add(SQLReservedWords.IF);
         parts.add("("); //$NON-NLS-1$
         parts.add(registerNode(obj.getCondition()));
         parts.add(")\n"); //$NON-NLS-1$
         parts.add(registerNode(obj.getIfBlock()));
         if(obj.hasElseBlock()) {
         	parts.add("\n"); //$NON-NLS-1$
-	        parts.add(ReservedWords.ELSE);
+	        parts.add(SQLReservedWords.ELSE);
 	        parts.add("\n"); //$NON-NLS-1$
 	        parts.add(registerNode(obj.getElseBlock()));
         }
@@ -1385,19 +1387,19 @@
     }
 
     public void visit(HasCriteria obj) {
-        parts.add( ReservedWords.HAS);
+        parts.add( SQLReservedWords.HAS);
         parts.add(SPACE);
         parts.add(registerNode(obj.getSelector()));
     }
 
     public void visit(TranslateCriteria obj) {
-        parts.add(ReservedWords.TRANSLATE);
+        parts.add(SQLReservedWords.TRANSLATE);
         parts.add(SPACE);
         parts.add(registerNode(obj.getSelector()));
 
         if(obj.hasTranslations()) {
 	        parts.add(SPACE);
-	        parts.add(ReservedWords.WITH);
+	        parts.add(SQLReservedWords.WITH);
 	        parts.add(SPACE);
         	parts.add("("); //$NON-NLS-1$
 	        Iterator critIter = obj.getTranslations().iterator();
@@ -1437,29 +1439,29 @@
         		parts.add("<> "); //$NON-NLS-1$
         		break;
         	case CriteriaSelector.IN:
-        		parts.add(ReservedWords.IN);
+        		parts.add(SQLReservedWords.IN);
         		parts.add(SPACE);
         		break;
         	case CriteriaSelector.IS_NULL:
-        		parts.add(ReservedWords.IS);
+        		parts.add(SQLReservedWords.IS);
         		parts.add(SPACE);
-        		parts.add(ReservedWords.NULL);
+        		parts.add(SQLReservedWords.NULL);
         		parts.add(SPACE);
         		break;
             case CriteriaSelector.LIKE:
-                parts.add(ReservedWords.LIKE);
+                parts.add(SQLReservedWords.LIKE);
                 parts.add(SPACE);
                 break;
             case CriteriaSelector.BETWEEN:
-                parts.add(ReservedWords.BETWEEN);
+                parts.add(SQLReservedWords.BETWEEN);
                 parts.add(SPACE);
                 break;
         }
 
-        parts.add(ReservedWords.CRITERIA);
+        parts.add(SQLReservedWords.CRITERIA);
 		if(obj.hasElements()) {
 	        parts.add(SPACE);
-	        parts.add(ReservedWords.ON);
+	        parts.add(SQLReservedWords.ON);
 	        parts.add(SPACE);
 	        parts.add("("); //$NON-NLS-1$
 
@@ -1477,7 +1479,7 @@
     public void visit(RaiseErrorStatement obj) {
         Object parts[] = new Object[4];
 
-        parts[0] = ReservedWords.ERROR;
+        parts[0] = SQLReservedWords.ERROR;
         parts[1] = SPACE;
         parts[2] = registerNode(obj.getExpression());
         parts[3] = ";"; //$NON-NLS-1$
@@ -1485,23 +1487,23 @@
     }
 
     public void visit(BreakStatement obj) {
-        parts.add(ReservedWords.BREAK);
+        parts.add(SQLReservedWords.BREAK);
         parts.add(";"); //$NON-NLS-1$
     }
 
     public void visit(ContinueStatement obj) {
-        parts.add(ReservedWords.CONTINUE);
+        parts.add(SQLReservedWords.CONTINUE);
         parts.add(";"); //$NON-NLS-1$
     }
 
     public void visit(LoopStatement obj) {
-        parts.add(ReservedWords.LOOP);
+        parts.add(SQLReservedWords.LOOP);
         parts.add(" "); //$NON-NLS-1$
-        parts.add(ReservedWords.ON);
+        parts.add(SQLReservedWords.ON);
         parts.add(" ("); //$NON-NLS-1$
         parts.add(registerNode(obj.getCommand()));
         parts.add(") "); //$NON-NLS-1$
-        parts.add(ReservedWords.AS);
+        parts.add(SQLReservedWords.AS);
         parts.add(" "); //$NON-NLS-1$
         parts.add(obj.getCursorName());
         parts.add("\n"); //$NON-NLS-1$
@@ -1509,7 +1511,7 @@
     }
 
     public void visit(WhileStatement obj) {
-        parts.add(ReservedWords.WHILE);
+        parts.add(SQLReservedWords.WHILE);
         parts.add("("); //$NON-NLS-1$
         parts.add(registerNode(obj.getCondition()));
         parts.add(")\n"); //$NON-NLS-1$
@@ -1518,7 +1520,7 @@
 
     public void visit(ExistsCriteria obj) {
         // operator and beginning of list
-        parts.add(ReservedWords.EXISTS);
+        parts.add(SQLReservedWords.EXISTS);
         parts.add(" ("); //$NON-NLS-1$
         parts.add(registerNode(obj.getCommand()));
         parts.add(")"); //$NON-NLS-1$
@@ -1550,7 +1552,7 @@
 
     
     public void visit(Limit obj) {
-        parts.add(ReservedWords.LIMIT);
+        parts.add(SQLReservedWords.LIMIT);
         if (obj.getOffset() != null) {
             parts.add(SPACE);
             parts.add(registerNode(obj.getOffset()));
@@ -1589,7 +1591,7 @@
     	if(string == null) {
     	    return false;
     	}
-   		return ReservedWords.isReservedWord(string);
+   		return SQLReservedWords.isReservedWord(string);
     }
 
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -36,6 +36,7 @@
 import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.eval.SecurityFunctionEvaluator;
 import com.metamatrix.query.execution.QueryExecPlugin;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.relational.PlanToProcessConverter;
 import com.metamatrix.query.processor.QueryProcessor;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -67,7 +68,7 @@
 	    
 	    private String vdbName;
 	    
-	    private String vdbVersion;
+	    private int vdbVersion;
 	    
 	    private Properties environmentProperties;
 	    
@@ -96,6 +97,8 @@
 	    private long timeSliceEnd = Long.MAX_VALUE;
 	    
 	    private long timeoutEnd = Long.MAX_VALUE;
+	    
+	    private QueryMetadataInterface metadata; 
 	}
 	
 	private GlobalState globalState = new GlobalState();
@@ -108,7 +111,7 @@
      * Construct a new context.
      */
     public CommandContext(Object processorID, String connectionID, String userName, 
-        Serializable commandPayload, String vdbName, String vdbVersion, Properties envProperties, boolean processDebug, boolean collectNodeStatistics) {
+        Serializable commandPayload, String vdbName, int vdbVersion, Properties envProperties, boolean processDebug, boolean collectNodeStatistics) {
         setProcessorID(processorID);
         setConnectionID(connectionID);
         setUserName(userName);
@@ -124,7 +127,7 @@
      * Construct a new context.
      */
     public CommandContext(Object processorID, String connectionID, String userName, 
-        String vdbName, String vdbVersion) {
+        String vdbName, int vdbVersion) {
 
         this(processorID, connectionID, userName, null, vdbName, 
             vdbVersion, null, false, false);            
@@ -203,7 +206,7 @@
     /**
      * @return String
      */
-    public String getVdbVersion() {
+    public int getVdbVersion() {
         return globalState.vdbVersion;
     }
 
@@ -235,7 +238,7 @@
      * Sets the vdbVersion.
      * @param vdbVersion The vdbVersion to set
      */
-    public void setVdbVersion(String vdbVersion) {
+    public void setVdbVersion(int vdbVersion) {
         this.globalState.vdbVersion = vdbVersion;
     }
 
@@ -425,5 +428,12 @@
 	public void setTimeoutEnd(long timeoutEnd) {
 		globalState.timeoutEnd = timeoutEnd;
 	}
+
+	public void setMetadata(QueryMetadataInterface metadata) {
+		globalState.metadata = metadata;
+	}
 	
+	public QueryMetadataInterface getMetadata() {
+		return globalState.metadata;
+	}
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/AggregateValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/AggregateValidationVisitor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/AggregateValidationVisitor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,10 +25,11 @@
 import java.util.Collection;
 import java.util.Set;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.navigator.PreOrderNavigator;
 import com.metamatrix.query.sql.symbol.AggregateSymbol;
 import com.metamatrix.query.sql.symbol.CaseExpression;
@@ -71,10 +72,10 @@
         
         // Verify data type of aggregate expression
         String aggregateFunction = obj.getAggregateFunction();
-        if((aggregateFunction.equals(ReservedWords.SUM) || aggregateFunction.equals(ReservedWords.AVG)) && obj.getType() == null) {
+        if((aggregateFunction.equals(SQLReservedWords.SUM) || aggregateFunction.equals(SQLReservedWords.AVG)) && obj.getType() == null) {
             handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0041, new Object[] {aggregateFunction, obj}), obj);
         }
-        if((aggregateFunction.equals(ReservedWords.MIN) || aggregateFunction.equals(ReservedWords.MAX)) && DataTypeManager.isNonComparable(DataTypeManager.getDataTypeName(aggExp.getType()))) {
+        if((aggregateFunction.equals(SQLReservedWords.MIN) || aggregateFunction.equals(SQLReservedWords.MAX)) && DataTypeManager.isNonComparable(DataTypeManager.getDataTypeName(aggExp.getType()))) {
     		handleValidationError(QueryPlugin.Util.getString("AggregateValidationVisitor.non_comparable", new Object[] {aggregateFunction, obj}), obj); //$NON-NLS-1$
         }
         validateBelow = false;

Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -330,8 +330,8 @@
     	String groupName = variable.getGroupSymbol().getCanonicalName();
 
     	if(groupName.equals(ProcedureReservedWords.INPUT) ||
-			groupName.equals(ProcedureReservedWords.CHANGING)) {
-			handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0012, new Object[] {ProcedureReservedWords.INPUT, ProcedureReservedWords.CHANGING}), obj);
+			groupName.equals(ProcedureReservedWords.CHANGING) || groupName.equals(ProcedureReservedWords.INPUTS)) {
+			handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0012, new Object[] {ProcedureReservedWords.INPUT, ProcedureReservedWords.INPUTS, ProcedureReservedWords.CHANGING}), obj);
 		}
 
 		if(obj.hasCommand()) {
@@ -376,10 +376,9 @@
     	ElementSymbol variable = obj.getVariable();
     	String elementname = variable.getShortName().toUpperCase();
 
-		// varaible cnnot be one of the special variables
-    	if(elementname.equals(ProcedureReservedWords.INPUT) || elementname.equals(ProcedureReservedWords.CHANGING)
-				|| elementname.equals(ProcedureReservedWords.ROWS_UPDATED)) {
-			handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0017, new Object[] {ProcedureReservedWords.INPUT, ProcedureReservedWords.CHANGING, ProcedureReservedWords.ROWS_UPDATED}), obj);
+		// varible cannot be one of the special variables
+    	if(elementname.equals(ProcedureReservedWords.ROWS_UPDATED)) {
+			handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0017, new Object[] {ProcedureReservedWords.ROWS_UPDATED}), obj);
 		}
         
         visit((AssignmentStatement)obj);

Modified: trunk/engine/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,6 +25,8 @@
 import java.io.Serializable;
 import java.util.Date;
 
+import javax.transaction.xa.Xid;
+
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.platform.security.api.SessionToken;
 
@@ -35,6 +37,8 @@
 
 public class RequestInfo implements Serializable {
 
+	private static final long serialVersionUID = -2779106368517784259L;
+	
 	private RequestID requestID;
     private String command;
     private SessionToken token;
@@ -43,7 +47,7 @@
     private boolean isSubscription;
     private int nodeID = Integer.MIN_VALUE;
     private String connectorBindingUUID;
-    private String transactionId;
+    private Xid xid;
     private int executionID;
     
     public RequestInfo(RequestID requestId, String originalCommand, Date submittedTime, Date processingTime) {
@@ -152,13 +156,13 @@
     }
 
 
-	public String getTransactionId() {
-		return transactionId;
+	public Xid getXid() {
+		return this.xid;
 	}
 
 
-	public void setTransactionId(String transactionId) {
-		this.transactionId = transactionId;
+	public void setXid(Xid id) {
+		this.xid = id;
 	}
 	
     @Override

Copied: trunk/engine/src/main/java/org/teiid/cache (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/cache)

Deleted: trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java	2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,135 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.cache;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.metamatrix.cache.Cache;
-import com.metamatrix.cache.CacheConfiguration;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.cache.CacheListener;
-import com.metamatrix.cache.Cache.Type;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-public class DefaultCacheFactory implements CacheFactory, Serializable {
-	private static final long serialVersionUID = -5541424157695857527L;
-	
-	DefaultCache cacheRoot = new DefaultCache("Teiid");
-	private volatile boolean destroyed = false;
-	
-	@Override
-	public void destroy() {
-		this.destroyed = true;
-	}
-
-	@Override
-	public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
-		if (!destroyed) {
-			Cache node = cacheRoot.addChild(type.location());
-			return node;
-		}
-		throw new MetaMatrixRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
-	}
-	
-	class DefaultCache<K, V> implements Cache<K, V>, Serializable {
-		Map<K, V> map = new HashMap();
-		Map<String, Cache> children = new HashMap();
-		String name;
-		
-		public DefaultCache(String name) {
-			this.name = name;
-		}
-		public void addListener(CacheListener listener) {
-		}
-
-		public void clear() {
-			map.clear();
-		}
-
-		public V get(K key) {
-			return map.get(key);
-		}
-
-		public Set<K> keySet() {
-			return map.keySet();
-		}
-
-		public V put(K key, V value) {
-			return map.put(key, value);
-		}
-
-		public V remove(K key) {
-			return map.remove(key);
-		}
-
-		public int size() {
-			return map.size();
-		}
-		
-		public Collection<V> values() {
-			return map.values();
-		}
-
-		@Override
-		public void removeListener() {
-		}
-
-		@Override
-		public Cache addChild(String name) {
-			if (children.get(name) != null) {
-				return children.get(name);
-			}
-			
-			Cache c = new DefaultCache(name);
-			children.put(name, c);
-			return c;
-		}
-
-		@Override
-		public Cache getChild(String name) {
-			return children.get(name);
-		}
-
-		@Override
-		public List<Cache> getChildren() {
-			return new ArrayList<Cache>(children.values());
-		}
-
-		@Override
-		public boolean removeChild(String name) {
-			Object obj = children.remove(name);
-			return obj != null;
-		}
-
-		@Override
-		public String getName() {
-			return name;
-		}		
-	}
-	
-}

Copied: trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.metamatrix.cache.Cache;
+import com.metamatrix.cache.CacheConfiguration;
+import com.metamatrix.cache.CacheFactory;
+import com.metamatrix.cache.CacheListener;
+import com.metamatrix.cache.Cache.Type;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class DefaultCacheFactory implements CacheFactory, Serializable {
+	private static final long serialVersionUID = -5541424157695857527L;
+	
+	DefaultCache cacheRoot = new DefaultCache("Teiid");
+	private volatile boolean destroyed = false;
+	
+	@Override
+	public void destroy() {
+		this.destroyed = true;
+	}
+
+	@Override
+	public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+		if (!destroyed) {
+			Cache node = cacheRoot.addChild(type.location());
+			return node;
+		}
+		throw new MetaMatrixRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
+	}
+	
+	class DefaultCache<K, V> implements Cache<K, V>, Serializable {
+		Map<K, V> map = new HashMap();
+		Map<String, Cache> children = new HashMap();
+		String name;
+		
+		public DefaultCache(String name) {
+			this.name = name;
+		}
+		public void addListener(CacheListener listener) {
+		}
+
+		public void clear() {
+			map.clear();
+		}
+
+		public V get(K key) {
+			return map.get(key);
+		}
+
+		public Set<K> keySet() {
+			return map.keySet();
+		}
+
+		public V put(K key, V value) {
+			return map.put(key, value);
+		}
+
+		public V remove(K key) {
+			return map.remove(key);
+		}
+
+		public int size() {
+			return map.size();
+		}
+		
+		public Collection<V> values() {
+			return map.values();
+		}
+
+		@Override
+		public void removeListener() {
+		}
+
+		@Override
+		public Cache addChild(String name) {
+			if (children.get(name) != null) {
+				return children.get(name);
+			}
+			
+			Cache c = new DefaultCache(name);
+			children.put(name, c);
+			return c;
+		}
+
+		@Override
+		public Cache getChild(String name) {
+			return children.get(name);
+		}
+
+		@Override
+		public List<Cache> getChildren() {
+			return new ArrayList<Cache>(children.values());
+		}
+
+		@Override
+		public boolean removeChild(String name) {
+			Object obj = children.remove(name);
+			return obj != null;
+		}
+
+		@Override
+		public String getName() {
+			return name;
+		}		
+	}
+	
+}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -21,37 +21,37 @@
  */
 package org.teiid.dqp.internal.cache;
 
-import java.util.Properties;
+import java.io.Serializable;
 
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.name.Named;
 import com.metamatrix.cache.Cache;
 import com.metamatrix.cache.CacheConfiguration;
 import com.metamatrix.cache.CacheFactory;
 import com.metamatrix.cache.CacheConfiguration.Policy;
 import com.metamatrix.common.log.LogManager;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
 import com.metamatrix.dqp.util.LogConstants;
 
- at Singleton
-public class DQPContextCache {
+public class DQPContextCache implements Serializable{
+	private static final long serialVersionUID = 6958846566556640186L;
+
 	private static enum Scope {REQUEST,SESSION,SERVICE,VDB,GLOBAL;}
 	
 	private Cache cache;
 	private String processIdentifier;
 	
-	@Inject
-	public DQPContextCache(@Named("DQPProperties") Properties props, CacheFactory cacheFactory) {
+	// called by mc
+	public void setCacheFactory(CacheFactory cacheFactory) {
 		this.cache = cacheFactory.get(Cache.Type.SCOPED_CACHE, new CacheConfiguration(Policy.LRU, 600, 10000));
-		this.processIdentifier = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
 	}
+	//called by mc
+	public void setProcessName(String name) {
+		this.processIdentifier = name;
+	}
 	
 	public Cache getGlobalScopedCache() {
 		return this.cache.addChild(Scope.GLOBAL.name());
 	}
 
-	public void shutdown() {
+	public void stop() {
 		try {
 			this.cache.removeChild(this.processIdentifier);
 		} catch(IllegalStateException e) {
@@ -115,13 +115,13 @@
 		}
 	}
 
-	public Cache getVDBScopedCache(String vdbName, String vdbVersion) {
+	public Cache getVDBScopedCache(String vdbName, int vdbVersion) {
 		Cache scopeNode = this.cache.addChild(Scope.VDB.name());
 		String id = vdbName+"-"+vdbVersion; //$NON-NLS-1$
 		return scopeNode.addChild(id.toUpperCase());
 	}
 
-	public void removeVDBScopedCache(String vdbName, String vdbVersion) {
+	public void removeVDBScopedCache(String vdbName, int vdbVersion) {
 		try {
 			Cache scopeNode = this.cache.addChild(Scope.VDB.name());
 			if (scopeNode != null) {

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,25 +22,48 @@
 
 package org.teiid.dqp.internal.datamgr.impl;
 
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkManager;
+
+import org.teiid.connector.api.ConnectorException;
+
 import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
 
 public class AsynchConnectorWorkItem extends ConnectorWorkItem {
-                
-    AsynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
+    private WorkManager workManager;            
+	
+    AsynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver, WorkManager wm) throws ConnectorException {
     	super(message, manager, resultsReceiver);
+    	this.workManager = wm;
     }
     
     @Override
     protected boolean dataNotAvailable(long delay) {
-    	this.manager.scheduleTask(this, delay);
+    	try {
+			this.manager.scheduleTask(workManager, this, delay);
+		} catch (ConnectorException e) {
+			throw new MetaMatrixRuntimeException(e.getCause());
+		}
     	return false;
     }
     
 	@Override
     protected void resumeProcessing() {
-    	this.manager.reenqueueRequest(this);
+    	try {
+			this.manager.reenqueueRequest(workManager, this);
+		} catch (ConnectorException e) {
+			throw new MetaMatrixRuntimeException(e.getCause());
+		}
     }
 
+	@Override
+	public void workCompleted(WorkEvent arg0) {
+		if (this.lastBatch) {
+			manager.removeState(this.id);
+			sendClose();
+		}
+	}	
 }
\ No newline at end of file

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,224 +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.
- */
-
-/*
- * Date: Sep 10, 2003
- * Time: 3:58:41 PM
- */
-package org.teiid.dqp.internal.datamgr.impl;
-
-import java.util.Properties;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-import org.teiid.connector.api.CacheScope;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ConnectorPropertyNames;
-import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.language.ILanguageFactory;
-import org.teiid.dqp.internal.cache.DQPContextCache;
-import org.teiid.dqp.internal.datamgr.language.LanguageFactoryImpl;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.cache.Cache;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-
-/**
- * Default Connector Environment. 
- */
-public class ConnectorEnvironmentImpl implements ConnectorEnvironment {
-    
-    private final class ContextClassLoaderPreservingRunnable implements
-			Runnable {
-		private final Runnable arg0;
-		private final ClassLoader cl = Thread.currentThread().getContextClassLoader();
-
-		private ContextClassLoaderPreservingRunnable(Runnable arg0) {
-			this.arg0 = arg0;
-		}
-
-		@Override
-		public void run() {
-			ClassLoader current = Thread.currentThread().getContextClassLoader();
-			Thread.currentThread().setContextClassLoader(cl);
-			try {
-				arg0.run();
-			} finally {
-				Thread.currentThread().setContextClassLoader(current);
-			}
-		}
-	}
-
-	private static final TypeFacility TYPE_FACILITY = new TypeFacilityImpl();
-    
-    private ConnectorLogger logger;
-    private Properties properties;
-    private ApplicationEnvironment env;
-    private WorkerPool workerPool;
-    
-    
-    public ConnectorEnvironmentImpl(Properties connectorProperties, ConnectorLogger logger, ApplicationEnvironment env) {
-    	this(connectorProperties, logger, env, null);
-    }
-    /**
-     * ctor  
-     * @param connectorProperties - Properties required for this Connector
-     * @param logger - Logger to be used by the Connector
-     * @param env - Connector Environment.
-     */
-    public ConnectorEnvironmentImpl(Properties connectorProperties, ConnectorLogger logger, ApplicationEnvironment env, WorkerPool workerPool) {
-        this.properties = connectorProperties;
-        this.logger = logger;
-        this.env = env;
-        this.workerPool = workerPool;
-    }
-    
-    /**  
-     * @see org.teiid.connector.api.ConnectorEnvironment#getProperties()
-     */
-    public Properties getProperties() {
-        return this.properties;
-    }
-
-    /**  
-     * @see org.teiid.connector.api.ConnectorEnvironment#getConnectorName() 
-     */
-    public String getConnectorName() {
-        return this.properties.getProperty(ConnectorPropertyNames.CONNECTOR_BINDING_NAME);
-    }
-
-    /**
-     * Aquire the logger that the connector using this environment will
-     * use to log messages.
-     * @return The {@link com.metamatrix.data.ConnectorLogger} for this Connector.
-     */
-    public ConnectorLogger getLogger() {
-        return this.logger;
-    }
-   
-    /**
-     * Implement the InternalConnectorEnvironment to allow access for internal connectors
-     * to standard Connector Manager resources.  For now this is just access to other
-     * connector manager services.
-     * @param resourceName Resource name - for now only valid names are DQP service names
-     * @return The service as requested 
-     * @see com.metamatrix.dqp.datamgr.InternalConnectorEnvironment#findResource(java.lang.String)
-     */
-    public Object findResource(String resourceName) {
-        return env.findService(resourceName);
-    }
-
-    /* 
-     * @see com.metamatrix.data.api.ConnectorEnvironment#getLanguageFactory()
-     */
-    public ILanguageFactory getLanguageFactory() {
-        return LanguageFactoryImpl.INSTANCE;
-    }
-
-    /**  
-     * @see org.teiid.connector.api.ConnectorEnvironment#getTypeFacility()
-     */
-    public TypeFacility getTypeFacility() {
-        return TYPE_FACILITY;
-    }
-
-	@Override
-	public void execute(Runnable command) {
-		if (this.workerPool != null) {
-			this.workerPool.execute(new ContextClassLoaderPreservingRunnable(command));
-		} else {
-			command.run();
-		}
-	}               
-	
-	@Override
-	public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
-			long initialDelay, long period, TimeUnit unit) {
-		if (this.workerPool != null) {
-			return this.workerPool.scheduleAtFixedRate(new ContextClassLoaderPreservingRunnable(command), initialDelay, period, unit);
-		}
-		return null;
-	}
-	
-	@Override
-	public Object getFromCache(CacheScope scope, Object key) {
-		DQPWorkContext context = DQPWorkContext.getWorkContext();
-		checkScopeValidity(scope, context);
-
-		Cache cache = getScopedCache(scope, context);
-		if (cache != null) {
-			return cache.get(key);
-		}
-		return null;
-	}
-	
-	@Override
-	public void storeInCache(CacheScope scope, Object key, Object value) {
-		DQPWorkContext context = DQPWorkContext.getWorkContext();
-		checkScopeValidity(scope, context);
-		Cache cache = getScopedCache(scope, context);
-		if (cache != null) {
-			cache.put(key, value);
-		}
-	}
-	
-	private Cache getScopedCache(CacheScope scope, DQPWorkContext context) {
-		BufferService service = (BufferService) findResource(DQPServiceNames.BUFFER_SERVICE);
-		if (service != null) {
-			DQPContextCache contextCache = service.getContextCache();
-			switch (scope) {
-			case SERVICE:
-				return contextCache.getServiceScopedCache(properties.getProperty(ConnectorPropertyNames.CONNECTOR_ID));
-			case SESSION:
-				return contextCache.getSessionScopedCache(context.getSessionToken().getSessionIDValue());
-			case VDB:
-				return contextCache.getVDBScopedCache(context.getVdbName(), context.getVdbVersion());
-			case GLOBAL:
-				return contextCache.getGlobalScopedCache();
-			}
-		}
-		return null;
-	}
-	
-	
-	private void checkScopeValidity(CacheScope scope, DQPWorkContext context) {
-		if (scope == CacheScope.REQUEST) {
-			throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.request_scope_error")); //$NON-NLS-1$
-		}
-		
-		if (scope == CacheScope.SESSION) {
-			if (context == null || context.getSessionToken() == null) {
-				throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.session_scope_error")); //$NON-NLS-1$
-			}
-		}
-		else if (scope == CacheScope.VDB) {
-			if (context == null || context.getVdbName() == null || context.getVdbVersion() == null) {
-				throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.vdb_scope_error")); //$NON-NLS-1$
-			}
-		}
-	}
-}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,63 +26,48 @@
  */
 package org.teiid.dqp.internal.datamgr.impl;
 
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
+import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkManager;
+
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.teiid.SecurityHelper;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
 import org.teiid.connector.api.Connection;
 import org.teiid.connector.api.Connector;
 import org.teiid.connector.api.ConnectorCapabilities;
 import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorPropertyNames;
 import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.ConnectorAnnotations.ConnectionPooling;
-import org.teiid.connector.api.ConnectorAnnotations.SynchronousWorkers;
+import org.teiid.connector.basic.WrappedConnection;
+import org.teiid.connector.metadata.runtime.Datatype;
 import org.teiid.connector.metadata.runtime.MetadataFactory;
 import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.xa.api.XAConnector;
 import org.teiid.dqp.internal.cache.DQPContextCache;
 import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
-import org.teiid.dqp.internal.pooling.connector.PooledConnector;
-import org.teiid.dqp.internal.process.DQPWorkContext;
 
-import com.metamatrix.admin.objects.MMConnectionPool;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.ClassLoaderManager;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.common.queue.WorkerPoolFactory;
-import com.metamatrix.common.queue.WorkerPoolStats;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.common.queue.StatsCapturingWorkManager;
 import com.metamatrix.core.log.MessageLevel;
 import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.core.util.StringUtil;
 import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
 import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.service.BufferService;
 import com.metamatrix.dqp.service.CommandLogMessage;
 import com.metamatrix.dqp.service.ConnectorStatus;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.TransactionService;
 import com.metamatrix.dqp.util.LogConstants;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -93,103 +78,86 @@
  * The <code>ConnectorManager</code> manages a {@link org.teiid.connector.basic.BasicConnector Connector}
  * and its associated workers' state.
  */
-public class ConnectorManager implements ApplicationService {
-
+ at ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="connectormanager"), properties=ManagementProperties.EXPLICIT)
+public class ConnectorManager  {
+	
 	public static final int DEFAULT_MAX_THREADS = 20;
-
-    //state constructed in start
-    private ConnectorWrapper connector;
-    private ConnectorID connectorID;
-    private WorkerPool connectorWorkerPool;
-    private ConnectorWorkItemFactory workItemFactory;
 	private String connectorName;
-    private int maxResultRows;
-    private boolean exceptionOnMaxRows = true;
-    private boolean synchWorkers;
-    private boolean isXa;
-    private boolean isImmutable;
+	    
+    private StatsCapturingWorkManager workManager;
+    private SecurityHelper securityHelper;
     
+    protected ConnectorWorkItemFactory workItemFactory;
+    
     private volatile ConnectorStatus state = ConnectorStatus.NOT_INITIALIZED;
 
     //services acquired in start
-    private MetadataService metadataService;
-    private TransactionService transactionService;
     private BufferService bufferService;
     
-    private ClassLoaderManager clManager;
-
     // known requests
     private ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem> requestStates = new ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem>();
-
-    private Properties props;
-	private ClassLoader classloader;
 	
 	private SourceCapabilities cachedCapabilities;
-    
-    public void initialize(Properties props) {
-    	this.props = props;
-    	this.isImmutable = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.IS_IMMUTABLE, false);
+
+    public ConnectorManager(String name) {
+    	this(name, DEFAULT_MAX_THREADS, null);
     }
-    
-    public boolean isImmutable() {
-        return isImmutable;
+	
+    public ConnectorManager(String name, int maxThreads, SecurityHelper securityHelper) {
+    	if (name == null) {
+    		throw new IllegalArgumentException("Connector name can not be null");
+    	}
+    	if (maxThreads <= 0) {
+    		maxThreads = DEFAULT_MAX_THREADS;
+    	}
+    	this.connectorName = name;
+    	this.workManager = new StatsCapturingWorkManager(this.connectorName, maxThreads);
+    	this.securityHelper = securityHelper;
     }
-
-    public ClassLoader getClassloader() {
-		return classloader;
-	}
     
-    public MetadataStore getMetadata(String modelName, Properties importProperties) throws ConnectorException {
-    	MetadataFactory factory;
-		try {
-			factory = new MetadataFactory(modelName, this.metadataService.getBuiltinDatatypes(), importProperties);
-		} catch (MetaMatrixComponentException e) {
-			throw new ConnectorException(e);
-		}
-		Thread currentThread = Thread.currentThread();
-		ClassLoader threadContextLoader = currentThread.getContextClassLoader();
-		try {
-			currentThread.setContextClassLoader(classloader);
-			this.connector.getConnectorMetadata(factory);
-		} finally {
-			currentThread.setContextClassLoader(threadContextLoader);
-		}
-		return factory.getMetadataStore();
+    SecurityHelper getSecurityHelper() {
+		return securityHelper;
 	}
     
-    public SourceCapabilities getCapabilities(RequestID requestID, Serializable executionPayload, DQPWorkContext message) throws ConnectorException {
+    public String getName() {
+        return this.connectorName;
+    }	
+	    
+    public MetadataStore getMetadata(String modelName, Map<String, Datatype> datatypes, Properties importProperties) throws ConnectorException {
+    	
+    	MetadataFactory factory = new MetadataFactory(modelName, datatypes, importProperties);
+		
+		WrappedConnection conn = null;
+    	try {
+    		checkStatus();
+	    	conn = (WrappedConnection)getConnector().getConnection();
+	    	conn.getConnectorMetadata(factory);
+    	} finally {
+    		if (conn != null) {
+    			conn.close();
+    		}
+    	}		
+    	return factory.getMetadataStore();
+	}    
+    
+    
+    public SourceCapabilities getCapabilities() throws ConnectorException {
     	if (cachedCapabilities != null) {
     		return cachedCapabilities;
     	}
         Connection conn = null;
-        // Defect 17536 - Set the thread-context classloader to the non-delegating classloader when calling
-        // methods on the connector.
-        Thread currentThread = Thread.currentThread();
-        ClassLoader threadContextLoader = currentThread.getContextClassLoader();
         try {
+        	checkStatus();
+        	Connector connector = getConnector();
         	ConnectorCapabilities caps = connector.getCapabilities();
-            currentThread.setContextClassLoader(classloader);
             boolean global = true;
             if (caps == null) {
-            	ExecutionContextImpl context = new ExecutionContextImpl(
-                        message.getVdbName(),
-                        message.getVdbVersion(),
-                        message.getUserName(),
-                        message.getTrustedPayload(),
-                        executionPayload,
-                        "capabilities-request", //$NON-NLS-1$
-                        connectorID.getID(), 
-                        requestID.toString(), 
-                        "capabilities-request", "0"); //$NON-NLS-1$ //$NON-NLS-2$ 
-            	
-            	context.setContextCache(getContextCache());
-
-            	conn = connector.getConnection(context, null);
+            	conn = connector.getConnection();
             	caps = conn.getCapabilities();
             	global = false;
             }
-            caps = (ConnectorCapabilities) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ConnectorCapabilities.class}, new CapabilitesOverloader(caps, this.props));
-            BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(caps, getName(), isXa);
+            
+            BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(caps, getName(), connector.getConnectorEnvironment().isXaCapable());
             if (global) {
             	resultCaps.setScope(Scope.SCOPE_GLOBAL);
             	cachedCapabilities = resultCaps;
@@ -201,35 +169,45 @@
         	if ( conn != null ) {
                 conn.close();
             }
-            currentThread.setContextClassLoader(threadContextLoader);
         }
     }
     
-    public void executeRequest(ResultsReceiver<AtomicResultsMessage> receiver, AtomicRequestMessage message) {
+    public void executeRequest(WorkManager workManager, ResultsReceiver<AtomicResultsMessage> receiver, AtomicRequestMessage message) throws ConnectorException {
         // Set the connector ID to be used; if not already set. 
+    	checkStatus();
     	AtomicRequestID atomicRequestId = message.getAtomicRequestID();
     	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); //$NON-NLS-1$
 
-    	ConnectorWorkItem item = workItemFactory.createWorkItem(message, receiver);
+    	ConnectorWorkItem item = workItemFactory.createWorkItem(message, receiver, workManager);
     	
         Assertion.isNull(requestStates.put(atomicRequestId, item), "State already existed"); //$NON-NLS-1$
-        message.markProcessingStart();
-        enqueueRequest(item);
+		enqueueRequest(workManager, item);
     }
     
-    private void enqueueRequest(ConnectorWorkItem state) {
-        this.connectorWorkerPool.execute(state);
+    private void enqueueRequest(WorkManager workManager, ConnectorWorkItem work) throws ConnectorException {
+        try {
+        	// if connector is immutable, then we do not want pass-on the transaction context.
+        	if (work.securityContext.isTransactional()) {
+        		this.workManager.scheduleWork(workManager, work, work.requestMsg.getTransactionContext(), 0);
+        	}
+        	else {
+        		this.workManager.scheduleWork(workManager, work);
+        	}
+		} catch (WorkException e) {
+			throw new ConnectorException(e);
+		}
     }
     
-    void reenqueueRequest(AsynchConnectorWorkItem state) {
-    	enqueueRequest(state);
+    void reenqueueRequest(WorkManager workManager, AsynchConnectorWorkItem work)  throws ConnectorException {
+    	enqueueRequest(workManager, work);
     }
     
     ConnectorWorkItem getState(AtomicRequestID requestId) {
         return requestStates.get(requestId);
     }
     
-    public void requstMore(AtomicRequestID requestId) {
+    @SuppressWarnings("unused")
+	public void requstMore(AtomicRequestID requestId) throws ConnectorException {
     	ConnectorWorkItem workItem = getState(requestId);
     	if (workItem == null) {
     		return; //already closed
@@ -242,13 +220,7 @@
     	if (workItem == null) {
     		return; //already closed
     	}
-        ClassLoader contextloader = Thread.currentThread().getContextClassLoader();
-        try {
-        	Thread.currentThread().setContextClassLoader(classloader);
-    	    workItem.requestCancel();
-        } finally {
-        	Thread.currentThread().setContextClassLoader(contextloader);
-        }
+	    workItem.requestCancel();
     }
     
     public void closeRequest(AtomicRequestID requestId) {
@@ -265,13 +237,21 @@
      * @param delay The delay to wait (in ms) before executing the task
      * @since 4.3.3
      */
-    public void scheduleTask(final AsynchConnectorWorkItem state, long delay) {
-        this.connectorWorkerPool.schedule(new Runnable() {
-        	@Override
-        	public void run() {
-        		state.requestMore();
-        	}
-        }, delay, TimeUnit.MILLISECONDS);        
+    public void scheduleTask(WorkManager workManager, final AsynchConnectorWorkItem state, long delay) throws ConnectorException {
+    	try {
+			this.workManager.scheduleWork(workManager, new Work() {
+				@Override
+				public void run() {
+					state.requestMore();
+				}
+				@Override
+				public void release() {
+					
+				}
+			}, null, delay);
+		} catch (WorkException e) {
+			throw new ConnectorException(e);
+		}        
     }
     
     /**
@@ -287,231 +267,57 @@
         return requestStates.size();
     }
     
-    public ConnectorStatus getStatus() {
-    	ConnectorWrapper connectorWrapper = this.connector;
-    	ConnectorStatus result = this.state;
-    	if (result != ConnectorStatus.OPEN) {
-    		return result;
-    	}
-        ClassLoader contextloader = Thread.currentThread().getContextClassLoader();
-        try {
-        	Thread.currentThread().setContextClassLoader(classloader);
-            return connectorWrapper.getStatus();
-        } finally {
-        	Thread.currentThread().setContextClassLoader(contextloader);
-        }
+    public void setBufferService(BufferService service) {
+    	this.bufferService = service;
     }
     
     /**
      * initialize this <code>ConnectorManager</code>.
      */
-    public synchronized void start(ApplicationEnvironment env) throws ApplicationLifecycleException {
+    public synchronized void start() throws ConnectorException {
     	if (this.state != ConnectorStatus.NOT_INITIALIZED) {
     		return;
     	}
     	this.state = ConnectorStatus.INIT_FAILED;
-        connectorName = props.getProperty(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, "Unknown_Binding_Name"); //$NON-NLS-1$
-        String connIDStr = props.getProperty(ConnectorPropertyNames.CONNECTOR_ID);
-        connectorID = new ConnectorID(connIDStr);
         
-        //connector Name - logical name<Unique Id>
-        connectorName = connectorName + '<' + connIDStr + '>';
-
         LogManager.logInfo(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorManagerImpl.Initializing_connector", connectorName)); //$NON-NLS-1$
 
-        this.setTransactionService((TransactionService) env.findService(DQPServiceNames.TRANSACTION_SERVICE));
+     	ConnectorEnvironment connectorEnv = null;
+		
+		connectorEnv = getConnector().getConnectorEnvironment();
+    	
+    	if (!connectorEnv.isSynchWorkers() && connectorEnv.isXaCapable()) {
+    		throw new ConnectorException(DQPPlugin.Util.getString("ConnectorManager.xa_capbility_not_supported", this.connectorName)); //$NON-NLS-1$
+    	}
 
-        // Set the class name for the connector class
-        String connectorClassString = props.getProperty(ConnectorPropertyNames.CONNECTOR_CLASS);
-        if ( connectorClassString == null || connectorClassString.trim().length() == 0 ) {             
-            throw new ApplicationLifecycleException(DQPPlugin.Util.getString("Missing_required_property", new Object[]{ConnectorPropertyNames.CONNECTOR_CLASS, connectorName})); //$NON-NLS-1$
-        }
-
-        int maxThreads = PropertiesUtils.getIntProperty(props, ConnectorPropertyNames.MAX_CONNECTIONS, DEFAULT_MAX_THREADS);
-
-        connectorWorkerPool = WorkerPoolFactory.newWorkerPool(connectorName, maxThreads);
-
-        // Create the Connector env
-        Properties clonedProps = new Properties(this.props);
-        
-        ConnectorEnvironment connectorEnv = new ConnectorEnvironmentImpl(clonedProps, new DefaultConnectorLogger(connectorID), env, connectorWorkerPool);
-
-        // Get the metadata service
-        this.metadataService = (MetadataService) env.findService(DQPServiceNames.METADATA_SERVICE);
-        if ( this.metadataService == null ) {
-            throw new ApplicationLifecycleException(DQPPlugin.Util.getString("Failed_to_find_service", new Object[]{DQPServiceNames.METADATA_SERVICE, connectorName})); //$NON-NLS-1$
-        }
-
-        this.maxResultRows = PropertiesUtils.getIntProperty(props, ConnectorPropertyNames.MAX_RESULT_ROWS, 0);
-        this.exceptionOnMaxRows = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.EXCEPTION_ON_MAX_ROWS, false);
-    	this.synchWorkers = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.SYNCH_WORKERS, true);
-
-     	this.bufferService = (BufferService) env.findService(DQPServiceNames.BUFFER_SERVICE);
-        // Initialize and start the connector
-        initStartConnector(connectorEnv);
-		this.workItemFactory = new ConnectorWorkItemFactory(this, synchWorkers);
+		this.workItemFactory = new ConnectorWorkItemFactory(this, connectorEnv.isSynchWorkers());
     	this.state = ConnectorStatus.OPEN;
     }
     
-	private String buildClasspath(Properties connectorProperties) {
-		StringBuilder sb = new StringBuilder();
-		appendlasspath(connectorProperties.getProperty(ConnectorPropertyNames.CONNECTOR_CLASSPATH), sb); // this is user defined, could be very specific to the binding
-        appendlasspath(connectorProperties.getProperty(ConnectorPropertyNames.CONNECTOR_TYPE_CLASSPATH), sb); // this is system defined; type classpath
-        return sb.toString();
-	}
-	
-	private void appendlasspath(String path, StringBuilder builder) {
-        if (path != null && path.length() > 0) {
-        	builder.append(path);
-        	if (!path.endsWith(";")) { //$NON-NLS-1$
-        		builder.append(";"); //$NON-NLS-1$
-        	}
-        }
-	} 
-	
     /**
-     * Initialize and start the connector.
-     * @param env
-     * @throws ApplicationLifecycleException
-     */
-    private void initStartConnector(ConnectorEnvironment env) throws ApplicationLifecycleException {
-    	
-        String connectorClassName = env.getProperties().getProperty(ConnectorPropertyNames.CONNECTOR_CLASS);
-        
-        String classPath = buildClasspath(env.getProperties());
-
-        Thread currentThread = Thread.currentThread();
-        ClassLoader threadContextLoader = currentThread.getContextClassLoader();
-        
-        if (classPath == null || classPath.trim().length() == 0) {
-        	classloader = threadContextLoader;
-        } else {
-        	env.getProperties().setProperty(ConnectorPropertyNames.USING_CUSTOM_CLASSLOADER, Boolean.TRUE.toString());
-            
-            boolean postDelegation = PropertiesUtils.getBooleanProperty(env.getProperties(), ConnectorPropertyNames.USE_POST_DELEGATION, false);
-            
-            LogManager.logInfo(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorManager.useClassloader", connectorName, postDelegation, classPath)); //$NON-NLS-1$
-            
-            if (postDelegation) {
-            	this.classloader = this.clManager.getPostDelegationClassLoader(classPath);
-            } else {
-            	this.classloader = this.clManager.getCommonClassLoader(classPath);
-            }
-        }
-        
-        try {
-        	currentThread.setContextClassLoader(classloader);
-        	Connector c;
-			try {
-				Object o = ReflectionHelper.create(connectorClassName, null, classloader);
-				if (o instanceof Connector) {
-					c = (Connector)o;
-					this.isXa = PropertiesUtils.getBooleanProperty(env.getProperties(), ConnectorPropertyNames.IS_XA, false);
-				} else {
-					try {
-						Class legacyConnector = classloader.loadClass("com.metamatrix.data.api.Connector"); //$NON-NLS-1$
-						if (!legacyConnector.isAssignableFrom(o.getClass())) {
-							throw new ApplicationLifecycleException(DQPPlugin.Util.getString("failed_legacy", connectorClassName)); //$NON-NLS-1$
-						}
-						c = (Connector)ReflectionHelper.create("com.metamatrix.dqp.internal.datamgr.ConnectorWrapper", new Object[] {o}, new Class[] {legacyConnector}, classloader); //$NON-NLS-1$
-						this.isXa = classloader.loadClass("com.metamatrix.data.xa.api.XAConnector").isAssignableFrom(o.getClass()); //$NON-NLS-1$
-					} catch (ClassNotFoundException e) {
-						throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_legacy", connectorClassName)); //$NON-NLS-1$
-					} 
-				}
-			} catch (MetaMatrixCoreException e) {
-	            throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_find_Connector_class", connectorClassName)); //$NON-NLS-1$
-			}
-            if (this.synchWorkers) {
-                SynchronousWorkers synchWorkerAnnotation = c.getClass().getAnnotation(SynchronousWorkers.class);
-            	if (synchWorkerAnnotation != null) {
-            		this.synchWorkers = synchWorkerAnnotation.enabled();
-            	}
-            	if (!this.synchWorkers) {
-            		LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Changing asynch connector", getName(), "to non-XA.  Consider changing you're connector binding to be non-XA."); //$NON-NLS-1$ //$NON-NLS-2$
-            		this.isXa = false;
-            	}
-            }
-        	this.connector = wrapConnector(c, env);
-            this.connector.start(env);
-        } catch (ConnectorException e) {
-            throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_start_Connector", new Object[] {this.getConnectorID(), e.getMessage()})); //$NON-NLS-1$
-        } finally {
-        	currentThread.setContextClassLoader(threadContextLoader);
-        }
-    }
-    
-    private ConnectorWrapper wrapConnector(Connector c, ConnectorEnvironment connectorEnv) throws ApplicationLifecycleException {
-    	//the pooling annotation overrides the connector binding
-        ConnectionPooling connectionPooling = c.getClass().getAnnotation(ConnectionPooling.class);
-    	boolean connectionPoolPropertyEnabled = PropertiesUtils.getBooleanProperty(connectorEnv.getProperties(), ConnectorPropertyNames.CONNECTION_POOL_ENABLED, true);
-    	boolean propertySet = connectorEnv.getProperties().contains(ConnectorPropertyNames.CONNECTION_POOL_ENABLED);
-    	boolean poolingEnabled = false;
-        if (propertySet) {
-        	poolingEnabled = connectionPoolPropertyEnabled && (connectionPooling == null || connectionPooling.enabled());
-        } else {
-        	poolingEnabled = connectionPooling != null && connectionPooling.enabled();
-        }
-		if (this.isXa) {
-            if(poolingEnabled && !(c instanceof XAConnector)){
-            	throw new ApplicationLifecycleException(DQPPlugin.Util.getString("non_xa_connector", connectorName)); //$NON-NLS-1$
-            }
-            if (this.getTransactionService() == null) {                    
-                throw new ApplicationLifecycleException(DQPPlugin.Util.getString("no_txn_manager", connectorName)); //$NON-NLS-1$
-            }
-		}
-        if (poolingEnabled) {
-           	LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Automatic connection pooling was enabled for connector " + getName()); //$NON-NLS-1$
-        	if (!this.synchWorkers) {
-            	LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorManager.asynch_worker_warning", ConnectorPropertyNames.SYNCH_WORKERS)); //$NON-NLS-1$	                
-        	}
-        	return new PooledConnector(this.connectorName, c, isXa?this.getTransactionService():null);
-        }         
-        return new ConnectorWrapper(c);
-    }
-    
-    /**
      * Stop this connector.
      */
-    public void stop() throws ApplicationLifecycleException {        
+    public void stop() {        
         synchronized (this) {
         	if (this.state == ConnectorStatus.CLOSED) {
         		return;
         	}
             this.state= ConnectorStatus.CLOSED;
 		}
-        if (this.connectorWorkerPool != null) {
-        	this.connectorWorkerPool.shutdownNow();
+        
+        if (workManager != null) {
+        	this.workManager.shutdownNow();
         }
         
         //ensure that all requests receive a response
         for (ConnectorWorkItem workItem : this.requestStates.values()) {
         	try {
-        		workItem.resultsReceiver.exceptionOccurred(new ConnectorException(DQPPlugin.Util.getString("Connector_Shutting_down", new Object[] {workItem.id, connectorID}))); //$NON-NLS-1$
+        		workItem.resultsReceiver.exceptionOccurred(new ConnectorException(DQPPlugin.Util.getString("Connector_Shutting_down", new Object[] {workItem.id, this.connectorName}))); //$NON-NLS-1$
         	} catch (Exception e) {
         		//ignore
         	}
 		}
         
-        if ( this.connector != null ) {
-
-            if(this.isXa){
-                if (this.getTransactionService() != null) {
-                    TransactionService ts = this.getTransactionService();
-                    ts.removeRecoverySource(connectorName);
-                }
-            }
-            
-            Thread currentThread = Thread.currentThread();
-            ClassLoader threadContextLoader = currentThread.getContextClassLoader();
-            try {
-                currentThread.setContextClassLoader(classloader);
-                this.connector.stop();
-            } finally {
-                currentThread.setContextClassLoader(threadContextLoader);
-            }
-            
-        }
     }
 
     /**
@@ -519,28 +325,12 @@
      * this service.
      * If there are no queues, an empty Collection is returned.
      */
-    public Collection<WorkerPoolStats> getQueueStatistics() {
-        if ( this.connectorWorkerPool == null ) {
-            return Collections.emptyList();
-        }
-        return Arrays.asList(connectorWorkerPool.getStats());
+    @ManagementProperty(description="Get Runtime workmanager statistics", use={ViewUse.STATISTIC}, readOnly=true)
+    public WorkerPoolStatisticsMetadata getWorkManagerStatistics() {
+        return workManager.getStats();
     }
 
     /**
-     * Returns a QueueStats object that represent the queue in
-     * this service.
-     * If there is no queue with the given name, an empty Collection is returned.
-     */
-    public Collection<WorkerPoolStats> getQueueStatistics(String name) {
-        if ( connectorID == null ||
-             !name.equalsIgnoreCase(connectorID.getID()) ||
-             connectorWorkerPool == null ) {
-            return Collections.emptyList();
-        }
-        return Arrays.asList(connectorWorkerPool.getStats());
-    }
-
-    /**
      * Add begin point to transaction monitoring table.
      * @param qr Request that contains the MetaMatrix command information in the transaction.
      */
@@ -556,7 +346,7 @@
         String userName = qr.getWorkContext().getUserName();
         String transactionID = null;
         if ( qr.isTransactional() ) {
-            transactionID = qr.getTransactionContext().getTxnID();
+            transactionID = qr.getTransactionContext().getXid().toString();
         }
         
         String modelName = qr.getModelName();
@@ -580,7 +370,7 @@
             }
             message = new CommandLogMessage(System.currentTimeMillis(), qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, connectorName, qr.getWorkContext().getConnectionID(), principal, finalRowCnt, isCancelled, errorOccurred, context);
         }         
-        LogManager.log(MessageLevel.INFO, LogConstants.CTX_COMMANDLOGGING, message);
+        LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_COMMANDLOGGING, message);
     }
     
     /**
@@ -588,107 +378,29 @@
      * manager.
      * @return the <code>Connector</code>.
      */
-    ConnectorWrapper getConnector() {
-        return this.connector;
+    Connector getConnector() throws ConnectorException {
+		try {
+			InitialContext ic  = new InitialContext();
+			return (Connector)ic.lookup(this.connectorName);    			
+		} catch (NamingException e) {
+			throw new ConnectorException(e, DQPPlugin.Util.getString("ConnectorManager.failed_to_lookup_connector", this.connectorName)); //$NON-NLS-1$
+		}
     }
     
-    void setConnector(ConnectorWrapper connector) {
-    	this.connector = connector;
-    }
-
-	int getMaxResultRows() {
-		return maxResultRows;
-	}
-
-	void setMetadataService(MetadataService metadataService) {
-		this.metadataService = metadataService;
-	}
-
-	MetadataService getMetadataService() {
-		return metadataService;
-	}
-
-	boolean isExceptionOnMaxRows() {
-		return exceptionOnMaxRows;
-	}
-
-	void setTransactionService(TransactionService transactionService) {
-		this.transactionService = transactionService;
-	}
-
-	TransactionService getTransactionService() {
-		return transactionService;
-	}
-	
-    /**
-     * The identifier that code will use to identify this object.
-     * @return The <code>ConnectorID</code>.
-     */
-    public ConnectorID getConnectorID() {
-        return connectorID;
-    }
-    
     DQPContextCache getContextCache() {
      	if (bufferService != null) {
     		return bufferService.getContextCache();
     	}
-
     	return null;
     }
     
-    /**
-     * Get the human-readable name that this connector is known by.
-     * <p>Will be <code>null</code> if connector is not started.</p>
-     * @return The connector's name.
-     */
-    public String getName() {
-        return this.connectorName;
+    public ConnectorStatus getStatus() {
+    	return this.state;
     }
-
-	void setConnectorWorkerPool(WorkerPool connectorWorkerPool) {
-		this.connectorWorkerPool = connectorWorkerPool;
-	}
-	
-	public boolean isXa() {
-		return isXa;
-	}
-	
-	public void setClassLoaderManager(ClassLoaderManager clManager) {
-		this.clManager = clManager;
-	}
-	
-	public void setWorkItemFactory(ConnectorWorkItemFactory workItemFactory) {
-		this.workItemFactory = workItemFactory;
-	}
-	
-	/**
-	 * Overloads the connector capabilities with one defined in the connector binding properties
-	 */
-    static final class CapabilitesOverloader implements InvocationHandler {
-    	ConnectorCapabilities caps; 
-    	Properties properties;
-    	
-    	CapabilitesOverloader(ConnectorCapabilities caps, Properties properties){
-    		this.caps = caps;
-    		this.properties = properties;
+    
+    private void checkStatus() throws ConnectorException {
+    	if (this.state != ConnectorStatus.OPEN) {
+    		throw new ConnectorException(DQPPlugin.Util.getString("ConnectorManager.not_in_valid_state", this.connectorName));
     	}
-    	
-		@Override
-		public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-			String value = this.properties.getProperty(method.getName());
-			if (value == null || value.trim().length() == 0 || (args != null && args.length != 0)) {
-				return method.invoke(this.caps, args);
-			}
-			return StringUtil.valueOf(value, method.getReturnType());
-		}
-	}
-
-	public Collection<MMConnectionPool> getConnectionPoolStats() {
-	     if (connector instanceof  PooledConnector) {
-    	 	PooledConnector pc = (PooledConnector) connector;
-    	 	
-    	 	return pc.getConnectionPoolStats();
-	     }
-	     return Collections.emptyList();
-	}
+    }
 }

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr.impl;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+public class ConnectorManagerRepository implements Serializable{
+	private static final long serialVersionUID = -1611063218178314458L;
+
+	private Map<String, ConnectorManager> repo = new ConcurrentHashMap<String, ConnectorManager>();
+	
+	public void addConnectorManager(String connectorName, ConnectorManager mgr) {
+		this.repo.put(connectorName, mgr);
+	}
+	
+	public ConnectorManager getConnectorManager(String connectorName) {
+		return this.repo.get(connectorName);
+	}
+	
+	public ConnectorManager removeConnectorManager(String connectorName) {
+		return this.repo.remove(connectorName);
+	}
+}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,19 +27,20 @@
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
+import javax.resource.spi.work.WorkEvent;
 
+import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.api.DataNotAvailableException;
 import org.teiid.connector.api.Execution;
 import org.teiid.connector.api.ProcedureExecution;
 import org.teiid.connector.api.ResultSetExecution;
 import org.teiid.connector.api.UpdateExecution;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQueryCommand;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.QueryExpression;
 import org.teiid.connector.metadata.runtime.RuntimeMetadata;
 import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
 import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
@@ -75,14 +76,16 @@
     protected AtomicRequestID id;
     protected ConnectorManager manager;
     protected AtomicRequestMessage requestMsg;
-    protected boolean isTransactional;
+    protected Connector connector;
+    QueryMetadataInterface queryMetadata;
     
     /* Created on new request */
     protected Connection connection;
+    protected ConnectorEnvironment connectorEnv;
     protected ExecutionContextImpl securityContext;
     protected volatile ResultSetExecution execution;
     protected ProcedureBatchHandler procedureBatchHandler;
-    private ICommand translatedCommand;
+    private org.teiid.connector.language.Command translatedCommand;
     private Class<?>[] schema;
     private List<Integer> convertToRuntimeType;
     private boolean[] convertToDesiredRuntimeType;
@@ -104,53 +107,51 @@
 
     protected ResultsReceiver<AtomicResultsMessage> resultsReceiver;
     
-    ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
+    ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) throws ConnectorException {
         this.id = message.getAtomicRequestID();
         this.requestMsg = message;
         this.manager = manager;
         this.resultsReceiver = resultsReceiver;
         AtomicRequestID requestID = this.requestMsg.getAtomicRequestID();
         this.securityContext = new ExecutionContextImpl(requestMsg.getWorkContext().getVdbName(),
-                requestMsg.getWorkContext().getVdbVersion(),
-                requestMsg.getWorkContext().getUserName(),
-                requestMsg.getWorkContext().getTrustedPayload(),
+                requestMsg.getWorkContext().getVdbVersion(),                
                 requestMsg.getExecutionPayload(),                                                                       
                 requestMsg.getWorkContext().getConnectionID(),                                                                      
-                requestMsg.getConnectorID().getID(),
+                requestMsg.getConnectorName(),
                 requestMsg.getRequestID().toString(),
                 Integer.toString(requestID.getNodeID()),
                 Integer.toString(requestID.getExecutionId())
                 );
+        this.securityContext.setUser(requestMsg.getWorkContext().getSubject());
         this.securityContext.setBatchSize(this.requestMsg.getFetchSize());
         this.securityContext.setContextCache(manager.getContextCache());
+        
+        this.connector = manager.getConnector();
+        this.connectorEnv = connector.getConnectorEnvironment();
+        try {
+        	VDBMetaData vdb = requestMsg.getWorkContext().getVDB();
+        	this.queryMetadata = vdb.getAttachment(QueryMetadataInterface.class);
+	        this.queryMetadata = new TempMetadataAdapter(this.queryMetadata, new TempMetadataStore());
+	        
+	        if (requestMsg.isTransactional()){
+	        	if (this.connectorEnv.isXaCapable()) {
+		    		this.securityContext.setTransactional(true);
+	        	} else if (!this.connectorEnv.isImmutable() && requestMsg.getCommand().updatingModelCount(queryMetadata) > 0) {
+	    	        throw new ConnectorException(DQPPlugin.Util.getString("ConnectorWorker.transactionNotSupported")); //$NON-NLS-1$
+	    	    }
+	        }
+        } catch(MetaMatrixComponentException e) {
+        	throw new ConnectorException(e);
+        }
     }
 
-    protected void createConnection(ConnectorWrapper connector, QueryMetadataInterface queryMetadata) throws ConnectorException, MetaMatrixComponentException {
+    protected void createConnection() throws ConnectorException {
         LogManager.logTrace(LogConstants.CTX_CONNECTOR, new Object[] {id, "creating connection for atomic-request"});  //$NON-NLS-1$
-         
-        if (requestMsg.isTransactional()){
-        	if (manager.isXa()) {
-	    		this.securityContext.setTransactional(true);
-	    		this.isTransactional = true;
-	    		try {
-					manager.getTransactionService().getTransactionManager().resume(requestMsg.getTransactionContext().getTransaction());
-				} catch (InvalidTransactionException e) {
-					throw new ConnectorException(e);
-				} catch (SystemException e) {
-					throw new ConnectorException(e);
-				}
-        	} else if (!manager.isImmutable() && requestMsg.getCommand().updatingModelCount(queryMetadata) > 0) {
-    	        throw new ConnectorException(DQPPlugin.Util.getString("ConnectorWorker.transactionNotSupported")); //$NON-NLS-1$
-    	    }
-    	}
-        
-    	connection = connector.getConnection(this.securityContext, this.isTransactional?requestMsg.getTransactionContext():null);
+    	this.connection = this.connector.getConnection();
     }
     
     protected void process() {
     	DQPWorkContext.setWorkContext(this.requestMsg.getWorkContext());
-        ClassLoader contextloader = Thread.currentThread().getContextClassLoader();
-    	Thread.currentThread().setContextClassLoader(this.manager.getClassloader());
     	boolean success = true;
     	try {
     		checkForCloseEvent();
@@ -180,13 +181,10 @@
     		this.requestState = RequestState.CLOSE;
         	handleError(t);
         } finally {
-        	try {
-	        	if (this.requestState == RequestState.CLOSE) {
-	    			processClose(success);
-	        	} 
-        	} finally {
-            	Thread.currentThread().setContextClassLoader(contextloader);
-        	}
+        	if (this.requestState == RequestState.CLOSE) {
+    			processClose(success);
+        	} 
+        	DQPWorkContext.releaseWorkContext();
         }
     }
 
@@ -264,26 +262,16 @@
         } catch (Throwable e) {
             LogManager.logError(LogConstants.CTX_CONNECTOR, e, e.getMessage());
         } finally {
-        	try {
-                if (connection != null) {
-                    connection.close();
-                    LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed connection"}); //$NON-NLS-1$
-                }
-            } finally {
-                manager.removeState(this.id);
-                sendClose();
+        	// Close the underlying connection, but send the close response only upon the notification from
+        	// container in workCompleted call.
+            if (connection != null) {
+                connection.close();
+                LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed connection"}); //$NON-NLS-1$
             }
         }        
     }
 
-	private void sendClose() {
-		if (this.isTransactional) {
-			try {
-				manager.getTransactionService().getTransactionManager().suspend();
-			} catch (SystemException e) {
-				LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, e.getMessage());
-			}
-		}
+	protected void sendClose() {
 		AtomicResultsMessage response = new AtomicResultsMessage(this.requestMsg);
 		response.setRequestClosed(true);
 		this.resultsReceiver.receiveResults(response);
@@ -300,9 +288,8 @@
 	protected void createExecution() throws MetaMatrixComponentException,
 			ConnectorException {
     	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Processing NEW request:", this.requestMsg.getCommand()}); //$NON-NLS-1$                                     
-
-		QueryMetadataInterface queryMetadata = new TempMetadataAdapter(manager.getMetadataService().lookupMetadata(this.requestMsg.getWorkContext().getVdbName(), this.requestMsg.getWorkContext().getVdbVersion()), new TempMetadataStore());
-        createConnection(manager.getConnector(), queryMetadata);
+		
+        createConnection();
         
         LogManager.logTrace(LogConstants.CTX_CONNECTOR, new Object[] {id, "creating execution for atomic-request"});  //$NON-NLS-1$
 
@@ -326,14 +313,14 @@
         
         // Create the execution based on mode
         final Execution exec = connection.createExecution(this.translatedCommand, this.securityContext, rmd);
-        if (this.translatedCommand instanceof IProcedure) {
+        if (this.translatedCommand instanceof Call) {
         	Assertion.isInstanceOf(this.execution, ProcedureExecution.class, "IProcedure Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
         	this.execution = (ProcedureExecution)exec;
         	StoredProcedure proc = (StoredProcedure)command;
         	if (proc.returnParameters()) {
-        		this.procedureBatchHandler = new ProcedureBatchHandler((IProcedure)this.translatedCommand, (ProcedureExecution)this.execution);
+        		this.procedureBatchHandler = new ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)this.execution);
         	}
-        } else if (this.translatedCommand instanceof IQueryCommand){
+        } else if (this.translatedCommand instanceof QueryExpression){
         	Assertion.isInstanceOf(this.execution, ResultSetExecution.class, "IQueryCommand Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
         	this.execution = (ResultSetExecution)exec;
         } else {
@@ -380,8 +367,14 @@
         int batchSize = 0;
         List<List> rows = new ArrayList<List>(batchSize/4);
         boolean sendResults = true;
-    	try {
+        
+        try {
 	        while (batchSize < this.requestMsg.getFetchSize()) {
+	        	
+	        	if (shouldAbortProcessing()) {
+	        		throw new ConnectorException("Container requested to abort the operation!");
+	        	}
+	        	
         		List row = this.execution.next();
             	if (row == null) {
             		this.lastBatch = true;
@@ -397,13 +390,13 @@
             	correctTypes(row);
             	rows.add(row);
 	            // Check for max result rows exceeded
-	            if(manager.getMaxResultRows() != 0 && this.rowCount >= manager.getMaxResultRows()){
-	                if (this.rowCount == manager.getMaxResultRows() && !manager.isExceptionOnMaxRows()) {
-		                LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Exceeded max, returning", manager.getMaxResultRows()}); //$NON-NLS-1$
+	            if(this.connectorEnv.getMaxResultRows() != 0 && this.rowCount >= this.connectorEnv.getMaxResultRows()){
+	                if (this.rowCount == this.connectorEnv.getMaxResultRows() && !this.connectorEnv.isExceptionOnMaxRows()) {
+		                LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Exceeded max, returning", this.connectorEnv.getMaxResultRows()}); //$NON-NLS-1$
 		        		this.lastBatch = true;
 		        		break;
-	            	} else if (this.rowCount > manager.getMaxResultRows() && manager.isExceptionOnMaxRows()) {
-	                    String msg = DQPPlugin.Util.getString("ConnectorWorker.MaxResultRowsExceed", manager.getMaxResultRows()); //$NON-NLS-1$
+	            	} else if (this.rowCount > this.connectorEnv.getMaxResultRows() && this.connectorEnv.isExceptionOnMaxRows()) {
+	                    String msg = DQPPlugin.Util.getString("ConnectorWorker.MaxResultRowsExceed", this.connectorEnv.getMaxResultRows()); //$NON-NLS-1$
 	                    throw new ConnectorException(msg);
 	                }
 	            }
@@ -436,7 +429,7 @@
 		if ( !lastBatch && currentRowCount == 0 ) {
 		    // Defect 13366 - Should send all batches, even if they're zero size.
 		    // Log warning if received a zero-size non-last batch from the connector.
-		    LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorWorker.zero_size_non_last_batch", requestMsg.getConnectorID())); //$NON-NLS-1$
+		    LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorWorker.zero_size_non_last_batch", requestMsg.getConnectorName())); //$NON-NLS-1$
 		}
 
 		AtomicResultsMessage response = createResultsMessage(this.requestMsg, rows.toArray(new List[currentRowCount]), requestMsg.getCommand().getProjectedSymbols());
@@ -535,4 +528,35 @@
 		return this.id.toString();
 	}
 
+	@Override
+	public void workCompleted(WorkEvent arg0) {
+        manager.removeState(this.id);
+        sendClose();
+	}
+
+	@Override
+	public void workRejected(WorkEvent event) {
+		try {
+			asynchCancel();
+		} catch (ConnectorException e) {
+			LogManager.logError(LogConstants.CTX_CONNECTOR, event.getException(), this.id.toString()); 
+		}
+	}
+	
+	@Override
+    protected boolean assosiateSecurityContext() {
+		DQPWorkContext context = requestMsg.getWorkContext();
+		if (context.getSubject() != null) {
+        	return manager.getSecurityHelper().assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());			
+		}
+		return false;
+	}
+    
+	@Override
+    protected void clearSecurityContext() {
+		DQPWorkContext context = requestMsg.getWorkContext();
+		if (context.getSubject() != null) {
+			manager.getSecurityHelper().clearSecurityContext(context.getSecurityDomain());			
+		}
+	}
 }
\ No newline at end of file

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,6 +23,11 @@
 package org.teiid.dqp.internal.datamgr.impl;
 
 
+
+import javax.resource.spi.work.WorkManager;
+
+import org.teiid.connector.api.ConnectorException;
+
 import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
@@ -37,11 +42,11 @@
 		this.synchWorkers = synchWorkers;
 	}
 	
-	public ConnectorWorkItem createWorkItem(AtomicRequestMessage message, ResultsReceiver<AtomicResultsMessage> receiver) {
+	public ConnectorWorkItem createWorkItem(AtomicRequestMessage message, ResultsReceiver<AtomicResultsMessage> receiver, WorkManager wm) throws ConnectorException {
     	if (synchWorkers) {
     		return new SynchConnectorWorkItem(message, manager, receiver);
     	} 
-    	return new AsynchConnectorWorkItem(message, manager, receiver);
+    	return new AsynchConnectorWorkItem(message, manager, receiver, wm);
 	}
 	
 }

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,154 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.impl;
-
-import java.util.concurrent.TimeUnit;
-
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.Connector;
-import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MetadataProvider;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.connector.xa.api.XAConnection;
-import org.teiid.connector.xa.api.XAConnector;
-import org.teiid.dqp.internal.pooling.connector.ConnectionPool;
-
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.dqp.service.ConnectorStatus;
-
-/**
- * ConnectorWrapper adds default behavior to the wrapped connector.
- */
-public class ConnectorWrapper implements MetadataProvider {
-	
-	private Connector actualConnector;
-	private volatile ConnectorStatus status = ConnectorStatus.UNABLE_TO_CHECK;
-	
-	public ConnectorWrapper(Connector actualConnector){
-		this.actualConnector = actualConnector;
-	}
-
-	public void start(ConnectorEnvironment environment) throws ConnectorException {
-		actualConnector.start(environment);
-		int interval = PropertiesUtils.getIntProperty(environment.getProperties(), ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, ConnectionPool.DEFAULT_SOURCE_CONNECTION_TEST_INTERVAL);
-		if (interval > 0 && isConnectionTestable()) {
-			environment.scheduleAtFixedRate(new Runnable() {
-				@Override
-				public void run() {
-					updateStatus();
-				}
-			}, 0, interval, TimeUnit.SECONDS);
-		}
-	}
-	
-	protected boolean isConnectionTestable() {
-		return supportsSingleIdentity();
-	}
-
-	public void stop() {
-		actualConnector.stop();
-	}
-	
-	public final Connection getConnection(ExecutionContext context, TransactionContext transactionContext)
-	throws ConnectorException {
-		if (context instanceof ExecutionContextImpl && context.getConnectorIdentity() == null) {
-    		((ExecutionContextImpl)context).setConnectorIdentity(createIdentity(context));
-    	}
-		if (transactionContext == null) {
-			return getConnectionDirect(context);
-		}
-		return getXAConnectionDirect(context, transactionContext);
-	}
-	
-	protected Connection getConnectionDirect(ExecutionContext context)
-			throws ConnectorException {
-		return actualConnector.getConnection(context);
-	}
-	
-	protected XAConnection getXAConnectionDirect(ExecutionContext executionContext,
-			TransactionContext transactionContext) throws ConnectorException {
-		if (actualConnector instanceof XAConnector) {
-    		return ((XAConnector)actualConnector).getXAConnection(executionContext, transactionContext);
-    	}
-    	return null;
-	}
-
-	public ConnectorCapabilities getCapabilities() {
-	    return actualConnector.getCapabilities();
-	}
-	
-	public final ConnectorStatus getStatus() {
-		return status;
-	}
-	
-	protected void updateStatus() {
-		this.status = testConnection();
-	}
-
-	protected ConnectorStatus testConnection() {
-		if (supportsSingleIdentity()) {
-			Connection conn = null;
-			try {
-				conn = this.getConnectionDirect(null);
-				return conn.isAlive()?ConnectorStatus.OPEN:ConnectorStatus.DATA_SOURCE_UNAVAILABLE;
-			} catch (ConnectorException e) {
-				return ConnectorStatus.DATA_SOURCE_UNAVAILABLE;
-			} finally {
-				if (conn != null) {
-					conn.close();
-				}
-			}
-		}
-		return ConnectorStatus.UNABLE_TO_CHECK;
-	}
-	
-	public Connector getActualConnector() {
-		return actualConnector;
-	}
-	
-	public ConnectorIdentity createIdentity(ExecutionContext context)
-			throws ConnectorException {
-		return actualConnector.createIdentity(context);
-	}
-	
-	public boolean supportsSingleIdentity() {
-		try {
-			return createIdentity(null) != null;
-		} catch (ConnectorException e) {
-			return false;
-		}
-	}
-	
-	@Override
-	public void getConnectorMetadata(MetadataFactory metadataFactory)
-			throws ConnectorException {
-		if (this.actualConnector instanceof MetadataProvider) {
-			((MetadataProvider)this.actualConnector).getConnectorMetadata(metadataFactory);
-		}
-	}
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.
- */
-
-/*
- * Date: Sep 16, 2003
- * Time: 11:23:00 AM
- */
-package org.teiid.dqp.internal.datamgr.impl;
-
-import org.teiid.connector.api.ConnectorLogger;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.util.LogConstants;
-
-/**
- * DefaultConnectorLogger.
- */
-public class DefaultConnectorLogger implements ConnectorLogger {
-    public DefaultConnectorLogger(ConnectorID loggingID) {
-    }
-
-    public void logError(String message) {
-        LogManager.logError(LogConstants.CTX_CONNECTOR, message);
-    }
-
-    public void logError(String message, Throwable error) {
-        LogManager.logError(LogConstants.CTX_CONNECTOR, error, message);
-    }
-
-    public void logWarning(String message) {
-        LogManager.logWarning(LogConstants.CTX_CONNECTOR, message);
-    }
-
-    public void logInfo(String message) {
-        LogManager.logInfo(LogConstants.CTX_CONNECTOR, message);
-    }
-
-    public void logDetail(String message) {
-        LogManager.logDetail(LogConstants.CTX_CONNECTOR, message);
-    }
-
-    public void logTrace(String message) {
-        LogManager.logTrace(LogConstants.CTX_CONNECTOR, message);
-    }
-
-	@Override
-	public boolean isDetailEnabled() {
-		return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL);
-	}
-
-	@Override
-	public boolean isErrorEnabled() {
-		return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.ERROR);
-	}
-
-	@Override
-	public boolean isInfoEnabled() {
-		return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.INFO);
-	}
-
-	@Override
-	public boolean isTraceEnabled() {
-		return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.TRACE);
-	}
-
-	@Override
-	public boolean isWarningEnabled() {
-		return LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.WARNING);
-	}
-
-	@Override
-	public void logDetail(String message, Throwable error) {
-		LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_CONNECTOR, error, message);
-	}
-
-	@Override
-	public void logInfo(String message, Throwable error) {
-		LogManager.log(MessageLevel.INFO, LogConstants.CTX_CONNECTOR, error, message);
-	}
-
-	@Override
-	public void logTrace(String message, Throwable error) {
-		LogManager.log(MessageLevel.TRACE, LogConstants.CTX_CONNECTOR, error, message);		
-	}
-
-	@Override
-	public void logWarning(String message, Throwable error) {
-		LogManager.log(MessageLevel.WARNING, LogConstants.CTX_CONNECTOR, error, message);	
-	}
-}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,17 +23,22 @@
 package org.teiid.dqp.internal.datamgr.impl;
 
 import java.io.Serializable;
+import java.security.Principal;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.teiid.connector.api.ConnectorIdentity;
+import javax.security.auth.Subject;
+
+import org.teiid.connector.api.CacheScope;
 import org.teiid.connector.api.ExecutionContext;
 import org.teiid.dqp.internal.cache.DQPContextCache;
+import org.teiid.dqp.internal.process.DQPWorkContext;
 
 import com.metamatrix.cache.Cache;
 import com.metamatrix.common.buffer.BufferManager;
 import com.metamatrix.core.util.HashCodeUtil;
+import com.metamatrix.dqp.DQPPlugin;
 
 /**
  */
@@ -44,15 +49,13 @@
     //  Access Node ID
     private String partID;
     // currentConnector ID
-    private String connectorID;    
+    private String connectorName;    
     // current VDB 
     private String vdbName;
     // Current VDB's version
-    private String vdbVersion;
+    private int vdbVersion;
     // User Name
-    private String userName;
-    // Payload setup on the Connection Object
-    private Serializable trustedPayload;
+    private Subject user;
     // Payload setup on the Statement object
     private Serializable executionPayload;
     // ID of the parent JDBC Connection which is executing the statement
@@ -63,24 +66,18 @@
     private boolean keepAlive = false;
     
     private boolean isTransactional;
-    
-    private ConnectorIdentity connectorIdentity;
-    
     private DQPContextCache contextCache;
     
     private int batchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
 	private List<Exception> warnings = new LinkedList<Exception>();
     
-    public ExecutionContextImpl(String vdbName, String vdbVersion, String userName,
-                                Serializable trustedPayload, Serializable executionPayload, 
-                                String originalConnectionID, String connectorId, String requestId, String partId, String execCount) {
+    public ExecutionContextImpl(String vdbName, int vdbVersion,  Serializable executionPayload, 
+                                String originalConnectionID, String connectorName, String requestId, String partId, String execCount) {
         
         this.vdbName = vdbName;
         this.vdbVersion = vdbVersion;
-        this.userName = userName;
-        this.trustedPayload = trustedPayload;
         this.executionPayload = executionPayload;
-        this.connectorID = connectorId;
+        this.connectorName = connectorName;
         this.requestID = requestId;
         this.partID = partId;        
         this.requestConnectionID = originalConnectionID;
@@ -88,43 +85,50 @@
     }
     
     public String getConnectorIdentifier() {
-        return this.connectorID;
+        return this.connectorName;
     }
     
+    @Override
     public String getRequestIdentifier() {
         return this.requestID;
     }
 
+    @Override
     public String getPartIdentifier() {
         return this.partID;
     }
+    
+    @Override
     public String getExecutionCountIdentifier() {
         return this.executeCount;
     }
+    @Override
     public String getVirtualDatabaseName() {
         return this.vdbName;
     }
-
-    public String getVirtualDatabaseVersion() {
+    @Override
+    public int getVirtualDatabaseVersion() {
         return this.vdbVersion;
     }
-
-    public String getUser() {
-        return this.userName;
+    @Override
+    public Subject getSubject() {
+        return this.user;
     }
-
-    public Serializable getTrustedPayload() {
-        return this.trustedPayload;
+    
+    public void setUser(Subject user) {
+        this.user = user;
     }
 
+    @Override
     public Serializable getExecutionPayload() {
         return executionPayload;
     }
     
+    @Override
 	public String getConnectionIdentifier() {
 		return requestConnectionID;
 	}
-
+    @Override
     public void keepExecutionAlive(boolean alive) {
         this.keepAlive = alive;
     }    
@@ -163,9 +167,16 @@
     }
 
     public String toString() {
-        return "ExecutionContext<vdb=" + this.vdbName + ", version=" + this.vdbVersion + ", user=" + this.userName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+    	String userName = null;
+    	if (this.user != null) {
+	    	for(Principal p:this.user.getPrincipals()) {
+	    		userName = p.getName();
+	    	}
+    	}
+        return "ExecutionContext<vdb=" + this.vdbName + ", version=" + this.vdbVersion + ", user=" + userName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
-
+	
+    @Override
 	public boolean isTransactional() {
 		return isTransactional;
 	}
@@ -173,17 +184,8 @@
 	void setTransactional(boolean isTransactional) {
 		this.isTransactional = isTransactional;
 	}
-
+		
 	@Override
-	public ConnectorIdentity getConnectorIdentity() {
-		return this.connectorIdentity;
-	}
-	
-	public void setConnectorIdentity(ConnectorIdentity connectorIdentity) {
-		this.connectorIdentity = connectorIdentity;
-	}
-	
-	@Override
 	public int getBatchSize() {
 		return batchSize;
 	}
@@ -229,4 +231,58 @@
 			cache.put(key, value);
 		}
 	}	
+	
+	
+	@Override
+	public Object getFromCache(CacheScope scope, Object key) {
+		DQPWorkContext context = DQPWorkContext.getWorkContext();
+		checkScopeValidity(scope, context);
+
+		Cache cache = getScopedCache(scope, context);
+		if (cache != null) {
+			return cache.get(key);
+		}
+		return null;
+	}
+	
+	@Override
+	public void storeInCache(CacheScope scope, Object key, Object value) {
+		DQPWorkContext context = DQPWorkContext.getWorkContext();
+		checkScopeValidity(scope, context);
+		Cache cache = getScopedCache(scope, context);
+		if (cache != null) {
+			cache.put(key, value);
+		}
+	}
+	
+	private Cache getScopedCache(CacheScope scope, DQPWorkContext context) {
+		switch (scope) {
+			case SERVICE:
+				return contextCache.getServiceScopedCache(getConnectorIdentifier());
+			case SESSION:
+				return contextCache.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID()));
+			case VDB:
+				return contextCache.getVDBScopedCache(context.getVdbName(), context.getVdbVersion());
+			case GLOBAL:
+				return contextCache.getGlobalScopedCache();
+		}
+		return null;
+	}
+	
+	private void checkScopeValidity(CacheScope scope, DQPWorkContext context) {
+		if (scope == CacheScope.REQUEST) {
+			throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.request_scope_error")); //$NON-NLS-1$
+		}
+		
+		if (scope == CacheScope.SESSION) {
+			if (context == null || context.getSessionToken() == null) {
+				throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.session_scope_error")); //$NON-NLS-1$
+			}
+		}
+		else if (scope == CacheScope.VDB) {
+			if (context == null || context.getVdbName() == null || context.getVdbVersion() == 0) {
+				throw new IllegalStateException(DQPPlugin.Util.getString("ConnectorEnvironmentImpl.vdb_scope_error")); //$NON-NLS-1$
+			}
+		}
+	}	
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,36 +28,34 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.api.ProcedureExecution;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IParameter.Direction;
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.Argument.Direction;
 
 import com.metamatrix.dqp.DQPPlugin;
 
 class ProcedureBatchHandler {
-	private IProcedure proc;
+	private Call proc;
 	private ProcedureExecution procExec;
 	private int paramCols = 0;
 	private int resultSetCols = 0;
 	private List filler;
     
-	public ProcedureBatchHandler(IProcedure proc, ProcedureExecution procExec) throws ConnectorException {
+	public ProcedureBatchHandler(Call proc, ProcedureExecution procExec) throws ConnectorException {
 		this.proc = proc;
 		this.procExec = procExec;
-        List params = proc.getParameters();
-
+        List<Argument> params = proc.getArguments();
+        resultSetCols = proc.getResultSetColumnTypes().length;
+        if (proc.getReturnType() != null) {
+        	paramCols++;
+        }
         if(params != null && !params.isEmpty()){
-            Iterator iter = params.iterator();
-            while(iter.hasNext()){
-                IParameter param = (IParameter)iter.next();
-                if (param.getDirection() == Direction.RESULT_SET) {
-                    resultSetCols = param.getMetadataObject().getChildren().size();
-                } else if(param.getDirection() == Direction.RETURN || param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
+        	for (Argument param : params) {
+                if(param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
                     paramCols += 1;
                 }
             }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,10 +26,16 @@
 import java.util.Map;
 import java.util.concurrent.Semaphore;
 
+import javax.resource.spi.work.WorkEvent;
+import javax.transaction.xa.Xid;
+
+import org.teiid.connector.api.ConnectorException;
+
 import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
+import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.dqp.util.LogConstants;
 
 public class SynchConnectorWorkItem extends ConnectorWorkItem {
@@ -39,39 +45,35 @@
 		int pendingCount;
 	}
 
-	private static Map<String, TransactionLock> TRANSACTION_LOCKS = new HashMap<String, TransactionLock>();
+	private static Map<Xid, TransactionLock> TRANSACTION_LOCKS = new HashMap<Xid, TransactionLock>();
 
 	private TransactionLock lock;
 
-	SynchConnectorWorkItem(AtomicRequestMessage message,
-			ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
+	SynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) throws ConnectorException  {
 		super(message, manager, resultsReceiver);
+		
+		// since container makes sure that there is no current work registered under current transaction it is
+		// required that lock must be acquired before we schedule the work.
+		try {
+			acquireTransactionLock();
+		} catch (InterruptedException e) {
+			interrupted(e);
+		} 			
 	}
 	
 	@Override
 	public void run() {
 		while (!this.isDoneProcessing()) { //process until closed
-			try {
-				acquireTransactionLock();
-			} catch (InterruptedException e) {
-				interrupted(e);
-			} 
-			try {
-				super.run();
-			} finally {
-				releaseTxnLock();
-			}
+			super.run();
 		}
 	}
 
 	@Override
 	protected void pauseProcessing() {
-		releaseTxnLock();
 		try {
 			while (isIdle()) {
 				this.wait();
 			}
-			acquireTransactionLock();
 		} catch (InterruptedException e) {
 			interrupted(e);
 		}
@@ -87,11 +89,12 @@
 		this.notify();
 	}
 	
-	private void acquireTransactionLock() throws InterruptedException {
-		if (!this.isTransactional) {
+	private void acquireTransactionLock() throws InterruptedException {		
+		if (!this.requestMsg.isTransactional()) {
 			return;
 		}
-		String key = requestMsg.getTransactionContext().getTxnID();
+		TransactionContext tc = this.requestMsg.getTransactionContext();		
+		Xid key = tc.getXid();
 
 		TransactionLock existing = null;
 		synchronized (TRANSACTION_LOCKS) {
@@ -101,20 +104,24 @@
 				TRANSACTION_LOCKS.put(key, existing);
 			}
 			existing.pendingCount++;
+			tc.incrementPartcipatingSourceCount(requestMsg.getConnectorName());
 		}
 		existing.lock.acquire();
 		this.lock = existing;
+		LogManager.logTrace("got the connector lock on =", key);
 	}
 
 	private void releaseTxnLock() {
-		if (!this.isTransactional || this.lock == null) {
+		if (!this.requestMsg.isTransactional() || this.lock == null) {
 			return;
 		}
+		TransactionContext tc = this.requestMsg.getTransactionContext();
 		synchronized (TRANSACTION_LOCKS) {
 			lock.pendingCount--;
 			if (lock.pendingCount == 0) {
-				String key = requestMsg.getTransactionContext().getTxnID();
+				Xid key = tc.getXid();
 				TRANSACTION_LOCKS.remove(key);
+				LogManager.logTrace("released the connector lock on =", key);
 			}
 		}
 		lock.lock.release();
@@ -128,4 +135,22 @@
     	return true;
     }
 
+    
+	@Override
+	public void workCompleted(WorkEvent event) {
+		try {
+			super.workCompleted(event);
+		} finally {
+			releaseTxnLock();
+		}
+	}
+
+	@Override
+	public void workRejected(WorkEvent event) {
+		try {
+			super.workRejected(event);
+		} finally {
+			releaseTxnLock();
+		}
+	}
 }

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.impl;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.teiid.connector.api.TypeFacility;
-
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.util.TimestampWithTimezone;
-
-/**
- */
-public class TypeFacilityImpl extends TypeFacility {
-
-    public TypeFacilityImpl() {
-    }
-
-	@Override
-	public Object convertToRuntimeType(Object value) {
-		return DataTypeManager.convertToRuntimeType(value);
-	}
-	
-	@Override
-	public Object convertDate(Date date, TimeZone initial, Calendar target,
-			Class targetType) {
-		return TimestampWithTimezone.create(date, initial, target, targetType);
-	}
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,106 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class AggregateImpl extends BaseLanguageObject implements IAggregate {
-    
-    private IExpression expression = null;
-    private String aggName;
-    private boolean isDistinct;
-    private Class type;
-    
-    public AggregateImpl(String aggName, boolean isDistinct, IExpression exp, Class type) {
-        this.expression = exp;
-        this.aggName = aggName;
-        this.isDistinct = isDistinct;
-        this.type = type;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IAggregate#getName()
-     */
-    public String getName() {
-        return this.aggName;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IAggregate#isDistinct()
-     */
-    public boolean isDistinct() {
-        return this.isDistinct;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IAggregate#getExpression()
-     */
-    public IExpression getExpression() {
-        return this.expression;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IAggregate#setName(java.lang.String)
-     */
-    public void setName(String name) {
-        this.aggName = name;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IAggregate#setDistinct(boolean)
-     */
-    public void setDistinct(boolean isDistinct) {
-        this.isDistinct = isDistinct;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IAggregate#setExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setExpression(IExpression expression) {
-        this.expression = expression;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExpression#getType()
-     */
-    public Class getType() {
-        return this.type;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
-     */
-    public void setType(Class type) {
-        this.type = type;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ILanguageObject;
-import org.teiid.connector.visitor.util.SQLStringVisitor;
-
-/**
- */
-public abstract class BaseLanguageObject implements ILanguageObject {
-
-    /**
-     * 
-     */
-    public BaseLanguageObject() {
-    }
-    
-    public String toString() {
-        return SQLStringVisitor.getSQLString(this);
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-
-/** 
- * @since 4.2
- */
-public class BatchedUpdatesImpl extends BaseLanguageObject implements
-                                                          IBatchedUpdates {
-
-    private List updateCommands;
-    public BatchedUpdatesImpl(List updateCommands) {
-        this.updateCommands = updateCommands;
-    }
-    
-    /** 
-     * @see org.teiid.connector.language.IBatchedUpdates#getUpdateCommands()
-     * @since 4.2
-     */
-    public List getUpdateCommands() {
-        return updateCommands;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(org.teiid.connector.visitor.framework.LanguageObjectVisitor)
-     * @since 4.2
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class CompareCriteriaImpl extends BaseLanguageObject implements ICompareCriteria {
-
-    private IExpression leftExpression = null;
-    private IExpression rightExpression = null;
-    private Operator operator;
-    
-    public CompareCriteriaImpl(IExpression left, IExpression right, Operator operator) {
-        leftExpression = left;
-        rightExpression = right;
-        this.operator = operator;
-    }
-    /**
-     * @see org.teiid.connector.language.ICompareCriteria#getLeftExpression()
-     */
-    public IExpression getLeftExpression() {
-        return leftExpression;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ICompareCriteria#getRightExpression()
-     */
-    public IExpression getRightExpression() {
-        return rightExpression;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ICompareCriteria#getOperator()
-     */
-    public Operator getOperator() {
-        return this.operator;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ICompareCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setLeftExpression(IExpression expression) {
-        this.leftExpression = expression;
-    }
-    
-    /* 
-     * @see com.metamatrix.data.language.ICompareCriteria#setRightExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setRightExpression(IExpression expression) {
-        this.rightExpression = expression;
-    }
-    
-    /* 
-     * @see com.metamatrix.data.language.ICompareCriteria#setOperator(int)
-     */
-    public void setOperator(Operator operator) {
-        this.operator = operator;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-    
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class CompoundCriteriaImpl extends BaseLanguageObject implements ICompoundCriteria {
-    
-    private List criteria = null;
-    private Operator operator = Operator.AND;
-    
-    public CompoundCriteriaImpl(List nestedCriteria, Operator operator) {
-        criteria = nestedCriteria;
-        this.operator = operator; 
-    }
-
-    /**
-     * @see org.teiid.connector.language.ICompoundCriteria#getOperator()
-     */
-    public Operator getOperator() {
-        return this.operator;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ICompoundCriteria#getCriteria()
-     */
-    public List getCriteria() {
-        return criteria;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ICompoundCriteria#setOperator(int)
-     */
-    public void setOperator(Operator operator) {
-        this.operator = operator;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ICompoundCriteria#setCriteria(java.util.List)
-     */
-    public void setCriteria(List criteria) {
-        this.criteria = criteria;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class DeleteImpl extends BaseLanguageObject implements IDelete {
-
-    private IGroup group = null;
-    private ICriteria criteria = null;
-    
-    public DeleteImpl(IGroup group, ICriteria criteria) {
-        this.group = group;
-        this.criteria = criteria;
-    }
-    /**
-     * @see org.teiid.connector.language.IDelete#getGroup()
-     */
-    public IGroup getGroup() {
-        return group;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IDelete#getCriteria()
-     */
-    public ICriteria getCriteria() {
-        return criteria;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-    
-    /* 
-     * @see com.metamatrix.data.language.IDelete#setGroup(com.metamatrix.data.language.IGroup)
-     */
-    public void setGroup(IGroup group) {
-        this.group = group;
-    }
-    
-    /* 
-     * @see com.metamatrix.data.language.IDelete#setCriteria(com.metamatrix.data.language.ICriteria)
-     */
-    public void setCriteria(ICriteria criteria) {
-        this.criteria = criteria;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class ElementImpl extends BaseLanguageObject implements IElement {
-
-    private IGroup group;
-    private String name;
-    private Element metadataObject;
-    private Class type;
-    
-    public ElementImpl(IGroup group, String name, Element metadataObject, Class type) {
-        this.group = group;
-        this.name = name;
-        this.metadataObject = metadataObject;
-        this.type = type;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.IElement#getName()
-     */
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IElement#getGroup()
-     */
-    public IGroup getGroup() {
-        return group;
-    }
-
-    @Override
-    public Element getMetadataObject() {
-    	return this.metadataObject;
-    }
-    
-    public void setMetadataObject(Element metadataObject) {
-		this.metadataObject = metadataObject;
-	}
-    
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IElement#setGroup(com.metamatrix.data.language.IGroup)
-     */
-    public void setGroup(IGroup group) {
-        this.group = group;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExpression#getType()
-     */
-    public Class getType() {
-        return this.type;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IElement#setName(java.lang.String)
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
-     */
-    public void setType(Class type) {
-        this.type = type;
-    }
-
-    /**
-     * Compare the symbol based ONLY on name.  Symbols are not compared based on
-     * their underlying physical metadata IDs but rather on their representation
-     * in the context of a particular query.  Case is not important when comparing
-     * symbol names.
-     * @param obj Other object
-     * @return True if other obj is a Symbol (or subclass) and name is equal
-     */
-    public boolean equals(Object obj) {
-        if(obj == this) {
-            return true;
-        }
-
-        if(obj != null && obj instanceof IElement) {
-            IElement other = (IElement) obj;
-            
-            // Compare groups
-            if(other.getGroup() == null) {
-                if(this.getGroup() != null) {
-                    return false;
-                }
-            } else {
-                if(this.getGroup() == null) {
-                    return false;
-                }
-                if(! other.getGroup().equals(this.getGroup())) {
-                    return false;
-                }
-            }
-            
-            // Compare elements
-            String thisShortName = this.getName();
-            int dotIndex = thisShortName.lastIndexOf('.');
-            if(dotIndex >= 0) {
-                thisShortName = thisShortName.substring(dotIndex+1);
-            }
-            
-            String otherShortName = other.getName();
-            dotIndex = otherShortName.lastIndexOf('.');
-            if(dotIndex >= 0) {
-                otherShortName = otherShortName.substring(dotIndex+1);
-            }
-            
-            return thisShortName.equalsIgnoreCase(otherShortName);
-        }
-        return false;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- */
-public class ExistsCriteriaImpl extends BaseLanguageObject implements IExistsCriteria {
-
-    private IQueryCommand query;
-    
-    /**
-     * 
-     */
-    public ExistsCriteriaImpl(IQuery query) {
-        this.query = query;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryContainer#getQuery()
-     */
-    public IQueryCommand getQuery() {
-        return query;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryContainer#setQuery(com.metamatrix.data.language.IQuery)
-     */
-    public void setQuery(IQueryCommand query) {
-        this.query = query;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class FromImpl extends BaseLanguageObject implements IFrom {
-
-    private List items = null;
-    
-    public FromImpl(List items) {
-        this.items = items;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.IFrom#getItems()
-     */
-    public List getItems() {
-        return items;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IFrom#setItems(java.util.List)
-     */
-    public void setItems(List items) {
-        this.items = items;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class FunctionImpl extends BaseLanguageObject implements IFunction {
-
-    private String name;
-    private List<IExpression> parameters;
-    private Class type;
-    
-    public FunctionImpl(String name, List<? extends IExpression> params, Class type) {
-        this.name = name;
-        if (params == null) {
-        	this.parameters = new ArrayList<IExpression>(0);
-        } else {
-        	this.parameters = new ArrayList<IExpression>(params);
-        }
-        this.type = type;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.IFunction#getName()
-     */
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IFunction#getParameters()
-     */
-    public List<IExpression> getParameters() {
-        return parameters;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IFunction#setName(java.lang.String)
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExpression#getType()
-     */
-    public Class getType() {
-        return this.type;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
-     */
-    public void setType(Class type) {
-        this.type = type;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class GroupByImpl extends BaseLanguageObject implements IGroupBy {
-
-    private List elements = null;
-    
-    public GroupByImpl(List elements) {
-        this.elements = elements;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.IGroupBy#getElements()
-     */
-    public List getElements() {
-        return elements;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IGroupBy#setElements(java.util.List)
-     */
-    public void setElements(List elements) {
-        this.elements = elements;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,113 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.metadata.runtime.Group;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-import com.metamatrix.core.util.HashCodeUtil;
-
-public class GroupImpl extends BaseLanguageObject implements IGroup {
-
-    private String context;
-    private String definition;    
-    private Group metadataObject;
-    
-    public GroupImpl(String context, String definition, Group group) {
-        this.context = context;
-        this.definition = definition;
-        this.metadataObject = group;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IGroup#getContext()
-     */
-    public String getContext() {
-        return context;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IGroup#getDefinition()
-     */
-    public String getDefinition() {
-        return this.definition;
-    }
-
-    @Override
-    public Group getMetadataObject() {
-    	return this.metadataObject;
-    }
-    
-    public void setMetadataObject(Group metadataObject) {
-		this.metadataObject = metadataObject;
-	}
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IGroup#setDefinition(java.lang.String)
-     */
-    public void setDefinition(String definition) {
-        this.definition = definition;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IGroup#setContext(java.lang.String)
-     */
-    public void setContext(String context) {
-        this.context = context;
-    }
-    
-    public int hashCode() {
-        return HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, this.getDefinition()), this.getContext());
-    }
-    
-    public boolean equals(Object obj) {
-        if(this == obj) {
-            return true;
-        }
-
-        if(obj == null || ! (obj instanceof IGroup)) {
-            return false;
-        }
-        IGroup other = (IGroup) obj;
-
-        // Two group symbols will be equal only if both use aliases or both
-        // don't use aliases.  In either case, comparing context names is
-        // enough.
-        if( (this.getDefinition() == null && other.getDefinition() == null) ||
-            (this.getDefinition() != null && other.getDefinition() != null) ) {
-
-            return this.getContext().equalsIgnoreCase(other.getContext());
-
-        }
-        return false;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class InCriteriaImpl extends BaseLanguageObject implements IInCriteria {
-
-    private IExpression leftExpression = null;
-    private List rightExpressions = null;
-    private boolean negated = false;
-    
-    public InCriteriaImpl(IExpression left, List right, boolean negated) {
-        leftExpression = left;
-        rightExpressions = right;
-        this.negated = negated;
-    }
-    /**
-     * @see org.teiid.connector.language.IInCriteria#getLeftExpression()
-     */
-    public IExpression getLeftExpression() {
-        return leftExpression;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IInCriteria#getRightExpressions()
-     */
-    public List getRightExpressions() {
-        return rightExpressions;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IInCriteria#isNegated()
-     */
-    public boolean isNegated() {
-        return this.negated;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-    /* 
-     * @see com.metamatrix.data.language.IInCriteria#setRightExpressions(java.util.List)
-     */
-    public void setRightExpressions(List expressions) {
-        this.rightExpressions = expressions;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IBaseInCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setLeftExpression(IExpression expression) {
-        this.leftExpression = expression;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IBaseInCriteria#setNegated(boolean)
-     */
-    public void setNegated(boolean negated) {
-        this.negated = negated;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- * Inline views are treated like aliased groups
- */
-public class InlineViewImpl extends GroupImpl implements IInlineView {
-
-    private String name;
-    private IQueryCommand query;
-    private String output;
-
-    public InlineViewImpl(IQueryCommand query, String name) {        
-        super(name, name, null);
-        this.query = query;
-        this.name = name;
-    }
-
-    public String getName() {
-        return this.name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public IQueryCommand getQuery() {
-        return this.query;
-    }
-
-    public void setQuery(IQueryCommand query) {
-        this.query = query;
-    }
-
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-	public String getOutput() {
-		return output;
-	}
-
-	public void setOutput(String output) {
-		this.output = output;
-	}
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertValueSource;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class InsertImpl extends BaseLanguageObject implements IInsert {
-    
-    private IGroup group;
-    private List elements;
-    private IInsertValueSource valueSource;
-  
-    public InsertImpl(IGroup group, List elements, IInsertValueSource valueSource) {
-        this.group = group;
-        this.elements = elements;
-        this.valueSource = valueSource;
-    }
-    /**
-     * @see org.teiid.connector.language.IInsert#getGroup()
-     */
-    public IGroup getGroup() {
-        return group;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IInsert#getElements()
-     */
-    public List getElements() {
-        return elements;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IInsert#getValueSource()
-     */
-    public IInsertValueSource getValueSource() {
-        return valueSource;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-    /* 
-     * @see com.metamatrix.data.language.IInsert#setGroup(com.metamatrix.data.language.IGroup)
-     */
-    public void setGroup(IGroup group) {
-        this.group = group;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IInsert#setElements(java.util.List)
-     */
-    public void setElements(List elements) {
-        this.elements = elements;
-    }
-    
-    @Override
-    public void setValueSource(IInsertValueSource values) {
-    	this.valueSource = values;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertValueExpressionsImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertValueExpressionsImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertValueExpressionsImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,27 +0,0 @@
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class InsertValueExpressionsImpl extends BaseLanguageObject implements IInsertExpressionValueSource {
-
-	private List<IExpression> values;
-	
-	public InsertValueExpressionsImpl(List<IExpression> values) {
-		this.values = values;
-	}
-
-	@Override
-	public List<IExpression> getValues() {
-		return values;
-	}
-
-	@Override
-	public void acceptVisitor(LanguageObjectVisitor visitor) {
-		visitor.visit(this);
-	}
-	
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class IsNullCriteriaImpl extends BaseLanguageObject implements IIsNullCriteria {
-    
-    private IExpression expression = null;
-    private boolean negated = false;
-    
-    public IsNullCriteriaImpl(IExpression expr, boolean isNegated) {
-        expression = expr;
-        this.negated = isNegated;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IIsNullCriteria#getExpression()
-     */
-    public IExpression getExpression() {
-        return expression;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IIsNullCriteria#isNegated()
-     */
-    public boolean isNegated() {
-        return this.negated;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IIsNullCriteria#setExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setExpression(IExpression expression) {
-        this.expression = expression;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IIsNullCriteria#setNegated(boolean)
-     */
-    public void setNegated(boolean negated) {
-        this.negated = negated;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IFromItem;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class JoinImpl extends BaseLanguageObject implements IJoin {
-
-    private IFromItem leftItem = null;
-    private IFromItem rightItem = null;
-    private JoinType joinType;
-    private List criteria = null;
-    
-    public JoinImpl(IFromItem left, IFromItem right, JoinType joinType, List criteria) {
-        this.leftItem = left;
-        this.rightItem = right;
-        this.joinType = joinType;
-        this.criteria = criteria;
-    }
-    /**
-     * @see org.teiid.connector.language.IJoin#getLeftItem()
-     */
-    public IFromItem getLeftItem() {
-        return leftItem;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IJoin#getRightItem()
-     */
-    public IFromItem getRightItem() {
-        return rightItem;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IJoin#getJoinType()
-     */
-    public JoinType getJoinType() {
-        return this.joinType;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IJoin#getCriteria()
-     */
-    public List getCriteria() {
-        return criteria;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-    /* 
-     * @see com.metamatrix.data.language.IJoin#setLeftItem(com.metamatrix.data.language.IFromItem)
-     */
-    public void setLeftItem(IFromItem item) {
-        this.leftItem = item;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IJoin#setRightItem(com.metamatrix.data.language.IFromItem)
-     */
-    public void setRightItem(IFromItem item) {
-        this.rightItem = item;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IJoin#setJoinType(int)
-     */
-    public void setJoinType(JoinType type) {
-        this.joinType = type;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IJoin#setCriteria(java.util.List)
-     */
-    public void setCriteria(List criteria) {
-        this.criteria = criteria;
-    }
-
-}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,49 +27,39 @@
 import java.util.List;
 
 import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.IBatchedUpdates;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IFromItem;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertValueSource;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.connector.language.ICompareCriteria.Operator;
-import org.teiid.connector.language.IParameter.Direction;
-import org.teiid.connector.language.ISubqueryCompareCriteria.Quantifier;
-import org.teiid.connector.metadata.runtime.Parameter;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.AndOr;
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Condition;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.DerivedTable;
+import org.teiid.connector.language.Exists;
+import org.teiid.connector.language.ExpressionValueSource;
+import org.teiid.connector.language.In;
+import org.teiid.connector.language.InsertValueSource;
+import org.teiid.connector.language.IsNull;
+import org.teiid.connector.language.Join;
+import org.teiid.connector.language.Like;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.Not;
+import org.teiid.connector.language.QueryExpression;
+import org.teiid.connector.language.SearchedWhenClause;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.SortSpecification;
+import org.teiid.connector.language.SubqueryComparison;
+import org.teiid.connector.language.SubqueryIn;
+import org.teiid.connector.language.TableReference;
+import org.teiid.connector.language.Argument.Direction;
+import org.teiid.connector.language.Comparison.Operator;
+import org.teiid.connector.language.SortSpecification.Ordering;
+import org.teiid.connector.language.SubqueryComparison.Quantifier;
 import org.teiid.connector.metadata.runtime.Procedure;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
 import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -86,7 +76,6 @@
 import com.metamatrix.query.sql.lang.Criteria;
 import com.metamatrix.query.sql.lang.Delete;
 import com.metamatrix.query.sql.lang.ExistsCriteria;
-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;
@@ -101,7 +90,6 @@
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.lang.QueryCommand;
 import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
 import com.metamatrix.query.sql.lang.SetClause;
 import com.metamatrix.query.sql.lang.SetClauseList;
 import com.metamatrix.query.sql.lang.SetCriteria;
@@ -133,7 +121,7 @@
         }
     }
 
-    public ICommand translate(Command command) throws MetaMatrixComponentException {
+    public org.teiid.connector.language.Command translate(Command command) throws MetaMatrixComponentException {
         if (command == null) return null;
         if (command instanceof Query) {
             return translate((Query)command);
@@ -153,25 +141,25 @@
         throw new AssertionError();
     }
     
-    IQueryCommand translate(QueryCommand command) throws MetaMatrixComponentException {
+    QueryExpression translate(QueryCommand command) throws MetaMatrixComponentException {
     	if (command instanceof Query) {
             return translate((Query)command);
         } 
     	return translate((SetQuery)command);
     }
 
-    ISetQuery translate(SetQuery union) throws MetaMatrixComponentException {
-        SetQueryImpl result = new SetQueryImpl();
+    org.teiid.connector.language.SetQuery translate(SetQuery union) throws MetaMatrixComponentException {
+        org.teiid.connector.language.SetQuery result = new org.teiid.connector.language.SetQuery();
         result.setAll(union.isAll());
         switch (union.getOperation()) {
             case UNION:
-                result.setOperation(ISetQuery.Operation.UNION);
+                result.setOperation(org.teiid.connector.language.SetQuery.Operation.UNION);
                 break;
             case INTERSECT:
-                result.setOperation(ISetQuery.Operation.INTERSECT);
+                result.setOperation(org.teiid.connector.language.SetQuery.Operation.INTERSECT);
                 break;
             case EXCEPT:
-                result.setOperation(ISetQuery.Operation.EXCEPT);
+                result.setOperation(org.teiid.connector.language.SetQuery.Operation.EXCEPT);
                 break;
         }
         result.setLeftQuery(translate(union.getLeftQuery()));
@@ -182,30 +170,18 @@
     }
 
     /* Query */
-    IQuery translate(Query query) throws MetaMatrixComponentException {
-        QueryImpl q = new QueryImpl(translate(query.getSelect()),
-                             translate(query.getFrom()),
-                             translate(query.getCriteria()),
-                             translate(query.getGroupBy()),
-                             translate(query.getHaving()),
-                             translate(query.getOrderBy()));
-        q.setLimit(translate(query.getLimit()));
-        return q;
-    }
-
-    public ISelect translate(Select select) throws MetaMatrixComponentException {
-        List symbols = select.getSymbols();
-        List translatedSymbols = new ArrayList(symbols.size());
+    Select translate(Query query) throws MetaMatrixComponentException {
+        List symbols = query.getSelect().getSymbols();
+        List<DerivedColumn> translatedSymbols = new ArrayList<DerivedColumn>(symbols.size());
         for (Iterator i = symbols.iterator(); i.hasNext();) {
             SingleElementSymbol symbol = (SingleElementSymbol)i.next();
-            boolean isAlias = false;
-            String alias = symbol.getOutputName();
+            String alias = null;
             if(symbol instanceof AliasSymbol) {
+                alias = symbol.getOutputName();
                 symbol = ((AliasSymbol)symbol).getSymbol();
-                isAlias = true;
             }
 
-            IExpression iExp = null;
+            org.teiid.connector.language.Expression iExp = null;
             if(symbol instanceof ElementSymbol) {
                 iExp = translate((ElementSymbol)symbol);
             } else if(symbol instanceof AggregateSymbol) {
@@ -214,26 +190,26 @@
                 iExp = translate(((ExpressionSymbol)symbol).getExpression());
             }
 
-            SelectSymbolImpl selectSymbol = new SelectSymbolImpl(alias, iExp);
-            if(isAlias){
-                selectSymbol.setOutputName(alias);
-                selectSymbol.setAlias(true);
-            }
+            DerivedColumn selectSymbol = new DerivedColumn(alias, iExp);
             translatedSymbols.add(selectSymbol);
         }
-        return new SelectImpl(translatedSymbols, select.isDistinct());
+    	List<TableReference> items = null;
+    	if (query.getFrom() != null) {
+	    	List clauses = query.getFrom().getClauses();
+	        items = new ArrayList<TableReference>(clauses.size());
+	        for (Iterator i = clauses.iterator(); i.hasNext();) {
+	            items.add(translate((FromClause)i.next()));
+	        }
+    	}
+		Select q = new Select(translatedSymbols, query
+				.getSelect().isDistinct(), items,
+				translate(query.getCriteria()), translate(query.getGroupBy()),
+				translate(query.getHaving()), translate(query.getOrderBy()));
+        q.setLimit(translate(query.getLimit()));
+        return q;
     }
-    
-    public IFrom translate(From from) throws MetaMatrixComponentException {
-        List clauses = from.getClauses();
-        List items = new ArrayList();
-        for (Iterator i = clauses.iterator(); i.hasNext();) {
-            items.add(translate((FromClause)i.next()));
-        }
-        return new FromImpl(items);
-    }
 
-    public IFromItem translate(FromClause clause) throws MetaMatrixComponentException {
+    public TableReference translate(FromClause clause) throws MetaMatrixComponentException {
         if (clause == null) return null;
         if (clause instanceof JoinPredicate) {
             return translate((JoinPredicate)clause);
@@ -245,41 +221,43 @@
         throw new AssertionError();
     }
 
-    IJoin translate(JoinPredicate join) throws MetaMatrixComponentException {
+    Join translate(JoinPredicate join) throws MetaMatrixComponentException {
         List crits = join.getJoinCriteria();
-        List criteria = new ArrayList();
-        for (Iterator i = crits.iterator(); i.hasNext();) {
-            criteria.add(translate((Criteria)i.next()));
+        Criteria crit = null;
+        if (crits.size() == 1) {
+        	crit = (Criteria)crits.get(0);
+        } else if (crits.size() > 1) {
+        	crit = new CompoundCriteria(crits);        	
         }
         
-        IJoin.JoinType joinType = IJoin.JoinType.INNER_JOIN;
+        Join.JoinType joinType = Join.JoinType.INNER_JOIN;
         if(join.getJoinType().equals(JoinType.JOIN_INNER)) {
-            joinType = IJoin.JoinType.INNER_JOIN;
+            joinType = Join.JoinType.INNER_JOIN;
         } else if(join.getJoinType().equals(JoinType.JOIN_LEFT_OUTER)) {
-            joinType = IJoin.JoinType.LEFT_OUTER_JOIN;
+            joinType = Join.JoinType.LEFT_OUTER_JOIN;
         } else if(join.getJoinType().equals(JoinType.JOIN_RIGHT_OUTER)) {
-            joinType = IJoin.JoinType.RIGHT_OUTER_JOIN;
+            joinType = Join.JoinType.RIGHT_OUTER_JOIN;
         } else if(join.getJoinType().equals(JoinType.JOIN_FULL_OUTER)) {
-            joinType = IJoin.JoinType.FULL_OUTER_JOIN;
+            joinType = Join.JoinType.FULL_OUTER_JOIN;
         } else if(join.getJoinType().equals(JoinType.JOIN_CROSS)) {
-            joinType = IJoin.JoinType.CROSS_JOIN;
+            joinType = Join.JoinType.CROSS_JOIN;
         }
         
-        return new JoinImpl(translate(join.getLeftClause()),
+        return new Join(translate(join.getLeftClause()),
                             translate(join.getRightClause()),
                             joinType,
-                            criteria);
+                            translate(crit));
     }
 
-    IFromItem translate(SubqueryFromClause clause) throws MetaMatrixComponentException {        
-        return new InlineViewImpl(translate((QueryCommand)clause.getCommand()), clause.getOutputName());
+    TableReference translate(SubqueryFromClause clause) throws MetaMatrixComponentException {        
+        return new DerivedTable(translate((QueryCommand)clause.getCommand()), clause.getOutputName());
     }
 
-    IGroup translate(UnaryFromClause clause) throws MetaMatrixComponentException {
+    NamedTable translate(UnaryFromClause clause) throws MetaMatrixComponentException {
         return translate(clause.getGroup());
     }
 
-    public ICriteria translate(Criteria criteria) throws MetaMatrixComponentException {
+    public Condition translate(Criteria criteria) throws MetaMatrixComponentException {
         if (criteria == null) return null;
         if (criteria instanceof CompareCriteria) {
             return translate((CompareCriteria)criteria);
@@ -303,8 +281,8 @@
         throw new AssertionError();
     }
 
-    ICompareCriteria translate(CompareCriteria criteria) throws MetaMatrixComponentException {
-        ICompareCriteria.Operator operator = Operator.EQ;
+    org.teiid.connector.language.Comparison translate(CompareCriteria criteria) throws MetaMatrixComponentException {
+        Operator operator = Operator.EQ;
         switch(criteria.getOperator()) {
             case CompareCriteria.EQ:    
                 operator = Operator.EQ;
@@ -327,51 +305,52 @@
             
         }
         
-        return new CompareCriteriaImpl(translate(criteria.getLeftExpression()),
+        return new org.teiid.connector.language.Comparison(translate(criteria.getLeftExpression()),
                                         translate(criteria.getRightExpression()), operator);
     }
 
-    ICompoundCriteria translate(CompoundCriteria criteria) throws MetaMatrixComponentException {
+    AndOr translate(CompoundCriteria criteria) throws MetaMatrixComponentException {
         List nestedCriteria = criteria.getCriteria();
-        List translatedCriteria = new ArrayList();
-        for (Iterator i = nestedCriteria.iterator(); i.hasNext();) {
-            translatedCriteria.add(translate((Criteria)i.next()));
+        int size = nestedCriteria.size();
+        AndOr.Operator op = criteria.getOperator() == CompoundCriteria.AND?AndOr.Operator.AND:AndOr.Operator.OR;
+        AndOr result = new AndOr(translate((Criteria)nestedCriteria.get(size - 2)), translate((Criteria)nestedCriteria.get(size - 1)), op);
+        for (int i = nestedCriteria.size() - 3; i >= 0; i--) {
+        	result = new AndOr(translate((Criteria)nestedCriteria.get(i)), result, op);
         }
-        
-        return new CompoundCriteriaImpl(translatedCriteria, criteria.getOperator() == CompoundCriteria.AND?ICompoundCriteria.Operator.AND:ICompoundCriteria.Operator.OR);
+        return result;
     }
 
-    IExistsCriteria translate(ExistsCriteria criteria) throws MetaMatrixComponentException {
-        return new ExistsCriteriaImpl(translate((Query)criteria.getCommand()));
+    Exists translate(ExistsCriteria criteria) throws MetaMatrixComponentException {
+        return new Exists(translate((QueryCommand)criteria.getCommand()));
     }
 
-    IIsNullCriteria translate(IsNullCriteria criteria) throws MetaMatrixComponentException {
-        return new IsNullCriteriaImpl(translate(criteria.getExpression()), criteria.isNegated());
+    IsNull translate(IsNullCriteria criteria) throws MetaMatrixComponentException {
+        return new IsNull(translate(criteria.getExpression()), criteria.isNegated());
     }
 
-    ILikeCriteria translate(MatchCriteria criteria) throws MetaMatrixComponentException {
+    Like translate(MatchCriteria criteria) throws MetaMatrixComponentException {
         Character escapeChar = null;
         if(criteria.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) {
             escapeChar = new Character(criteria.getEscapeChar());
         }
-        return new LikeCriteriaImpl(translate(criteria.getLeftExpression()),
+        return new Like(translate(criteria.getLeftExpression()),
                                     translate(criteria.getRightExpression()), 
                                     escapeChar, 
                                     criteria.isNegated());
     }
 
-    IInCriteria translate(SetCriteria criteria) throws MetaMatrixComponentException {
+    In translate(SetCriteria criteria) throws MetaMatrixComponentException {
         List expressions = criteria.getValues();
         List translatedExpressions = new ArrayList();
         for (Iterator i = expressions.iterator(); i.hasNext();) {
             translatedExpressions.add(translate((Expression)i.next()));
         }
-        return new InCriteriaImpl(translate(criteria.getExpression()),
+        return new In(translate(criteria.getExpression()),
                                   translatedExpressions, 
                                   criteria.isNegated());
     }
 
-    ISubqueryCompareCriteria translate(SubqueryCompareCriteria criteria) throws MetaMatrixComponentException {
+    SubqueryComparison translate(SubqueryCompareCriteria criteria) throws MetaMatrixComponentException {
         Quantifier quantifier = Quantifier.ALL;
         switch(criteria.getPredicateQuantifier()) {
             case SubqueryCompareCriteria.ALL:   
@@ -385,84 +364,80 @@
                 break;
         }
         
-        ICompareCriteria.Operator operator = ICompareCriteria.Operator.EQ;
+        Operator operator = Operator.EQ;
         switch(criteria.getOperator()) {
             case SubqueryCompareCriteria.EQ:
-                operator = ICompareCriteria.Operator.EQ;
+                operator = Operator.EQ;
                 break;
             case SubqueryCompareCriteria.NE:
-                operator = ICompareCriteria.Operator.NE;
+                operator = Operator.NE;
                 break;
             case SubqueryCompareCriteria.LT:
-                operator = ICompareCriteria.Operator.LT;
+                operator = Operator.LT;
                 break;
             case SubqueryCompareCriteria.LE:
-                operator = ICompareCriteria.Operator.LE;
+                operator = Operator.LE;
                 break;
             case SubqueryCompareCriteria.GT:
-                operator = ICompareCriteria.Operator.GT;
+                operator = Operator.GT;
                 break;
             case SubqueryCompareCriteria.GE:
-                operator = ICompareCriteria.Operator.GE;
+                operator = Operator.GE;
                 break;                    
         }
                 
-        return new SubqueryCompareCriteriaImpl(translate(criteria.getLeftExpression()),
+        return new SubqueryComparison(translate(criteria.getLeftExpression()),
                                   operator,
                                   quantifier,
-                                  translate((Query)criteria.getCommand()));
+                                  translate((QueryCommand)criteria.getCommand()));
     }
 
-    ISubqueryInCriteria translate(SubquerySetCriteria criteria) throws MetaMatrixComponentException {
-        return new SubqueryInCriteriaImpl(translate(criteria.getExpression()),
+    SubqueryIn translate(SubquerySetCriteria criteria) throws MetaMatrixComponentException {
+        return new SubqueryIn(translate(criteria.getExpression()),
                                   criteria.isNegated(),
-                                  translate((Query)criteria.getCommand()));
+                                  translate((QueryCommand)criteria.getCommand()));
     }
 
-    INotCriteria translate(NotCriteria criteria) throws MetaMatrixComponentException {
-        return new NotCriteriaImpl(translate(criteria.getCriteria()));
+    Not translate(NotCriteria criteria) throws MetaMatrixComponentException {
+        return new Not(translate(criteria.getCriteria()));
     }
 
-    public IGroupBy translate(GroupBy groupBy) throws MetaMatrixComponentException {
+    public org.teiid.connector.language.GroupBy translate(GroupBy groupBy) throws MetaMatrixComponentException {
         if(groupBy == null){
             return null;
         }
         List items = groupBy.getSymbols();
-        List translatedItems = new ArrayList();
+        List<org.teiid.connector.language.Expression> translatedItems = new ArrayList<org.teiid.connector.language.Expression>();
         for (Iterator i = items.iterator(); i.hasNext();) {
             translatedItems.add(translate((Expression)i.next()));
         }
-        return new GroupByImpl(translatedItems);
+        return new org.teiid.connector.language.GroupBy(translatedItems);
     }
 
-    public IOrderBy translate(OrderBy orderBy) throws MetaMatrixComponentException {
+    public org.teiid.connector.language.OrderBy translate(OrderBy orderBy) throws MetaMatrixComponentException {
         if(orderBy == null){
             return null;
         }
-        List<OrderByItemImpl> translatedItems = new ArrayList<OrderByItemImpl>();
-        for (OrderByItem item : orderBy.getOrderByItems()) {
-            SingleElementSymbol symbol = item.getSymbol();
-            boolean direction = item.isAscending()?IOrderByItem.ASC:IOrderByItem.DESC;
-                                
-            OrderByItemImpl orderByItem = null;                                
-            if(symbol instanceof ElementSymbol){
-                IElement innerElement = translate((ElementSymbol)symbol);
-                if (item.isUnrelated() || (symbol.getOutputName() != null && symbol.getOutputName().indexOf(ElementSymbol.SEPARATOR) != -1)) {
-                	orderByItem = new OrderByItemImpl(null, direction, innerElement);
-                } else {
-                	orderByItem = new OrderByItemImpl(symbol.getOutputName(), direction, innerElement);
-                }
+        List<OrderByItem> items = orderBy.getOrderByItems();
+        List<SortSpecification> translatedItems = new ArrayList<SortSpecification>();
+        for (int i = 0; i < items.size(); i++) {
+            SingleElementSymbol symbol = items.get(i).getSymbol();
+            Ordering direction = items.get(i).isAscending() ? Ordering.ASC: Ordering.DESC;
+            
+            SortSpecification orderByItem = null;                                
+            if(symbol instanceof AliasSymbol || !items.get(i).isUnrelated()){
+            	orderByItem = new SortSpecification(direction, new ColumnReference(null, symbol.getOutputName(), null, symbol.getType()));
             } else {
-                orderByItem = new OrderByItemImpl(symbol.getOutputName(), direction, null);                
+            	orderByItem = new SortSpecification(direction, translate(symbol));                                
             }
             translatedItems.add(orderByItem);
         }
-        return new OrderByImpl(translatedItems);
+        return new org.teiid.connector.language.OrderBy(translatedItems);
     }
 
 
     /* Expressions */
-    public IExpression translate(Expression expr) throws MetaMatrixComponentException {
+    public org.teiid.connector.language.Expression translate(Expression expr) throws MetaMatrixComponentException {
         if (expr == null) return null;
         if (expr instanceof Constant) {
             return translate((Constant)expr);
@@ -478,46 +453,42 @@
         throw new AssertionError();
     }
 
-    ILiteral translate(Constant constant) {
-        LiteralImpl result = new LiteralImpl(constant.getValue(), constant.getType());
+    Literal translate(Constant constant) {
+        Literal result = new Literal(constant.getValue(), constant.getType());
         result.setBindValue(constant.isMultiValued());
         result.setMultiValued(constant.isMultiValued());
         return result;
     }
 
-    IFunction translate(Function function) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Function translate(Function function) throws MetaMatrixComponentException {
         Expression [] args = function.getArgs();
-        List<IExpression> params = new ArrayList<IExpression>(args.length);
+        List<org.teiid.connector.language.Expression> params = new ArrayList<org.teiid.connector.language.Expression>(args.length);
         if (args != null) {
             for (int i = 0; i < args.length; i++) {
                 params.add(translate(args[i]));
             }
         }
-        return new FunctionImpl(function.getName(), params, function.getType());
+        return new org.teiid.connector.language.Function(function.getName(), params, function.getType());
     }
 
-    ISearchedCaseExpression translate(SearchedCaseExpression expr) throws MetaMatrixComponentException {
-        ArrayList whens = new ArrayList(), thens = new ArrayList();
+    SearchedCase translate(SearchedCaseExpression expr) throws MetaMatrixComponentException {
+        ArrayList<SearchedWhenClause> whens = new ArrayList<SearchedWhenClause>();
         for (int i = 0; i < expr.getWhenCount(); i++) {
-            whens.add(translate(expr.getWhenCriteria(i)));
-            thens.add(translate(expr.getThenExpression(i)));
+        	whens.add(new SearchedWhenClause(translate(expr.getWhenCriteria(i)), translate(expr.getThenExpression(i))));
         }
-        return new SearchedCaseExpressionImpl(whens,
-                                      thens,
+        return new SearchedCase(whens,
                                       translate(expr.getElseExpression()),
                                       expr.getType());
     }
 
 
-    IExpression translate(ScalarSubquery ss) throws MetaMatrixComponentException {
-        return new ScalarSubqueryImpl(translate((Query)ss.getCommand()));
+    org.teiid.connector.language.Expression translate(ScalarSubquery ss) throws MetaMatrixComponentException {
+        return new org.teiid.connector.language.ScalarSubquery(translate((QueryCommand)ss.getCommand()));
     }
 
-    IExpression translate(SingleElementSymbol symbol) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Expression translate(SingleElementSymbol symbol) throws MetaMatrixComponentException {
         if (symbol == null) return null;
-        if (symbol instanceof AliasSymbol) {
-            return translate((AliasSymbol)symbol);
-        } else if (symbol instanceof ElementSymbol) {
+        if (symbol instanceof ElementSymbol) {
             return translate((ElementSymbol)symbol);
         } else if (symbol instanceof AggregateSymbol) {
             return translate((AggregateSymbol)symbol);
@@ -527,14 +498,14 @@
         throw new AssertionError();
     }
 
-    IExpression translate(AliasSymbol symbol) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Expression translate(AliasSymbol symbol) throws MetaMatrixComponentException {
         return translate(symbol.getSymbol());
     }
 
-    IElement translate(ElementSymbol symbol) throws MetaMatrixComponentException {
-        ElementImpl element = new ElementImpl(translate(symbol.getGroupSymbol()), symbol.getOutputName(), null, symbol.getType());
-        
-        if (element.getGroup().getMetadataObject() == null) {
+    ColumnReference translate(ElementSymbol symbol) throws MetaMatrixComponentException {
+        ColumnReference element = null;
+        element = new ColumnReference(translate(symbol.getGroupSymbol()), symbol.getOutputName(), null, symbol.getType());
+        if (element.getTable().getMetadataObject() == null) {
             return element;
         }
 
@@ -546,74 +517,72 @@
         return element;
     }
 
-    IAggregate translate(AggregateSymbol symbol) throws MetaMatrixComponentException {
-        return new AggregateImpl(symbol.getAggregateFunction(), 
+    AggregateFunction translate(AggregateSymbol symbol) throws MetaMatrixComponentException {
+        return new AggregateFunction(symbol.getAggregateFunction(), 
                                 symbol.isDistinct(), 
                                 translate(symbol.getExpression()),
                                 symbol.getType());
     }
 
-    IExpression translate(ExpressionSymbol symbol) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Expression translate(ExpressionSymbol symbol) throws MetaMatrixComponentException {
         return translate(symbol.getExpression());
     }
 
 
     /* Insert */
-    IInsert translate(Insert insert) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Insert translate(Insert insert) throws MetaMatrixComponentException {
         List elements = insert.getVariables();
-        List translatedElements = new ArrayList();
+        List<ColumnReference> translatedElements = new ArrayList<ColumnReference>();
         for (Iterator i = elements.iterator(); i.hasNext();) {
             translatedElements.add(translate((ElementSymbol)i.next()));
         }
         
-        IInsertValueSource valueSource = null;
+        InsertValueSource valueSource = null;
         if (insert.getQueryExpression() != null) {
         	valueSource = translate(insert.getQueryExpression());
         } else {
             // This is for the simple one row insert.
             List values = insert.getValues();
-            List translatedValues = new ArrayList();
+            List<org.teiid.connector.language.Expression> translatedValues = new ArrayList<org.teiid.connector.language.Expression>();
             for (Iterator i = values.iterator(); i.hasNext();) {
                 translatedValues.add(translate((Expression)i.next()));
             }
-            valueSource = new InsertValueExpressionsImpl(translatedValues);
+            valueSource = new ExpressionValueSource(translatedValues);
         }
         
-        InsertImpl result = new InsertImpl(translate(insert.getGroup()),
+        return new org.teiid.connector.language.Insert(translate(insert.getGroup()),
                               translatedElements,
                               valueSource);
-        return result;
     }
 
     /* Update */
-    IUpdate translate(Update update) throws MetaMatrixComponentException {
-        UpdateImpl updateImpl =  new UpdateImpl(translate(update.getGroup()),
+    org.teiid.connector.language.Update translate(Update update) throws MetaMatrixComponentException {
+        return new org.teiid.connector.language.Update(translate(update.getGroup()),
                               translate(update.getChangeList()),
                               translate(update.getCriteria()));
-        return updateImpl;
     }
     
-    ISetClauseList translate(SetClauseList setClauseList) throws MetaMatrixComponentException {
-    	List<ISetClause> clauses = new ArrayList<ISetClause>(setClauseList.getClauses().size());
+    List<org.teiid.connector.language.SetClause> translate(SetClauseList setClauseList) throws MetaMatrixComponentException {
+    	List<org.teiid.connector.language.SetClause> clauses = new ArrayList<org.teiid.connector.language.SetClause>(setClauseList.getClauses().size());
     	for (SetClause setClause : setClauseList.getClauses()) {
     		clauses.add(translate(setClause));
     	}
-    	return new SetClauseListImpl(clauses);
+    	return clauses;
     }
     
-    ISetClause translate(SetClause setClause) throws MetaMatrixComponentException {
-    	return new SetClauseImpl(translate(setClause.getSymbol()), translate(setClause.getValue()));
+    org.teiid.connector.language.SetClause translate(SetClause setClause) throws MetaMatrixComponentException {
+    	return new org.teiid.connector.language.SetClause(translate(setClause.getSymbol()), translate(setClause.getValue()));
     }
 
     /* Delete */
-    IDelete translate(Delete delete) throws MetaMatrixComponentException {
-        DeleteImpl deleteImpl = new DeleteImpl(translate(delete.getGroup()),
+    org.teiid.connector.language.Delete translate(Delete delete) throws MetaMatrixComponentException {
+        org.teiid.connector.language.Delete deleteImpl = new org.teiid.connector.language.Delete(translate(delete.getGroup()),
                               translate(delete.getCriteria()));
         return deleteImpl;
     }
 
     /* Execute */
-    IProcedure translate(StoredProcedure sp) throws MetaMatrixComponentException {
+    Call translate(StoredProcedure sp) throws MetaMatrixComponentException {
         Procedure proc = null;
         if(sp.getProcedureID() != null) {
             try {
@@ -622,42 +591,50 @@
                 throw new MetaMatrixComponentException(e);
             }
         }
-
+        Class<?> returnType = null;
         List parameters = sp.getParameters();
-        List<IParameter> translatedParameters = new ArrayList<IParameter>();
+        List<Argument> translatedParameters = new ArrayList<Argument>();
         for (Iterator i = parameters.iterator(); i.hasNext();) {
-            translatedParameters.add(translate((SPParameter)i.next(), proc));
+        	SPParameter param = (SPParameter)i.next();
+        	Direction direction = Direction.IN;
+            switch(param.getParameterType()) {
+                case ParameterInfo.IN:    
+                    direction = Direction.IN;
+                    break;
+                case ParameterInfo.INOUT: 
+                    direction = Direction.INOUT;
+                    break;
+                case ParameterInfo.OUT: 
+                    direction = Direction.OUT;
+                    break;
+                case ParameterInfo.RESULT_SET: 
+                    continue; //already part of the metadata
+                case ParameterInfo.RETURN_VALUE: 
+                	returnType = param.getClassType();
+                	break;
+                    
+            }
+            
+            ProcedureParameter metadataParam = metadataFactory.getParameter(param);
+            //we can assume for now that all arguments will be literals, which may be multivalued
+            Literal value = (Literal)translate(param.getExpression());
+            Argument arg = new Argument(direction, value, param.getClassType(), metadataParam);
+            translatedParameters.add(arg);
         }
                         
-        return new ProcedureImpl(sp.getProcedureName(), translatedParameters, proc);
+        Call call = new Call(sp.getProcedureName(), translatedParameters, proc);
+        call.setReturnType(returnType);
+        return call;
     }
 
-    IParameter translate(SPParameter param, Procedure parent) {
-        Direction direction = Direction.IN;
-        switch(param.getParameterType()) {
-            case ParameterInfo.IN:    
-                direction = Direction.IN;
-                break;
-            case ParameterInfo.INOUT: 
-                direction = Direction.INOUT;
-                break;
-            case ParameterInfo.OUT: 
-                direction = Direction.OUT;
-                break;
-            case ParameterInfo.RESULT_SET: 
-                direction = Direction.RESULT_SET;
-                break;
-            case ParameterInfo.RETURN_VALUE: 
-                direction = Direction.RETURN;
-                break;
+    public NamedTable translate(GroupSymbol symbol) throws MetaMatrixComponentException {
+    	String alias = null;
+        String fullGroup = symbol.getOutputName();
+        if(symbol.getOutputDefinition() != null) {
+            alias = symbol.getOutputName();
+            fullGroup = symbol.getOutputDefinition();
         }
-        
-        Parameter metadataParam = metadataFactory.getParameter(param, parent);
-        return new ParameterImpl(param.getIndex(), direction, param.getValue(), param.getClassType(), metadataParam);                
-    }
-
-    public IGroup translate(GroupSymbol symbol) throws MetaMatrixComponentException {
-        GroupImpl group = new GroupImpl(symbol.getOutputName(), symbol.getOutputDefinition(), null);
+        NamedTable group = new NamedTable(fullGroup, alias, null);
 		if (symbol.getMetadataID() instanceof TempMetadataID) {
 			return group;
 		}
@@ -671,26 +648,26 @@
     }
     
     /* Batched Updates */
-    IBatchedUpdates translate(BatchedUpdateCommand command) throws MetaMatrixComponentException {
+    BatchedUpdates translate(BatchedUpdateCommand command) throws MetaMatrixComponentException {
         List updates = command.getUpdateCommands();
-        List translatedUpdates = new ArrayList(updates.size());
+        List<org.teiid.connector.language.Command> translatedUpdates = new ArrayList<org.teiid.connector.language.Command>(updates.size());
         for (Iterator i = updates.iterator(); i.hasNext();) {
             translatedUpdates.add(translate((Command)i.next()));
         }
-        return new BatchedUpdatesImpl(translatedUpdates);
+        return new BatchedUpdates(translatedUpdates);
     }
 
-    ILimit translate(Limit limit) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Limit translate(Limit limit) throws MetaMatrixComponentException {
         if (limit == null) {
             return null;
         }
         int rowOffset = 0;
         if (limit.getOffset() != null) {
-            ILiteral c1 = (ILiteral)translate(limit.getOffset());
+            Literal c1 = (Literal)translate(limit.getOffset());
             rowOffset = ((Integer)c1.getValue()).intValue();
         }
-        ILiteral c2 = (ILiteral)translate(limit.getRowLimit());
+        Literal c2 = (Literal)translate(limit.getRowLimit());
         int rowLimit = ((Integer)c2.getValue()).intValue();
-        return new LimitImpl(rowOffset, rowLimit);
+        return new org.teiid.connector.language.Limit(rowOffset, rowLimit);
     }
 }

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,346 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICompoundCriteria;
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IFromItem;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.language.IInsertValueSource;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.IJoin;
-import org.teiid.connector.language.ILanguageFactory;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Group;
-import org.teiid.connector.metadata.runtime.Parameter;
-import org.teiid.connector.metadata.runtime.Procedure;
-
-
-/**
- */
-public class LanguageFactoryImpl implements ILanguageFactory {
-
-    /**
-     * Public instance, holds no state so can be shared by everyone.
-     */
-    public static final LanguageFactoryImpl INSTANCE = new LanguageFactoryImpl();
-
-
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createAggregate(java.lang.String, boolean, com.metamatrix.data.language.IExpression, java.lang.Class)
-     */
-    public IAggregate createAggregate(String name, boolean isDistinct, IExpression expression, Class type) {
-        return new AggregateImpl(name, isDistinct, expression, type);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createCompareCriteria(int, com.metamatrix.data.language.IExpression, com.metamatrix.data.language.IExpression)
-     */
-    public ICompareCriteria createCompareCriteria(
-        ICompareCriteria.Operator operator,
-        IExpression leftExpression,
-        IExpression rightExpression) {
-        return new CompareCriteriaImpl(leftExpression, rightExpression, operator);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createCompoundCriteria(int, java.util.List)
-     */
-    public ICompoundCriteria createCompoundCriteria(ICompoundCriteria.Operator operator, List innerCriteria) {
-        return new CompoundCriteriaImpl(innerCriteria, operator);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createDelete(com.metamatrix.data.language.IGroup, com.metamatrix.data.language.ICriteria)
-     */
-    public IDelete createDelete(IGroup group, ICriteria criteria) {
-        return new DeleteImpl(group, criteria);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createElement(java.lang.String, com.metamatrix.data.language.IGroup, com.metamatrix.data.metadata.runtime.MetadataID)
-     */
-    public IElement createElement(String name, IGroup group, Element metadataReference, Class type) {
-        return new ElementImpl(group, name, metadataReference, type);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createExistsCriteria(com.metamatrix.data.language.IQuery)
-     */
-    public IExistsCriteria createExistsCriteria(IQuery query) {
-        return new ExistsCriteriaImpl(query);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createFrom(java.util.List)
-     */
-    public IFrom createFrom(List items) {
-        return new FromImpl(items);
-    }
-    
-    @Override
-    public IFunction createFunction(String functionName, IExpression[] args,
-    		Class<?> type) {
-    	return new FunctionImpl(functionName, Arrays.asList(args), type);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createFunction(java.lang.String, com.metamatrix.data.language.IExpression[], java.lang.Class)
-     */
-    @Override
-    public IFunction createFunction(String functionName, List<? extends IExpression> args, Class<?> type) {
-        return new FunctionImpl(functionName, args, type);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createGroup(java.lang.String, java.lang.String, com.metamatrix.data.metadata.runtime.MetadataID)
-     */
-    public IGroup createGroup(String context, String definition, Group metadataReference) {
-        return new GroupImpl(context, definition, metadataReference);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createGroupBy(java.util.List)
-     */
-    public IGroupBy createGroupBy(List items) {
-        return new GroupByImpl(items);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createInCriteria(com.metamatrix.data.language.IExpression, java.util.List, boolean)
-     */
-    public IInCriteria createInCriteria(IExpression leftExpression, List rightExpressions, boolean isNegated) {
-        return new InCriteriaImpl(leftExpression, rightExpressions, isNegated);
-    }
-    
-    @Override
-    public IInsert createInsert(IGroup group, List<IElement> columns,
-    		IInsertValueSource valueSource) {
-        return new InsertImpl(group, columns, valueSource);
-    }
-    
-    @Override
-    public IInsertExpressionValueSource createInsertExpressionValueSource(
-    		List<IExpression> values) {
-    	return new InsertValueExpressionsImpl(values);
-    }
-    
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createIsNullCriteria(com.metamatrix.data.language.IExpression, boolean)
-     */
-    public IIsNullCriteria createIsNullCriteria(IExpression expression, boolean isNegated) {
-        return new IsNullCriteriaImpl(expression, isNegated);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createJoin(int, com.metamatrix.data.language.IFromItem, com.metamatrix.data.language.IFromItem, java.util.List)
-     */
-    public IJoin createJoin(IJoin.JoinType joinType, IFromItem leftItem, IFromItem rightItem, List criteria) {
-        return new JoinImpl(leftItem, rightItem, joinType, criteria);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createLikeCriteria(com.metamatrix.data.language.IExpression, com.metamatrix.data.language.IExpression, java.lang.Character, boolean)
-     */
-    public ILikeCriteria createLikeCriteria(
-        IExpression leftExpression,
-        IExpression rightExpression,
-        Character escapeCharacter,
-        boolean isNegated) {
-        return new LikeCriteriaImpl(leftExpression, rightExpression, escapeCharacter, isNegated);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createLiteral(java.lang.Object, java.lang.Class)
-     */
-    public ILiteral createLiteral(Object value, Class type) {
-        return new LiteralImpl(value, type);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createNotCriteria(com.metamatrix.data.language.ICriteria)
-     */
-    public INotCriteria createNotCriteria(ICriteria criteria) {
-        return new NotCriteriaImpl(criteria);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createOrderBy(java.util.List)
-     */
-    public IOrderBy createOrderBy(List items) {
-        return new OrderByImpl(items);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createOrderByItem(java.lang.String, com.metamatrix.data.language.IElement, boolean)
-     */
-    public IOrderByItem createOrderByItem(String name, IElement element, boolean direction) {
-        return new OrderByItemImpl(name, direction, element);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createParameter(int, int, java.lang.Object, java.lang.Class)
-     */
-    public IParameter createParameter(int index, IParameter.Direction direction, Object value, Class type, Parameter metadataReference) {
-        return new ParameterImpl(index, direction, value, type, metadataReference);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createProcedure(java.lang.String, java.util.List, com.metamatrix.data.metadata.runtime.MetadataID)
-     */
-    public IProcedure createProcedure(String name, List parameters, Procedure metadataReference) {
-        return new ProcedureImpl(name, parameters, metadataReference);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createQuery(com.metamatrix.data.language.ISelect, com.metamatrix.data.language.IFrom, com.metamatrix.data.language.ICriteria, com.metamatrix.data.language.IGroupBy, com.metamatrix.data.language.ICriteria, com.metamatrix.data.language.IOrderBy)
-     */
-    public IQuery createQuery(
-        ISelect select,
-        IFrom from,
-        ICriteria where,
-        IGroupBy groupBy,
-        ICriteria having,
-        IOrderBy orderBy) {
-        return new QueryImpl(select, from, where, groupBy, having, orderBy);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createScalarSubquery(com.metamatrix.data.language.IQuery)
-     */
-    public IScalarSubquery createScalarSubquery(IQuery query) {
-        return new ScalarSubqueryImpl(query);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createSearchedCaseExpression(java.util.List, java.util.List, com.metamatrix.data.language.IExpression, java.lang.Class)
-     */
-    public ISearchedCaseExpression createSearchedCaseExpression(
-        List whenExpressions,
-        List thenExpressions,
-        IExpression elseExpression,
-        Class type) {
-        return new SearchedCaseExpressionImpl(whenExpressions, thenExpressions, elseExpression, type);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createSelect(boolean, java.util.List)
-     */
-    public ISelect createSelect(boolean isDistinct, List selectSymbols) {
-        return new SelectImpl(selectSymbols, isDistinct);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createSelectSymbol(java.lang.String, com.metamatrix.data.language.IExpression)
-     */
-    public ISelectSymbol createSelectSymbol(String name, IExpression expression) {
-        return new SelectSymbolImpl(name, expression);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createSubqueryCompareCriteria(com.metamatrix.data.language.IExpression, int, int, com.metamatrix.data.language.IQuery)
-     */
-    public ISubqueryCompareCriteria createSubqueryCompareCriteria(
-        IExpression leftExpression,
-        ICompareCriteria.Operator operator,
-        ISubqueryCompareCriteria.Quantifier quantifier,
-        IQuery subquery) {
-        return new SubqueryCompareCriteriaImpl(leftExpression, operator, quantifier, subquery);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createSubqueryInCriteria(com.metamatrix.data.language.IExpression, com.metamatrix.data.language.IQuery, boolean)
-     */
-    public ISubqueryInCriteria createSubqueryInCriteria(IExpression expression, IQuery subquery, boolean isNegated) {
-        return new SubqueryInCriteriaImpl(expression, isNegated, subquery);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageFactory#createUpdate(com.metamatrix.data.language.IGroup, java.util.List, com.metamatrix.data.language.ICriteria)
-     */
-    public IUpdate createUpdate(IGroup group, ISetClauseList updates, ICriteria criteria) {
-        return new UpdateImpl(group, updates, criteria);
-    }
-
-    public IInlineView createInlineView(IQueryCommand query, String name) {
-        return new InlineViewImpl(query, name);
-    }
-
-    public ISetQuery createSetOp(ISetQuery.Operation operation, boolean all, IQueryCommand leftQuery, IQueryCommand rightQuery, IOrderBy orderBy, ILimit limit) {
-        SetQueryImpl queryImpl = new SetQueryImpl();
-        queryImpl.setOperation(operation);
-        queryImpl.setAll(all);
-        queryImpl.setLeftQuery(leftQuery);
-        queryImpl.setRightQuery(rightQuery);
-        queryImpl.setOrderBy(orderBy);
-        queryImpl.setLimit(limit);
-        return queryImpl;
-    }
-
-	@Override
-	public ISetClause createSetClause(IElement symbol, IExpression value) {
-		return new SetClauseImpl(symbol, value);
-	}
-
-	@Override
-	public ISetClauseList createSetClauseList(List<ISetClause> clauses) {
-		return new SetClauseListImpl(clauses);
-	}
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class LikeCriteriaImpl extends BaseLanguageObject implements ILikeCriteria {
-        
-    private IExpression leftExpression = null;
-    private IExpression rightExpression = null;
-    private Character escapeCharacter = null;
-    private boolean isNegated = false;
-    
-    public LikeCriteriaImpl(IExpression left, IExpression right, Character escapeCharacter, boolean negated) {
-        leftExpression = left;
-        rightExpression = right;
-        this.escapeCharacter = escapeCharacter;
-        this.isNegated = negated;
-        
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILikeCriteria#getLeftExpression()
-     */
-    public IExpression getLeftExpression() {
-        return leftExpression;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILikeCriteria#getRightExpression()
-     */
-    public IExpression getRightExpression() {
-        return rightExpression;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILikeCriteria#getEscapeCharacter()
-     */
-    public Character getEscapeCharacter() {
-        return this.escapeCharacter;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILikeCriteria#isNegated()
-     */
-    public boolean isNegated() {
-        return this.isNegated;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILikeCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setLeftExpression(IExpression expression) {
-        this.leftExpression = expression;        
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILikeCriteria#setRightExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setRightExpression(IExpression expression) {
-        this.rightExpression = expression;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILikeCriteria#setEscapeCharacter(java.lang.Character)
-     */
-    public void setEscapeCharacter(Character character) {
-        this.escapeCharacter = character;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILikeCriteria#setNegated(boolean)
-     */
-    public void setNegated(boolean negated) {
-        this.isNegated = negated;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-/** 
- * @since 4.3
- */
-public class LimitImpl extends BaseLanguageObject implements ILimit {
-
-    private int rowOffset;
-    private int rowLimit;
-    
-    public LimitImpl(int offset, int rowLimit) {
-        this.rowOffset = offset;
-        this.rowLimit = rowLimit;
-    }
-    /** 
-     * @see org.teiid.connector.language.ILimit#getRowLimit()
-     * @since 4.3
-     */
-    public int getRowLimit() {
-        return rowLimit;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ILimit#getRowOffset()
-     * @since 4.3
-     */
-    public int getRowOffset() {
-        return rowOffset;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(org.teiid.connector.visitor.framework.LanguageObjectVisitor)
-     * @since 4.3
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class LiteralImpl extends BaseLanguageObject implements ILiteral {
-    
-    private Object value;
-    private Class<?> type;
-    private boolean bindValue;
-    private boolean multiValued;
-    
-    public LiteralImpl(Object value, Class<?> type) {
-        this.value = value;
-        this.type = type;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.ILiteral#getValue()
-     */
-    public Object getValue() {
-        return this.value;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILiteral#getType()
-     */
-    public Class<?> getType() {
-        return this.type;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILiteral#setValue(java.lang.Object)
-     */
-    public void setValue(Object value) {
-        this.value = value;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ILiteral#isBindValue()
-     */
-    public boolean isBindValue() {
-        return bindValue;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ILiteral#setBindValue(boolean)
-     */
-    public void setBindValue(boolean bindValue) {
-        this.bindValue = bindValue;
-    }
-
-	@Override
-	public boolean isMultiValued() {
-		return multiValued;
-	}
-
-	@Override
-	public void setMultiValued(boolean multiValued) {
-		this.multiValued = multiValued;
-	}
-
-	@Override
-	public void setType(Class<?> type) {
-		this.type = type;
-	}
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.INotCriteria;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class NotCriteriaImpl extends BaseLanguageObject implements INotCriteria {
-
-    private ICriteria criteria = null;
-    
-    public NotCriteriaImpl(ICriteria criteria) {
-        this.criteria = criteria;
-    }
-    /**
-     * @see org.teiid.connector.language.INotCriteria#getCriteria()
-     */
-    public ICriteria getCriteria() {
-        return criteria;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-    /* 
-     * @see com.metamatrix.data.language.INotCriteria#setCriteria(com.metamatrix.data.language.ICriteria)
-     */
-    public void setCriteria(ICriteria criteria) {
-        this.criteria = criteria;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class OrderByImpl extends BaseLanguageObject implements IOrderBy {
-
-    private List items = null;
-    
-    public OrderByImpl(List items) {
-        this.items = items;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.IOrderBy#getItems()
-     */
-    public List getItems() {
-        return items;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IOrderBy#setItems(java.util.List)
-     */
-    public void setItems(List items) {
-        this.items = items;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class OrderByItemImpl extends BaseLanguageObject implements IOrderByItem {
-    
-    private String name;
-    private boolean direction = false;
-    private IElement element;       // optional, may be null
-    
-    public OrderByItemImpl(String name, boolean direction, IElement element) {
-        this.name = name;
-        this.direction = direction;
-        this.element = element;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IOrderByItem#getName()
-     */
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IOrderByItem#getDirection()
-     */
-    public boolean getDirection() {
-        return direction;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IOrderByItem#setName(java.lang.String)
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IOrderByItem#setDirection(boolean)
-     */
-    public void setDirection(boolean direction) {
-        this.direction = direction;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IOrderByElementItem#getElement()
-     */
-    public IElement getElement() {
-        return this.element;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IOrderByElementItem#setElement(com.metamatrix.data.language.IElement)
-     */
-    public void setElement(IElement element) {
-        this.element = element;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.metadata.runtime.Parameter;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class ParameterImpl extends BaseLanguageObject implements IParameter {
-
-    private int index;
-    private Direction direction;
-    private Object value;
-    private boolean valueSpecified;
-    private Class type;
-    private Parameter metadataObject;
-    
-    public ParameterImpl(int index, Direction direction, Object value, Class type, Parameter metadataObject) {
-        setIndex(index);
-        setDirection(direction);
-        setValue(value);
-        setType(type);
-        this.metadataObject = metadataObject;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.IParameter#getIndex()
-     */
-    public int getIndex() {
-        return this.index;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IParameter#getDirection()
-     */
-    public Direction getDirection() {
-        return this.direction;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IParameter#getType()
-     */
-    public Class getType() {
-        return this.type;
-    }
-
-    /*
-     * @see com.metamatrix.data.language.IParameter#getValue()
-     */
-    public Object getValue() {
-        return this.value;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IParameter#setIndex(int)
-     */
-    public void setIndex(int index) {
-        this.index = index;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IParameter#setDirection(int)
-     */
-    public void setDirection(Direction direction) {
-        this.direction = direction;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IParameter#setType(java.lang.Class)
-     */
-    public void setType(Class type) {
-        this.type = type;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IParameter#setValue(java.lang.Object)
-     */
-    public void setValue(Object value) {
-        this.value = value;
-        if(value != null) {
-            setValueSpecified(true);
-        }
-    }
-
-    @Override
-    public Parameter getMetadataObject() {
-    	return this.metadataObject;
-    }
-
-    public void setMetadataObject(Parameter metadataObject) {
-		this.metadataObject = metadataObject;
-	}
-    
-    /** 
-     * @see org.teiid.connector.language.IParameter#getValueSpecified()
-     * @since 4.3.2
-     */
-    public boolean getValueSpecified() {
-        return this.valueSpecified;
-    }
-    
-    /** 
-     * @see org.teiid.connector.language.IParameter#setValueSpecified(boolean)
-     * @since 4.3.2
-     */
-    public void setValueSpecified(boolean specified) {
-        this.valueSpecified = specified;
-    }
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,121 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.language.IParameter;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.language.IParameter.Direction;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class ProcedureImpl extends BaseLanguageObject implements IProcedure {
-
-    private String name;
-    private List<IParameter> parameters;
-    private Procedure metadataObject;
-    
-    public ProcedureImpl(String name, List<IParameter> parameters, Procedure metadataObject) {
-        this.name = name;
-        this.parameters = parameters;
-        this.metadataObject = metadataObject;
-    }
-    
-    /**
-     * @see com.metamatrix.data.language.IExecute#getProcedureName()
-     */
-    public String getProcedureName() {
-        return this.name;
-    }
-
-    /**
-     * @see com.metamatrix.data.language.IExecute#getVariableValues()
-     */
-    public List<IParameter> getParameters() {
-        return parameters;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExecute#setProcedureName(java.lang.String)
-     */
-    public void setProcedureName(String name) {
-        this.name = name;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExecute#setParameters(java.util.List)
-     */
-    public void setParameters(List<IParameter> parameters) {
-        this.parameters = parameters;
-    }
-
-    @Override
-    public Procedure getMetadataObject() {
-    	return this.metadataObject;
-    }
-
-    public void setMetadataObject(Procedure metadataID) {
-        this.metadataObject = metadataID;
-    }
-    
-    public boolean equals(Object obj) {
-        if(obj == this) {
-            return true;
-        }
-        
-        if(obj == null) {
-            return false;
-        }
-        
-        IProcedure proc = (IProcedure) obj;
-        return getProcedureName().equalsIgnoreCase(proc.getProcedureName());
-    }
-    
-    public Class<?>[] getResultSetColumnTypes() throws ConnectorException {
-        for (IParameter param : parameters) {
-            if(param.getDirection() == Direction.RESULT_SET){
-                List<Element> columnMetadata = param.getMetadataObject().getChildren();
-
-                int size = columnMetadata.size();
-                Class<?>[] coulmnDTs = new Class[size];
-                for(int i =0; i<size; i++ ){
-                    coulmnDTs[i] = columnMetadata.get(i).getJavaType();
-                }
-                return coulmnDTs;
-            }
-        }
-        return new Class[0];
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.connector.language.ILimit;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.ISelectSymbol;
-
-
-public abstract class QueryCommandImpl extends BaseLanguageObject implements org.teiid.connector.language.IQueryCommand {
-
-    private IOrderBy orderBy = null;
-    private ILimit limit = null;
-
-    /**
-     * @see org.teiid.connector.language.IQuery#getOrderBy()
-     */
-    public IOrderBy getOrderBy() {
-        return orderBy;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IQuery#getLimit()
-     */
-    public ILimit getLimit() {
-        return limit;
-    }
-    
-    public String[] getColumnNames() {
-        List selectSymbols = getProjectedQuery().getSelect().getSelectSymbols();
-        String[] columnNames = new String[selectSymbols.size()];
-        int symbolIndex = 0;
-        for (Iterator i = selectSymbols.iterator(); i.hasNext(); symbolIndex++) {
-            columnNames[symbolIndex] = ((ISelectSymbol)i.next()).getOutputName();
-        }
-        return columnNames;
-    }
-    
-    public Class[] getColumnTypes() {
-        List selectSymbols = getProjectedQuery().getSelect().getSelectSymbols();
-        Class[] columnTypes = new Class[selectSymbols.size()];
-        int symbolIndex = 0;
-        for (Iterator i = selectSymbols.iterator(); i.hasNext(); symbolIndex++) {
-            ISelectSymbol symbol = (ISelectSymbol)i.next();
-            if (symbol.getExpression() == null) {
-                columnTypes[symbolIndex] = null;
-            } else {
-                columnTypes[symbolIndex] = symbol.getExpression().getType();
-            }
-        }
-        return columnTypes;
-    }
-    
-    /* 
-     * @see com.metamatrix.data.language.IQuery#setOrderBy(com.metamatrix.data.language.IOrderBy)
-     */
-    public void setOrderBy(IOrderBy orderBy) {
-        this.orderBy = orderBy;
-    }
-    
-    /* 
-     * @see com.metamatrix.data.language.IQuery#setOrderBy(com.metamatrix.data.language.IOrderBy)
-     */
-    public void setLimit(ILimit limit) {
-        this.limit = limit;
-    }
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,158 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IFrom;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IOrderBy;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class QueryImpl extends QueryCommandImpl implements IQuery {
-
-    private ISelect select = null;
-    private IFrom from = null;
-    private ICriteria where = null;
-    private IGroupBy groupBy = null;
-    private ICriteria having = null;
-    
-    public QueryImpl(ISelect select, IFrom from, ICriteria where,
-                     IGroupBy groupBy, ICriteria having, IOrderBy orderBy) {
-        this.select = select;
-        this.from = from;
-        this.where = where;
-        this.groupBy = groupBy;
-        this.having = having;
-        this.setOrderBy(orderBy);
-    }
-    /**
-     * @see org.teiid.connector.language.IQuery#getSelect()
-     */
-    public ISelect getSelect() {
-        return select;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IQuery#getFrom()
-     */
-    public IFrom getFrom() {
-        return from;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IQuery#getWhere()
-     */
-    public ICriteria getWhere() {
-        return where;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IQuery#getGroupBy()
-     */
-    public IGroupBy getGroupBy() {
-        return groupBy;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IQuery#getHaving()
-     */
-    public ICriteria getHaving() {
-        return having;
-    }
-
-    public String[] getColumnNames() {
-        List selectSymbols = getSelect().getSelectSymbols();
-        String[] columnNames = new String[selectSymbols.size()];
-        int symbolIndex = 0;
-        for (Iterator i = selectSymbols.iterator(); i.hasNext(); symbolIndex++) {
-            columnNames[symbolIndex] = ((ISelectSymbol)i.next()).getOutputName();
-        }
-        return columnNames;
-    }
-    
-    public Class[] getColumnTypes() {
-        List selectSymbols = getSelect().getSelectSymbols();
-        Class[] columnTypes = new Class[selectSymbols.size()];
-        int symbolIndex = 0;
-        for (Iterator i = selectSymbols.iterator(); i.hasNext(); symbolIndex++) {
-            ISelectSymbol symbol = (ISelectSymbol)i.next();
-            if (symbol.getExpression() == null) {
-                columnTypes[symbolIndex] = null;
-            } else {
-                columnTypes[symbolIndex] = symbol.getExpression().getType();
-            }
-        }
-        return columnTypes;
-    }
-    
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-    /* 
-     * @see com.metamatrix.data.language.IQuery#setSelect(com.metamatrix.data.language.ISelect)
-     */
-    public void setSelect(ISelect select) {
-        this.select = select;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IQuery#setFrom(com.metamatrix.data.language.IFrom)
-     */
-    public void setFrom(IFrom from) {
-        this.from = from;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IQuery#setWhere(com.metamatrix.data.language.ICriteria)
-     */
-    public void setWhere(ICriteria criteria) {
-        this.where = criteria;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IQuery#setGroupBy(com.metamatrix.data.language.IGroupBy)
-     */
-    public void setGroupBy(IGroupBy groupBy) {
-        this.groupBy = groupBy;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IQuery#setHaving(com.metamatrix.data.language.ICriteria)
-     */
-    public void setHaving(ICriteria criteria) {
-        this.having = criteria;
-    }
-    
-    /** 
-     * @see org.teiid.dqp.internal.datamgr.language.QueryCommandImpl#getProjectedQuery()
-     */
-    public IQuery getProjectedQuery() {
-        return this;
-    }
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- */
-public class ScalarSubqueryImpl extends BaseLanguageObject implements IScalarSubquery {
-
-    private IQueryCommand query;
-    private Class type;
-
-    /**
-     * 
-     */
-    public ScalarSubqueryImpl(IQueryCommand query) {
-        setQuery(query);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExpression#getType()
-     */
-    public Class getType() {
-        return this.type;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryContainer#getQuery()
-     */
-    public IQueryCommand getQuery() {
-        return this.query;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
-     */
-    public void setType(Class type) {
-        this.type = type;        
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryContainer#setQuery(com.metamatrix.data.language.IQuery)
-     */
-    public void setQuery(IQueryCommand query) {
-        this.query = query;
-        this.type = query.getColumnTypes()[0];
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class SearchedCaseExpressionImpl extends BaseLanguageObject implements ISearchedCaseExpression {
-
-    private List whenExpressions;
-    private List thenExpressions;
-    private IExpression elseExpression;
-    private Class type;
-    
-    public SearchedCaseExpressionImpl(List whens, List thens, IExpression elseExpression, Class type) {
-        this.whenExpressions = whens;
-        this.thenExpressions = thens;
-        this.elseExpression = elseExpression;
-        this.type = type;
-    }
-    /**
-     * @see org.teiid.connector.language.ISearchedCaseExpression#getElseExpression()
-     */
-    public IExpression getElseExpression() {
-        return elseExpression;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ISearchedCaseExpression#getThenExpression(int)
-     */
-    public IExpression getThenExpression(int index) {
-        return (IExpression)thenExpressions.get(index);
-    }
-
-    /**
-     * @see org.teiid.connector.language.ISearchedCaseExpression#getWhenCount()
-     */
-    public int getWhenCount() {
-        return whenExpressions.size();
-    }
-
-    /**
-     * @see org.teiid.connector.language.ISearchedCaseExpression#getWhenCriteria(int)
-     */
-    public ICriteria getWhenCriteria(int index) {
-        return (ICriteria)whenExpressions.get(index);
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-    /* 
-     * @see com.metamatrix.data.language.ISearchedCaseExpression#setWhenCriteria(int, com.metamatrix.data.language.ICriteria)
-     */
-    public void setWhenCriteria(int index, ICriteria criteria) {
-        this.whenExpressions.set(index, criteria);
-    }
-    /* 
-     * @see com.metamatrix.data.language.ISearchedCaseExpression#setThenExpression(int, com.metamatrix.data.language.IExpression)
-     */
-    public void setThenExpression(int index, IExpression expression) {
-        this.thenExpressions.set(index, expression);
-    }
-    /* 
-     * @see com.metamatrix.data.language.ISearchedCaseExpression#setElseExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setElseExpression(IExpression expression) {
-        this.elseExpression = expression;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IExpression#getType()
-     */
-    public Class getType() {
-        return this.type;
-    }
-    /* 
-     * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
-     */
-    public void setType(Class type) {
-        this.type = type;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import org.teiid.connector.language.ISelect;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class SelectImpl extends BaseLanguageObject implements ISelect {
-    
-    private List selectSymbols = null;
-    private boolean isDistinct = false;
-    
-    public SelectImpl(List symbols, boolean distinct) {
-        selectSymbols = symbols;
-        this.isDistinct = distinct;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ISelect#getSelectSymbols()
-     */
-    public List getSelectSymbols() {
-        return selectSymbols;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ISelect#isDistinct()
-     */
-    public boolean isDistinct() {
-        return this.isDistinct;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISelect#setSelectSymbols(java.util.List)
-     */
-    public void setSelectSymbols(List symbols) {
-        this.selectSymbols = symbols;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISelect#setDistinct(boolean)
-     */
-    public void setDistinct(boolean distinct) {
-        this.isDistinct = distinct;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class SelectSymbolImpl extends BaseLanguageObject implements ISelectSymbol {
-
-    private boolean hasAlias;
-    private String name;
-    private IExpression expression = null;
-    
-    public SelectSymbolImpl(String name, IExpression expression) {
-        this.name = name;
-        this.expression = expression;
-    }
-    /**
-     * @see org.teiid.connector.language.ISelectSymbol#hasAlias()
-     */
-    public boolean hasAlias() {
-        return hasAlias;
-    }
-
-    public void setAlias(boolean alias){
-        this.hasAlias = alias;    
-    }
-    
-    /**
-     * @see org.teiid.connector.language.ISelectSymbol#getOutputName()
-     */
-    public String getOutputName() {
-        return name;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ISelectSymbol#getExpression()
-     */
-    public IExpression getExpression() {
-        return expression;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISelectSymbol#setOutputName(java.lang.String)
-     */
-    public void setOutputName(String name) {
-        this.name = name;
-    }
-    
-    /* 
-     * @see com.metamatrix.data.language.ISelectSymbol#setExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setExpression(IExpression expression) {
-        this.expression = expression;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class SetClauseImpl extends BaseLanguageObject implements ISetClause {
-
-	private IElement symbol;
-	private IExpression value;
-	
-	public SetClauseImpl(IElement symbol, IExpression value) {
-		this.symbol = symbol;
-		this.value = value;
-	}
-
-	@Override
-	public IElement getSymbol() {
-		return symbol;
-	}
-
-	@Override
-	public IExpression getValue() {
-		return value;
-	}
-
-	@Override
-	public void setSymbol(IElement symbol) {
-		this.symbol = symbol;
-	}
-
-	@Override
-	public void setValue(IExpression value) {
-		this.value = value;
-	}
-
-	@Override
-	public void acceptVisitor(LanguageObjectVisitor visitor) {
-		visitor.visit(this);
-	}
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class SetClauseListImpl extends BaseLanguageObject implements ISetClauseList {
-
-	private List<ISetClause> clauses;
-	
-	public SetClauseListImpl(List<ISetClause> clauses) {
-		if (clauses == null) {
-			clauses = new ArrayList<ISetClause>();
-		}
-		this.clauses = clauses;
-	}
-
-	@Override
-	public List<ISetClause> getClauses() {
-		return clauses;
-	}
-
-	@Override
-	public void acceptVisitor(LanguageObjectVisitor visitor) {
-		visitor.visit(this);
-	}
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class SetQueryImpl extends QueryCommandImpl implements org.teiid.connector.language.ISetQuery {
-
-    private boolean all;
-    private IQueryCommand leftQuery;
-    private IQueryCommand rightQuery;
-    private Operation operation;
-    
-    /** 
-     * @see org.teiid.dqp.internal.datamgr.language.QueryCommandImpl#getProjectedQuery()
-     */
-    public IQuery getProjectedQuery() {
-        if (leftQuery instanceof IQuery) {
-            return (IQuery)leftQuery;
-        }
-        return leftQuery.getProjectedQuery();
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ISetQuery#getLeftQuery()
-     */
-    public IQueryCommand getLeftQuery() {
-        return leftQuery;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ISetQuery#getOperation()
-     */
-    public Operation getOperation() {
-        return operation;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ISetQuery#getRightQuery()
-     */
-    public IQueryCommand getRightQuery() {
-        return rightQuery;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ISetQuery#isAll()
-     */
-    public boolean isAll() {
-        return all;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ISetQuery#setAll(boolean)
-     */
-    public void setAll(boolean all) {
-        this.all = all;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ISetQuery#setLeftQuery(org.teiid.connector.language.IQueryCommand)
-     */
-    public void setLeftQuery(IQueryCommand leftQuery) {
-        this.leftQuery = leftQuery;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ISetQuery#setOperation(org.teiid.connector.language.ISetQuery.Operation)
-     */
-    public void setOperation(Operation operation) {
-        this.operation = operation;
-    }
-
-    /** 
-     * @see org.teiid.connector.language.ISetQuery#setRightQuery(org.teiid.connector.language.IQueryCommand)
-     */
-    public void setRightQuery(IQueryCommand rightQuery) {
-        this.rightQuery = rightQuery;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.*;
-import org.teiid.connector.language.ICompareCriteria.Operator;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- */
-public class SubqueryCompareCriteriaImpl extends BaseLanguageObject implements ISubqueryCompareCriteria {
-
-    private IExpression leftExpr;
-    private Operator operator;
-    private Quantifier quantifier;
-    private IQueryCommand query;
-    
-    /**
-     * 
-     */
-    public SubqueryCompareCriteriaImpl(IExpression leftExpr, Operator operator, Quantifier quantifier, IQueryCommand query) {
-        this.leftExpr = leftExpr;
-        this.operator = operator;
-        this.quantifier = quantifier;
-        this.query = query;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryCompareCriteria#getLeftExpression()
-     */
-    public IExpression getLeftExpression() {
-        return this.leftExpr;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryCompareCriteria#getOperator()
-     */
-    public Operator getOperator() {
-        return this.operator;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryCompareCriteria#getQuantifier()
-     */
-    public Quantifier getQuantifier() {
-        return this.quantifier;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryContainer#getQuery()
-     */
-    public IQueryCommand getQuery() {
-        return this.query;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryCompareCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setLeftExpression(IExpression expression) {
-        this.leftExpr = expression;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryCompareCriteria#setOperator(int)
-     */
-    public void setOperator(Operator operator) {
-        this.operator = operator;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryCompareCriteria#setQuantifier(int)
-     */
-    public void setQuantifier(Quantifier quantifier) {
-        this.quantifier = quantifier;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryContainer#setQuery(com.metamatrix.data.language.IQuery)
-     */
-    public void setQuery(IQueryCommand query) {
-        this.query = query;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,94 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.*;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- */
-public class SubqueryInCriteriaImpl extends BaseLanguageObject implements ISubqueryInCriteria {
-
-    private IExpression leftExpr;
-    private boolean isNegated = false;
-    private IQueryCommand rightQuery;
-
-    /**
-     * 
-     */
-    public SubqueryInCriteriaImpl(IExpression leftExpr, boolean isNegated, IQueryCommand rightQuery) {
-        this.leftExpr = leftExpr;
-        this.isNegated = isNegated;
-        this.rightQuery = rightQuery;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IBaseInCriteria#getLeftExpression()
-     */
-    public IExpression getLeftExpression() {
-        return this.leftExpr;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IBaseInCriteria#isNegated()
-     */
-    public boolean isNegated() {
-        return this.isNegated;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryContainer#getQuery()
-     */
-    public IQueryCommand getQuery() {
-        return this.rightQuery;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IBaseInCriteria#setLeftExpression(com.metamatrix.data.language.IExpression)
-     */
-    public void setLeftExpression(IExpression expression) {
-        this.leftExpr = expression;        
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IBaseInCriteria#setNegated(boolean)
-     */
-    public void setNegated(boolean negated) {
-        this.isNegated = negated;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.ISubqueryContainer#setQuery(com.metamatrix.data.language.IQuery)
-     */
-    public void setQuery(IQueryCommand query) {
-        this.rightQuery = query;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.ISetClauseList;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class UpdateImpl extends BaseLanguageObject implements IUpdate {
-    
-    private IGroup group;
-    private ISetClauseList changes;
-    private ICriteria criteria;
-    
-    public UpdateImpl(IGroup group, ISetClauseList changes, ICriteria criteria) {
-        this.group = group;
-        this.changes = changes;
-        this.criteria = criteria;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IUpdate#getGroup()
-     */
-    public IGroup getGroup() {
-        return group;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IUpdate#getChanges()
-     */
-    public ISetClauseList getChanges() {
-        return changes;
-    }
-
-    /**
-     * @see org.teiid.connector.language.IUpdate#getCriteria()
-     */
-    public ICriteria getCriteria() {
-        return criteria;
-    }
-
-    /**
-     * @see org.teiid.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
-     */
-    public void acceptVisitor(LanguageObjectVisitor visitor) {
-        visitor.visit(this);
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IUpdate#setGroup(com.metamatrix.data.language.IGroup)
-     */
-    public void setGroup(IGroup group) {
-        this.group = group;
-    }
-
-    public void setChanges(ISetClauseList changes) {
-        this.changes = changes;
-    }
-
-    /* 
-     * @see com.metamatrix.data.language.IUpdate#setCriteria(com.metamatrix.data.language.ICriteria)
-     */
-    public void setCriteria(ICriteria criteria) {
-        this.criteria = criteria;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,159 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.dqp.internal.datamgr.metadata;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Group;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.metadata.SupportConstants;
-
-/**
- */
-public class ElementImpl extends TypeModelImpl implements Element {
-    
-    ElementImpl(Object actualID, RuntimeMetadataImpl factory){
-        super(actualID, factory);
-    }
-    
-    public Class getJavaType() throws ConnectorException {
-        try {
-            String elementType = getMetadata().getElementType(getActualID());
-            return DataTypeManager.getDataTypeClass(elementType);
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-    
-    public int getPosition() throws ConnectorException {
-        try {
-            return getMetadata().getPosition(getActualID()) - 1;
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public Object getMaximumValue() throws ConnectorException {
-        try {
-            return getMetadata().getMaximumValue(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public Object getMinimumValue() throws ConnectorException {
-        try {
-            return getMetadata().getMinimumValue(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public int getSearchability() throws ConnectorException {
-        try {
-            boolean comparable = getMetadata().elementSupports(getActualID(), SupportConstants.Element.SEARCHABLE_COMPARE);
-            boolean likable = getMetadata().elementSupports(getActualID(), SupportConstants.Element.SEARCHABLE_LIKE);
-            if(comparable) {
-                if(likable) {
-                    return Element.SEARCHABLE;
-                }
-                return Element.SEARCHABLE_COMPARE;
-            }
-            if(likable) {
-                return Element.SEARCHABLE_LIKE;
-            }
-            return Element.NOT_SEARCHABLE;                    
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public boolean isAutoIncremented() throws ConnectorException {
-        try {
-            return getMetadata().elementSupports(getActualID(), SupportConstants.Element.AUTO_INCREMENT);
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public boolean isCaseSensitive() throws ConnectorException {
-        try {
-            return getMetadata().elementSupports(getActualID(), SupportConstants.Element.CASE_SENSITIVE);
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public String getNativeType() throws ConnectorException {
-        try {
-            return getMetadata().getNativeType(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-	@Override
-	public String getFormat() throws ConnectorException {
-        try {
-            return getMetadata().getFormat(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-	}
-
-	@Override
-	public Group getParent() throws ConnectorException {
-		Object groupId;
-		try {
-			groupId = this.getMetadata().getGroupIDForElementID(getActualID());
-		} catch (QueryMetadataException e) {
-			throw new ConnectorException(e);
-		} catch (MetaMatrixComponentException e) {
-			throw new ConnectorException(e);
-		}
-		return new GroupImpl(groupId, getFactory());
-	}  
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.metadata;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Group;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-
-/**
- */
-public class GroupImpl extends MetadataObjectImpl implements Group {
-	
-    GroupImpl(Object actualID, RuntimeMetadataImpl factory){
-        super(actualID, factory);
-    }
-    
-    @Override
-    public List<Element> getChildren() throws ConnectorException {
-    	try {
-	    	List elementIds = getMetadata().getElementIDsInGroupID(getActualID());
-	    	List<Element> result = new ArrayList<Element>(elementIds.size());
-	    	for (Object elementId : elementIds) {
-				result.add(new ElementImpl(elementId, getFactory()));
-	    	}
-	    	return result;
-    	} catch (QueryMetadataException e) {
-    		throw new ConnectorException(e);
-    	} catch (MetaMatrixComponentException e) {
-    		throw new ConnectorException(e);
-		}
-    }
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.metadata;
-
-import java.util.Properties;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.MetadataObject;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-
-/**
- */
-public abstract class MetadataObjectImpl implements MetadataObject {
-    private Object actualID;
-    private RuntimeMetadataImpl factory;
-	private String fullName;
-    
-    MetadataObjectImpl(Object actualID, RuntimeMetadataImpl factory){
-        this.actualID = actualID;
-        this.factory = factory;
-        try {
-			this.fullName = getMetadata().getFullName(actualID);
-		} catch (QueryMetadataException e) {
-			throw new MetaMatrixRuntimeException(e);
-		} catch (MetaMatrixComponentException e) {
-			throw new MetaMatrixRuntimeException(e);
-		}
-    }
-    
-    public Object getActualID() {
-        return actualID;
-    }
-
-    QueryMetadataInterface getMetadata() {
-        return factory.getMetadata();
-    }
-    
-    RuntimeMetadataImpl getFactory() {
-		return factory;
-	}
-
-    public String getNameInSource() throws ConnectorException {
-        try {
-            return getMetadata().getNameInSource(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public Properties getProperties() throws ConnectorException {
-        try {
-            return getMetadata().getExtensionProperties(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-    
-    public boolean equals(Object obj){
-        if (this == obj) {
-            return true;
-        }
-
-        if (this.getClass().isInstance(obj)) {
-            MetadataObjectImpl that = (MetadataObjectImpl)obj;
-            return this.actualID.equals(that.actualID);
-        }
-        
-        return false;        
-    }
-    
-    public int hashCode(){
-        return actualID.hashCode();
-    } 
-    
-    @Override
-    public String getName() {
-        int index = fullName.lastIndexOf("."); //$NON-NLS-1$
-        return fullName.substring(index + 1);
-    }
-    
-    @Override
-    public String getFullName() {
-		return fullName;
-	}
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,132 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.metadata;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.Parameter;
-import org.teiid.connector.metadata.runtime.Procedure;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.ParameterInfo;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.sql.lang.SPParameter;
-
-/**
- */
-public class ParameterImpl extends TypeModelImpl implements Parameter {
-
-    private SPParameter param;
-    private Procedure parent;
-
-    /**
-     * @param metadataID
-     */
-    ParameterImpl(RuntimeMetadataImpl factory, SPParameter param, Procedure parent) {
-        super(param.getMetadataID(), factory);
-        this.parent = parent;
-        this.param = param;
-    }
-
-    private SPParameter getParameterInfo() throws ConnectorException {
-        return param;  
-    }
-
-    /* 
-     * @see com.metamatrix.data.metadata.runtime.Parameter#getIndex()
-     */
-    public int getIndex() throws ConnectorException {
-        SPParameter paramInfo = getParameterInfo();
-        return paramInfo.getIndex();
-    }
-
-    /* 
-     * @see com.metamatrix.data.metadata.runtime.Parameter#getDirection()
-     */
-    public int getDirection() throws ConnectorException {
-        SPParameter paramInfo = getParameterInfo();
-        switch(paramInfo.getParameterType()) {
-            case ParameterInfo.IN:            return Parameter.IN;
-            case ParameterInfo.INOUT:         return Parameter.INOUT;
-            case ParameterInfo.OUT:           return Parameter.OUT;
-            case ParameterInfo.RESULT_SET:    return Parameter.RESULT_SET;
-            case ParameterInfo.RETURN_VALUE:  return Parameter.RETURN;
-            default:    
-                throw new ConnectorException(DQPPlugin.Util.getString("ParameterImpl.Invalid_direction", paramInfo.getParameterType())); //$NON-NLS-1$
-        }        
-    }
-
-    /* 
-     * @see com.metamatrix.data.metadata.runtime.Parameter#getJavaType()
-     */
-    public Class getJavaType() throws ConnectorException {
-        SPParameter paramInfo = getParameterInfo();
-        return paramInfo.getClassType();
-    }
-
-    /** 
-     * @see org.teiid.connector.metadata.runtime.TypeModel#getNullability()
-     * @since 4.3
-     */
-    public int getNullability() throws ConnectorException {
-        try {
-            boolean allowsNull = getMetadata().elementSupports(getActualID(), SupportConstants.Element.NULL);
-            boolean nullUnknown = getMetadata().elementSupports(getActualID(), SupportConstants.Element.NULL_UNKNOWN);
-            if(nullUnknown) {
-                return Element.NULLABLE_UNKNOWN;
-            }
-            if(allowsNull) {
-                return Element.NULLABLE;
-            }
-            return Element.NOT_NULLABLE;                    
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-    
-    @Override
-    public List<Element> getChildren() throws ConnectorException {
-    	if (param.getParameterType() == SPParameter.RESULT_SET) {
-    		List<Element> result = new ArrayList<Element>(param.getResultSetIDs().size());
-    		for (Object elementId : param.getResultSetIDs()) {
-    			result.add(new ElementImpl(elementId, getFactory()));
-    		}
-    		return result;
-    	}
-    	return Collections.emptyList();
-    }
-    
-    @Override
-    public Procedure getParent() throws ConnectorException {
-    	return parent;
-    }
-
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.datamgr.metadata;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.connector.metadata.runtime.Parameter;
-import org.teiid.connector.metadata.runtime.Procedure;
-
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.sql.lang.SPParameter;
-
-/**
- */
-public class ProcedureImpl extends MetadataObjectImpl implements Procedure {
-	
-	private StoredProcedureInfo procInfo;
-
-    ProcedureImpl(RuntimeMetadataImpl factory, StoredProcedureInfo procInfo){
-        super(procInfo.getProcedureID(), factory);
-        this.procInfo = procInfo;
-    }
-    
-    @Override
-    public List<Parameter> getChildren() {
-    	List<Parameter> result = new ArrayList<Parameter>(procInfo.getParameters().size());
-    	for (SPParameter param : procInfo.getParameters()) {
-    		result.add(new ParameterImpl(getFactory(), param, this));
-    	}
-    	return result;
-    }
-    
-}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -45,10 +45,10 @@
     }
     
     @Override
-    public Element getElement(String fullName) throws ConnectorException {
+    public Column getElement(String fullName) throws ConnectorException {
 		try {
-			Object elementId = metadata.getElementID(fullName);
-	    	return new ElementImpl(elementId, this);
+			Object metadataId = metadata.getElementID(fullName);
+			return getElement(metadataId);
 		} catch (QueryMetadataException e) {
 			throw new ConnectorException(e);
 		} catch (MetaMatrixComponentException e) {
@@ -56,12 +56,15 @@
 		}
     }
     
-    public ElementImpl getElement(Object elementId) {
-    	return new ElementImpl(elementId, this);
+    public Column getElement(Object elementId) {
+    	if (elementId instanceof Column) {
+    		return (Column)elementId;
+    	}
+    	return null;
     }
     
     @Override
-    public Group getGroup(String fullName) throws ConnectorException {
+    public Table getGroup(String fullName) throws ConnectorException {
 		try {
 			Object groupId = metadata.getGroupID(fullName);
 	    	return getGroup(groupId);
@@ -72,9 +75,9 @@
 		}
     }
 
-	public GroupImpl getGroup(Object groupId) throws QueryMetadataException, MetaMatrixComponentException {
-		if (!metadata.isVirtualGroup(groupId)) {
-			return new GroupImpl(groupId, this);
+	public Table getGroup(Object groupId) throws QueryMetadataException, MetaMatrixComponentException {
+		if (!metadata.isVirtualGroup(groupId) && groupId instanceof Table) {
+			return (Table)groupId;
 		}
 		return null;
 	}    
@@ -92,11 +95,17 @@
     }
 
 	public Procedure getProcedure(StoredProcedureInfo sp) {
-		return new ProcedureImpl(this, sp);
+		if (sp.getProcedureID() instanceof Procedure) {
+			return (Procedure)sp.getProcedureID();
+		}
+		return null;
 	}
 	
-	public Parameter getParameter(SPParameter param, Procedure parent) {
-		return new ParameterImpl(this, param, parent);
+	public ProcedureParameter getParameter(SPParameter param) {
+		if (param.getMetadataID() instanceof ProcedureParameter) {
+			return (ProcedureParameter)param.getMetadataID();
+		}
+		return null;
 	}
     
     public byte[] getBinaryVDBResource(String resourcePath) throws ConnectorException {

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.metadata;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.Element;
-import org.teiid.connector.metadata.runtime.TypeModel;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.metadata.SupportConstants;
-
-
-/** 
- * @since 4.3
- */
-public abstract class TypeModelImpl extends MetadataObjectImpl implements
-                                                TypeModel {
-
-    /** 
-     * @since 4.3
-     */
-    public TypeModelImpl(Object actualID, RuntimeMetadataImpl factory) {
-        super(actualID, factory);
-    }
-
-    public int getNullability() throws ConnectorException {
-        try {
-            boolean allowsNull = getMetadata().elementSupports(getActualID(), SupportConstants.Element.NULL);
-            boolean nullUnknown = getMetadata().elementSupports(getActualID(), SupportConstants.Element.NULL_UNKNOWN);
-            if(nullUnknown) {
-                return Element.NULLABLE_UNKNOWN;
-            }
-            if(allowsNull) {
-                return Element.NULLABLE;
-            }
-            return Element.NOT_NULLABLE;                    
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public Object getDefaultValue() throws ConnectorException {
-        try {
-            return getMetadata().getDefaultValue(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public int getLength() throws ConnectorException {
-        try {
-            return getMetadata().getElementLength(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-    
-    public int getPrecision() throws ConnectorException {
-        try {
-            return getMetadata().getPrecision(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public int getScale() throws ConnectorException {
-        try {
-            return getMetadata().getScale(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public String getModeledType() throws ConnectorException {
-        try {
-            return getMetadata().getModeledType(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-
-    public String getModeledBaseType() throws ConnectorException {
-        try {
-            return getMetadata().getModeledBaseType(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-    
-    public String getModeledPrimitiveType() throws ConnectorException {
-        try {
-            return getMetadata().getModeledPrimitiveType(getActualID());
-        } catch(QueryMetadataException e) {
-            throw new ConnectorException(e);
-        } catch(MetaMatrixComponentException e) {
-            throw new ConnectorException(e);            
-        }
-    }
-    
-
-}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,6 +22,10 @@
 
 package org.teiid.dqp.internal.process;
 
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkListener;
+
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.dqp.util.LogConstants;
 
@@ -30,20 +34,23 @@
  * Represents a task that performs work that may take more than one processing pass to complete.
  * During processing the WorkItem may receive events asynchronously through the moreWork method.
  */
-public abstract class AbstractWorkItem implements Runnable {
+public abstract class AbstractWorkItem implements Work, WorkListener {
 	
     enum ThreadState {
     	MORE_WORK, WORKING, IDLE, DONE
     }
     
     private ThreadState threadState = ThreadState.MORE_WORK;
+    private volatile boolean release = false;
     
     public void run() {
     	try {
+    		assosiateSecurityContext();
     		startProcessing();
     		process();
     	} finally {
     		endProcessing();
+   			clearSecurityContext();
     	}
     }
     
@@ -125,5 +132,34 @@
 	
     protected abstract boolean isDoneProcessing();
     
+    protected abstract boolean assosiateSecurityContext();
+    
+    protected abstract void clearSecurityContext();
+    
     public abstract String toString();
+    
+	@Override
+	public void release() {
+		this.release = true;
+	}
+	
+	public boolean shouldAbortProcessing() {
+		return this.release;
+	}
+	
+	@Override
+	public void workAccepted(WorkEvent arg0) {
+	}
+
+	@Override
+	public void workCompleted(WorkEvent arg0) {
+	}
+
+	@Override
+	public void workRejected(WorkEvent event) {
+	}
+
+	@Override
+	public void workStarted(WorkEvent arg0) {
+	}		
 }

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,25 @@
+package org.teiid.dqp.internal.process;
+
+import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.ResultsMessage;
+
+public class AsyncRequestWorkItem extends RequestWorkItem {
+
+	public AsyncRequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg,
+			Request request, ResultsReceiver<ResultsMessage> receiver,
+			RequestID requestID, DQPWorkContext workContext) {
+		super(dqpCore, requestMsg, request, receiver, requestID, workContext);
+	}
+	
+	
+	@Override
+	protected void resumeProcessing() {
+		dqpCore.addWork(this);
+	}
+	
+	@Override
+	protected void pauseProcessing() {
+	}
+}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.process;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-
-/**
- */
-public class CachedFinder implements CapabilitiesFinder {
-
-	private static BasicSourceCapabilities SYSTEM_CAPS = new BasicSourceCapabilities();
-	
-    private DataService dataService;
-    private RequestMessage requestMessage;
-    private DQPWorkContext workContext;
-
-    private Map<String, SourceCapabilities> userCache = new HashMap<String, SourceCapabilities>();
-    
-    /**
-     * Construct a CacheFinder that wraps another finder
-     * @param internalFinder Finder to wrap
-     */
-    public CachedFinder(DataService dataService, RequestMessage requestMessage, DQPWorkContext workContext) {
-        this.dataService = dataService;
-        this.requestMessage = requestMessage;
-        this.workContext = workContext;
-    	userCache.put(CoreConstants.SYSTEM_MODEL, SYSTEM_CAPS);
-    }
-
-    /**
-     * Find capabilities used the cache if possible, otherwise do the lookup.
-     */
-    public SourceCapabilities findCapabilities(String modelName) throws MetaMatrixComponentException {
-    	SourceCapabilities caps = userCache.get(modelName);
-        if(caps != null) {
-            return caps;
-        }
-        caps = dataService.getCapabilities(requestMessage, workContext, modelName);
-        userCache.put(modelName, caps);
-        return caps;
-    }
-    
-}

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.core.CoreConstants;
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+
+/**
+ */
+public class CachedFinder implements CapabilitiesFinder {
+
+	private static BasicSourceCapabilities SYSTEM_CAPS = new BasicSourceCapabilities();
+	
+    private ConnectorManagerRepository connectorRepo;
+    private VDBMetaData vdb;
+    
+    private Map<String, SourceCapabilities> userCache = new HashMap<String, SourceCapabilities>();
+    
+    /**
+     * Construct a CacheFinder that wraps another finder
+     * @param internalFinder Finder to wrap
+     */
+    public CachedFinder(ConnectorManagerRepository repo, VDBMetaData vdb) {
+        this.connectorRepo = repo;
+        this.vdb = vdb;
+    	userCache.put(CoreConstants.SYSTEM_MODEL, SYSTEM_CAPS);
+    }
+
+    /**
+     * Find capabilities used the cache if possible, otherwise do the lookup.
+     */
+    public SourceCapabilities findCapabilities(String modelName) throws MetaMatrixComponentException {
+    	SourceCapabilities caps = userCache.get(modelName);
+        if(caps != null) {
+            return caps;
+        }
+        ConnectorException exception = null;
+        ModelMetaData model = vdb.getModel(modelName);
+        for (String sourceName:model.getSourceNames()) {
+        	try {
+        		ConnectorManager mgr = this.connectorRepo.getConnectorManager(model.getSourceJndiName(sourceName));
+        		caps = mgr.getCapabilities();
+        		break;
+            } catch(ConnectorException e) {
+            	if (exception == null) {
+            		exception = e;
+            	}
+            }        	
+        }
+
+        if (exception != null) {
+        	throw new MetaMatrixComponentException(exception);
+        }
+        
+        userCache.put(modelName, caps);
+        return caps;
+    }
+        
+}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -250,7 +250,7 @@
         
         private int hashCode;
         
-        public CacheKey(String codeTable, String returnElement, String keyElement, String vdbName, String vdbVersion) {
+        public CacheKey(String codeTable, String returnElement, String keyElement, String vdbName, int vdbVersion) {
             this.codeTable = codeTable;
             this.returnElement = returnElement;
             this.keyElement = keyElement;

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkManager;
+
+public interface ContainerServiceProvider {
+	
+	XATerminator getXATerminator();
+	
+	WorkManager getWorkManager();
+	
+	DQPConfiguration getDQPConfiguration();
+
+}

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.dqp.internal.process;
+
+import com.metamatrix.dqp.message.RequestMessage;
+
+public class DQPConfiguration{
+	
+    //Constants
+    static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
+    static final int DEFAULT_MAX_CODE_TABLES = 200;
+    static final int DEFAULT_MAX_CODE_RECORDS = 200000;
+    static final int DEFAULT_FETCH_SIZE = RequestMessage.DEFAULT_FETCH_SIZE * 10;
+    static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
+    static final int DEFAULT_MAX_RESULTSET_CACHE_ENTRIES = 1024;
+    static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
+    static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
+	
+    
+	private String processName = "localhost";
+	private int maxThreads = DEFAULT_MAX_PROCESS_WORKERS;
+	private int timeSliceInMilli = DEFAULT_PROCESSOR_TIMESLICE;
+	private boolean processDebugAllowed;
+	private int maxRowsFetchSize = DEFAULT_FETCH_SIZE;
+	private int lobChunkSizeInKB = 100;
+	private int preparedPlanCacheMaxCount = SessionAwareCache.DEFAULT_MAX_SIZE_TOTAL;
+	private int codeTablesMaxCount = DEFAULT_MAX_CODE_TABLES;
+	private int codeTablesMaxRowsPerTable = DEFAULT_MAX_CODE_TABLE_RECORDS;
+	private int codeTablesMaxRows = DEFAULT_MAX_CODE_RECORDS;
+	private String bindAddress = "localhost";
+	private int portNumber = 31000;
+	private boolean resultSetCacheEnabled = false;
+	private int maxResultSetCacheEntries = DQPConfiguration.DEFAULT_MAX_RESULTSET_CACHE_ENTRIES;
+	
+	public String getProcessName() {
+		return processName;
+	}
+
+	public void setProcessName(String processName) {
+		this.processName = processName;
+	}
+
+	public int getMaxThreads() {
+		return maxThreads;
+	}
+
+	public void setMaxThreads(int maxThreads) {
+		this.maxThreads = maxThreads;
+	}
+
+	public int getTimeSliceInMilli() {
+		return timeSliceInMilli;
+	}
+
+	public void setTimeSliceInMilli(int timeSliceInMilli) {
+		this.timeSliceInMilli = timeSliceInMilli;
+	}
+	
+	public boolean isProcessDebugAllowed() {
+		return processDebugAllowed;
+	}
+
+	public void setProcessDebugAllowed(boolean processDebugAllowed) {
+		this.processDebugAllowed = processDebugAllowed;
+	}
+
+	public int getMaxRowsFetchSize() {
+		return maxRowsFetchSize;
+	}
+
+	public void setMaxRowsFetchSize(int maxRowsFetchSize) {
+		this.maxRowsFetchSize = maxRowsFetchSize;
+	}
+
+	public int getLobChunkSizeInKB() {
+		return lobChunkSizeInKB;
+	}
+
+	public void setLobChunkSizeInKB(int lobChunkSizeInKB) {
+		this.lobChunkSizeInKB = lobChunkSizeInKB;
+	}
+
+	public int getPreparedPlanCacheMaxCount() {
+		return preparedPlanCacheMaxCount;
+	}
+
+	public void setPreparedPlanCacheMaxCount(int preparedPlanCacheMaxCount) {
+		this.preparedPlanCacheMaxCount = preparedPlanCacheMaxCount;
+	}
+
+	public int getCodeTablesMaxCount() {
+		return codeTablesMaxCount;
+	}
+
+	public void setCodeTablesMaxCount(int codeTablesMaxCount) {
+		this.codeTablesMaxCount = codeTablesMaxCount;
+	}
+
+	public int getCodeTablesMaxRowsPerTable() {
+		return codeTablesMaxRowsPerTable;
+	}
+
+	public void setCodeTablesMaxRowsPerTable(int codeTablesMaxRowsPerTable) {
+		this.codeTablesMaxRowsPerTable = codeTablesMaxRowsPerTable;
+	}
+
+	public int getCodeTablesMaxRows() {
+		return codeTablesMaxRows;
+	}
+
+	public void setCodeTablesMaxRows(int codeTablesMaxRows) {
+		this.codeTablesMaxRows = codeTablesMaxRows;
+	}
+
+	public String getBindAddress() {
+		return bindAddress;
+	}
+
+	public void setBindAddress(String bindAddress) {
+		this.bindAddress = bindAddress;
+	}
+
+	public int getPortNumber() {
+		return portNumber;
+	}
+
+	public void setPortNumber(int portNumber) {
+		this.portNumber = portNumber;
+	}
+
+	public int getResultSetCacheMaxEntries() {
+		return this.maxResultSetCacheEntries;
+	}
+	
+	public void setResultSetCacheMaxEntries(int value) {
+		this.maxResultSetCacheEntries = value;
+	}
+
+	public boolean isResultSetCacheEnabled() {
+		return this.resultSetCacheEnabled;
+	}
+	
+	public void setResultSetCacheEnabled(boolean value) {
+		this.resultSetCacheEnabled = value;
+	}		
+}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,78 +23,116 @@
 package org.teiid.dqp.internal.process;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
 
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
 import javax.transaction.xa.Xid;
 
-import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.SecurityHelper;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
 import org.teiid.dqp.internal.cache.DQPContextCache;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.DQPConfigSource;
-import com.metamatrix.common.application.ServiceLoader;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.api.exception.security.SessionServiceException;
 import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.common.lob.LobChunk;
 import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.common.queue.WorkerPoolFactory;
+import com.metamatrix.common.queue.StatsCapturingWorkManager;
 import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.util.PropertiesUtils;
 import com.metamatrix.common.xa.MMXid;
 import com.metamatrix.common.xa.XATransactionException;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.Assertion;
 import com.metamatrix.dqp.DQPPlugin;
 import com.metamatrix.dqp.client.ClientSideDQP;
 import com.metamatrix.dqp.client.MetadataResult;
 import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.service.AuthorizationService;
 import com.metamatrix.dqp.service.BufferService;
 import com.metamatrix.dqp.service.CommandLogMessage;
-import com.metamatrix.dqp.service.ConfigurationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.VDBService;
 import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.platform.security.api.service.SessionService;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.processor.ProcessorDataManager;
 import com.metamatrix.query.tempdata.TempTableStoreImpl;
-import com.metamatrix.server.serverapi.RequestInfo;
 
 /**
  * Implements the core DQP processing.
  */
- at Singleton
 public class DQPCore implements ClientSideDQP {
 	
+	private final static class FutureWork<T> implements Work, WorkListener {
+		private final ResultsReceiver<T> receiver;
+		private final Callable<T> toCall;
+
+		private FutureWork(ResultsReceiver<T> receiver,
+				Callable<T> processor) {
+			this.receiver = receiver;
+			this.toCall = processor;
+		}
+
+		@Override
+		public void run() {
+			try {
+				receiver.receiveResults(toCall.call());
+			} catch (Throwable t) {
+				receiver.exceptionOccurred(t);
+			}
+		}
+
+		@Override
+		public void release() {
+			
+		}
+		
+		@Override
+		public void workAccepted(WorkEvent arg0) {
+			
+		}
+		
+		@Override
+		public void workCompleted(WorkEvent arg0) {
+			
+		}
+		
+		@Override
+		public void workRejected(WorkEvent arg0) {
+			receiver.exceptionOccurred(arg0.getException());
+		}
+		
+		@Override
+		public void workStarted(WorkEvent arg0) {
+			
+		}
+	}	
+	
 	static class ClientState {
 		List<RequestID> requests;
 		TempTableStoreImpl tempTableStoreImpl;
@@ -125,22 +163,15 @@
 		
 	}
 	
-    //Constants
-    private static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
-    private static final int DEFAULT_MAX_CODE_TABLES = 200;
-    private static final int DEFAULT_MAX_CODE_RECORDS = 200000;
-    private static final int DEFAULT_MAX_FETCH_SIZE = RequestMessage.DEFAULT_FETCH_SIZE * 10;
-    private static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
-    private static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
-    private static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
-    private static final int DEFAULT_MAX_RESULTSET_CACHE_ENTRIES = 1024;
-
+    private WorkManager workManager;
+    private StatsCapturingWorkManager processWorkerPool;
+    
     // System properties for Code Table
-    private int maxCodeTableRecords = DEFAULT_MAX_CODE_TABLE_RECORDS;
-    private int maxCodeTables = DEFAULT_MAX_CODE_TABLES;
-    private int maxCodeRecords = DEFAULT_MAX_CODE_RECORDS;
+    private int maxCodeTableRecords = DQPConfiguration.DEFAULT_MAX_CODE_TABLE_RECORDS;
+    private int maxCodeTables = DQPConfiguration.DEFAULT_MAX_CODE_TABLES;
+    private int maxCodeRecords = DQPConfiguration.DEFAULT_MAX_CODE_RECORDS;
     
-    private int maxFetchSize = DEFAULT_MAX_FETCH_SIZE;
+    private int maxFetchSize = DQPConfiguration.DEFAULT_FETCH_SIZE;
     
     // Resources
     private BufferManager bufferManager;
@@ -148,11 +179,13 @@
     private SessionAwareCache<PreparedPlan> prepPlanCache;
     private SessionAwareCache<CachedResults> rsCache;
     private TransactionService transactionService;
-    private MetadataService metadataService;
+    private AuthorizationService authorizationService;
+    private BufferService bufferService;
+    private SessionService sessionService;
+    private ConnectorManagerRepository connectorManagerRepository;
     
     // Query worker pool for processing plans
-    private WorkerPool processWorkerPool;
-    private int processorTimeslice = DEFAULT_PROCESSOR_TIMESLICE;
+    private int processorTimeslice = DQPConfiguration.DEFAULT_PROCESSOR_TIMESLICE;
     private boolean processorDebugAllowed;
     
     private int chunkSize = Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
@@ -160,35 +193,26 @@
 	private Map<RequestID, RequestWorkItem> requests = new ConcurrentHashMap<RequestID, RequestWorkItem>();			
 	private Map<String, ClientState> clientState = Collections.synchronizedMap(new HashMap<String, ClientState>());
 	private DQPContextCache contextCache;
-    private ServiceLoader loader = new ServiceLoader();
-    private CacheFactory cacheFactory;
+	private SecurityHelper securityHelper;
     
-    private ApplicationEnvironment environment = new ApplicationEnvironment();
-
     /**
      * perform a full shutdown and wait for 10 seconds for all threads to finish
-     * @throws ApplicationLifecycleException 
      */
-    public void stop() throws ApplicationLifecycleException {
-		LogManager.logDetail(LogConstants.CTX_DQP, "Stopping the DQP"); //$NON-NLS-1$
+    public void stop() {
     	processWorkerPool.shutdownNow();
     	try {
 			processWorkerPool.awaitTermination(10, TimeUnit.SECONDS);
 		} catch (InterruptedException e) {
 		}
-    	contextCache.shutdown();
-    	this.environment.stop();
-    	
-    	if (cacheFactory != null) {
-    		cacheFactory.destroy();
-    	}
+    	// TODO: Should we be doing more cleanup here??
+		LogManager.logDetail(LogConstants.CTX_DQP, "Stopping the DQP"); //$NON-NLS-1$
     }
     
     /**
-     * Return a list of {@link RequestInfo} for the given session
+     * Return a list of {@link RequestMetadata} for the given session
      */
-    public List<RequestInfo> getRequestsByClient(String clientConnection) {
-    	ClientState state = getClientState(clientConnection, false);
+    public List<RequestMetadata> getRequestsForSession(long sessionId) {
+    	ClientState state = getClientState(String.valueOf(sessionId), false);
     	if (state == null) {
     		return Collections.emptyList();
     	}
@@ -207,38 +231,48 @@
     }
 
     /**
-     * Return a list of all {@link RequestInfo} 
+     * Return a list of all {@link RequestMetadata} 
      */
-    public List<RequestInfo> getRequests() {
+    public List<RequestMetadata> getRequests() {
 		return buildRequestInfos(requests.keySet());
     } 
 
-    private List<RequestInfo> buildRequestInfos(Collection<RequestID> ids) {
-		List<RequestInfo> results = new ArrayList<RequestInfo>();
-    	for (RequestID requestID : ids) {
+    private List<RequestMetadata> buildRequestInfos(Collection<RequestID> ids) {
+		List<RequestMetadata> results = new ArrayList<RequestMetadata>();
+    	
+		for (RequestID requestID : ids) {
             RequestWorkItem holder = requests.get(requestID);
             
             if(holder != null && !holder.isCanceled()) {
-            	RequestInfo req = new RequestInfo(holder.requestID, holder.requestMsg.getCommandString(), holder.requestMsg.getSubmittedTimestamp(), holder.requestMsg.getProcessingTimestamp());
-            	req.setSessionToken(holder.getDqpWorkContext().getSessionToken());
-            	if (holder.getTransactionContext() != null && holder.getTransactionContext().isInTransaction()) {
-            		req.setTransactionId(holder.getTransactionContext().getTxnID());
+            	RequestMetadata req = new RequestMetadata();
+            	
+            	req.setExecutionId(holder.requestID.getExecutionID());
+            	req.setSessionId(Long.parseLong(holder.requestID.getConnectionID()));
+            	req.setCommand(holder.requestMsg.getCommandString());
+            	req.setProcessingTime(holder.getProcessingTimestamp());
+            	
+            	if (holder.getTransactionContext() != null && holder.getTransactionContext().getXid() != null) {
+            		req.setTransactionId(holder.getTransactionContext().getXid().toString());
             	}
 
                 for (DataTierTupleSource conInfo : holder.getConnectorRequests()) {
-                    ConnectorID connectorID = conInfo.getConnectorId();
+                    String connectorName = conInfo.getConnectorName();
 
-                    if (connectorID == null) {
+                    if (connectorName == null) {
                     	continue;
                     }
                     // If the request has not yet completed processing, then
                     // add all the subrequest messages
                 	AtomicRequestMessage arm = conInfo.getAtomicRequestMessage();
-                	RequestInfo info = new RequestInfo(arm.getRequestID(), arm.getCommand().toString(), arm.getSubmittedTimestamp(), arm.getProcessingTimestamp());
-                	info.setSessionToken(holder.getDqpWorkContext().getSessionToken());
-                	info.setConnectorBindingUUID(arm.getConnectorBindingID());
-        			info.setNodeID(arm.getAtomicRequestID().getNodeID());
-        			info.setExecutionID(arm.getAtomicRequestID().getExecutionId());
+                	RequestMetadata info = new RequestMetadata();
+                	
+                	info.setExecutionId(arm.getRequestID().getExecutionID());
+                	info.setSessionId(Long.parseLong(holder.requestID.getConnectionID()));
+                	info.setCommand(arm.getCommand().toString());
+                	info.setProcessingTime(arm.getProcessingTimestamp());
+                	info.setSourceRequest(true);
+                	info.setNodeId(arm.getAtomicRequestID().getNodeID());
+                	
         			results.add(info);
                 }
                 results.add(req);
@@ -247,11 +281,9 @@
     	return results;
 	}    
 
-	public ResultsFuture<ResultsMessage> executeRequest(long reqID,
-			RequestMessage requestMsg) {
+	public ResultsFuture<ResultsMessage> executeRequest(long reqID,RequestMessage requestMsg) {
     	DQPWorkContext workContext = DQPWorkContext.getWorkContext();
 		RequestID requestID = workContext.getRequestID(reqID);
-		requestMsg.markProcessingStart();
 		requestMsg.setFetchSize(Math.min(requestMsg.getFetchSize(), maxFetchSize));
 		Request request = null;
 	    if ( requestMsg.isPreparedStatement() || requestMsg.isCallableStatement()) {
@@ -260,16 +292,14 @@
 	    	request = new Request();
 	    }
 	    ClientState state = this.getClientState(workContext.getConnectionID(), true);
-	    request.initialize(requestMsg, environment, bufferManager,
-				dataTierMgr, transactionService, processorDebugAllowed,
+	    request.initialize(requestMsg, bufferManager,
+				dataTierMgr, transactionService, authorizationService, processorDebugAllowed,
 				state.tempTableStoreImpl, workContext,
-				chunkSize);
+				chunkSize, connectorManagerRepository);
 		
         ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
-
         RequestWorkItem workItem = new RequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext);
-
-    	logMMCommand(workItem, true, false, 0); //TODO: there is no transaction at this point 
+    	logMMCommand(workItem, true, false, 0); 
         addRequest(requestID, workItem, state);
         
         this.addWork(workItem);      
@@ -302,10 +332,27 @@
     	contextCache.removeRequestScopedCache(workItem.requestID.toString());
     }
            
-    void addWork(Runnable r) {
-    	this.processWorkerPool.execute(r);
+    void addWork(Work work) {
+    	try {
+			this.processWorkerPool.scheduleWork(this.workManager, work);
+		} catch (WorkException e) {
+			//TODO: cancel? close?
+			throw new MetaMatrixRuntimeException(e);
+		}
     }
     
+    public void setWorkManager(WorkManager mgr) {
+    	this.workManager = mgr;
+    }
+    
+    SecurityHelper getSecurityHelper() {
+    	return this.securityHelper;
+    }
+    
+    public void setSecurityHelper(SecurityHelper securityHelper) {
+		this.securityHelper = securityHelper;
+	}
+    
 	public ResultsFuture<?> closeLobChunkStream(int lobRequestId,
 			long requestId, String streamId)
 			throws MetaMatrixProcessingException {
@@ -317,7 +364,7 @@
         if (workItem != null) {
 	        workItem.removeLobStream(lobRequestId);
         }
-        return null;
+        return ResultsFuture.NULL_FUTURE;
     }
 	    
 	public ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId,
@@ -332,20 +379,20 @@
         return resultsFuture;
     }
     
-    /**
-     * Cancels a node in the request. (This request is called by the 
-     * client directly using the admin API), so if this does not support
-     * partial results then remove the original request.
-     * @throws MetaMatrixComponentException 
-     */
-    public void cancelAtomicRequest(AtomicRequestID requestID) throws MetaMatrixComponentException {                    
-        RequestWorkItem workItem = safeGetWorkItem(requestID.getRequestID());
-        if (workItem == null) {
-    		LogManager.logDetail(LogConstants.CTX_DQP, "Could not cancel", requestID, "parent request does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
-        	return;
-        }
-        workItem.requestAtomicRequestCancel(requestID);
-    }
+//    /**
+//     * Cancels a node in the request. (This request is called by the 
+//     * client directly using the admin API), so if this does not support
+//     * partial results then remove the original request.
+//     * @throws MetaMatrixComponentException 
+//     */
+//    public void cancelAtomicRequest(AtomicRequestID requestID) throws MetaMatrixComponentException {                    
+//        RequestWorkItem workItem = safeGetWorkItem(requestID.getRequestID());
+//        if (workItem == null) {
+//    		LogManager.logDetail(LogConstants.CTX_DQP, "Could not cancel", requestID, "parent request does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
+//        	return;
+//        }
+//        workItem.requestAtomicRequestCancel(requestID);
+//    }
     
     RequestWorkItem getRequestWorkItem(RequestID reqID) throws MetaMatrixProcessingException {
     	RequestWorkItem result = this.requests.get(reqID);
@@ -358,42 +405,19 @@
 	RequestWorkItem safeGetWorkItem(Object processorID) {
     	return this.requests.get(processorID);
 	}
-
+	
     /**
      * Returns a list of QueueStats objects that represent the queues in
      * this service.
      * If there are no queues, an empty Collection is returned.
      */
-    public Collection getQueueStatistics() {
-        if ( this.processWorkerPool == null ) {
-            return Collections.EMPTY_LIST;
-        }
-
-        return Arrays.asList(processWorkerPool.getStats());
+    public WorkerPoolStatisticsMetadata getWorkManagerStatistics() {
+        return processWorkerPool.getStats();
     }
-
-    /**
-     * Returns a QueueStats object that represent the queue in
-     * this service.
-     * If there is no queue with the given name, an empty Collection is returned.
-     */
-    public Collection getQueueStatistics(String name) {
-        if ( !name.equalsIgnoreCase(PROCESS_PLAN_QUEUE_NAME)) {
-            return Collections.EMPTY_LIST;
-        }
-        return getQueueStatistics();
-    }
-            
-    /**
-     * Cancel and close all requests associated with the clientConnection/session. Also runs a final cleanup any caches within
-     * the session's scope.
-     * @param clientConnection
-     * @param sendCancellationsToClient Notify the client that each request has been closed.
-     * @throws MetaMatrixComponentException
-     * @since 4.2
-     */
-    public void terminateConnection(String sessionId) throws MetaMatrixComponentException {
-    	        
+           
+    public void terminateSession(long terminateeId) {
+    	String sessionId = String.valueOf(terminateeId);
+    	
         // sometimes there will not be any atomic requests pending, in that
         // situation we still need to clear the master request from our map
         ClientState state = getClientState(sessionId, false);
@@ -410,18 +434,19 @@
         if (transactionService != null) {
             try {
                 transactionService.cancelTransactions(sessionId, false);
-            } catch (InvalidTransactionException err) {
+            } catch (XATransactionException err) {
                 LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + sessionId); //$NON-NLS-1$
-            } catch (SystemException err) {
-                throw new MetaMatrixComponentException(err);
-            }
+            } 
         }
         contextCache.removeSessionScopedCache(sessionId);
     }
 
-    public boolean cancelRequest(RequestID requestID)
-        throws MetaMatrixComponentException {
-        
+    public boolean cancelRequest(long sessionId, long requestId) throws MetaMatrixComponentException {
+    	RequestID requestID = new RequestID(String.valueOf(sessionId), requestId);
+    	return cancelRequest(requestID);
+    }
+    
+    private boolean cancelRequest(RequestID requestID) throws MetaMatrixComponentException {
         if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
             LogManager.logDetail(LogConstants.CTX_DQP, "cancelQuery for requestID=" + requestID); //$NON-NLS-1$
         }
@@ -443,7 +468,7 @@
 	public ResultsFuture<?> closeRequest(long requestId) throws MetaMatrixProcessingException, MetaMatrixComponentException {
         DQPWorkContext workContext = DQPWorkContext.getWorkContext();
         closeRequest(workContext.getRequestID(requestId));
-        return null;
+        return ResultsFuture.NULL_FUTURE;
 	}
     
     /**
@@ -464,23 +489,78 @@
         }
     }
     
-    public void clearPlanCache(){
+    private void clearPlanCache(){
         LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_prepared_plan_cache")); //$NON-NLS-1$
         this.prepPlanCache.clearAll();
     }
 
-    public void clearCodeTableCache(){
+    private void clearCodeTableCache(){
         LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_code_table_cache")); //$NON-NLS-1$
         this.dataTierMgr.clearCodeTables();
     }
-
-	public void clearResultSetCache() {
+    
+	private void clearResultSetCache() {
 		//clear cache in server
 		if(rsCache != null){
 			rsCache.clearAll();
 		}
 	}
+	
+	
+    public Collection<String> getCacheTypes(){
+    	ArrayList<String> caches = new ArrayList<String>();
+    	caches.add(Admin.Cache.CODE_TABLE_CACHE.toString());
+    	caches.add(Admin.Cache.PREPARED_PLAN_CACHE.toString());
+    	caches.add(Admin.Cache.CONNECTOR_RESULT_SET_CACHE.toString());
+    	caches.add(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString());
+    	return caches;
+    }	
+	
+	public void clearCache(String cacheType) {
+		Admin.Cache cache = Admin.Cache.valueOf(cacheType);
+		switch (cache) {
+		case CODE_TABLE_CACHE:
+			clearCodeTableCache();
+			break;
+		case PREPARED_PLAN_CACHE:
+			clearPlanCache();
+			break;
+		case CONNECTOR_RESULT_SET_CACHE:
+			clearResultSetCache();
+			break;
+		case QUERY_SERVICE_RESULT_SET_CACHE:
+			break;
+		}
+	}
     
+	public Collection<SessionMetadata> getActiveSessions() throws SessionServiceException {
+		if (this.sessionService == null) {
+			return Collections.emptyList();
+		}
+		return this.sessionService.getActiveSessions();
+	}
+	
+	public int getActiveSessionsCount() throws SessionServiceException{
+		if (this.sessionService == null) {
+			return 0;
+		}
+		return this.sessionService.getActiveSessionsCount();
+	}	
+	
+	public Collection<org.teiid.adminapi.Transaction> getTransactions() {
+		if (this.transactionService == null) {
+			return Collections.emptyList();
+		}
+		return this.transactionService.getTransactions();
+	}
+	
+	public void terminateTransaction(String xid) throws AdminException {
+		if (this.transactionService == null) {
+			return;
+		}
+		this.transactionService.terminateTransaction(xid);
+	}	
+	
     void logMMCommand(RequestWorkItem workItem, boolean isBegin, boolean isCancel, int rowCount) {
     	if (!LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.INFO)) {
     		return;
@@ -495,8 +575,8 @@
     	}
     	String txnID = null;
 		TransactionContext tc = workItem.getTransactionContext();
-		if (tc != null) {
-			txnID = tc.getTxnID();
+		if (tc != null && tc.getXid() != null) {
+			txnID = tc.getXid().toString();
 		}
     	String appName = workContext.getAppName();
         // Log to request log
@@ -523,7 +603,7 @@
             }
             message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getConnectionID(), workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), rowCount, isCancelled, errorOccurred);
         }
-        LogManager.log(MessageLevel.INFO, LogConstants.CTX_COMMANDLOGGING, message);
+        LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_COMMANDLOGGING, message);
     }
     
     ProcessorDataManager getDataTierManager() {
@@ -544,10 +624,6 @@
 		}
 		return transactionService;
 	}
-	
-	public TransactionService getTransactionServiceDirect() {
-		return transactionService;
-	}
 
 	SessionAwareCache<CachedResults> getRsCache() {
 		return rsCache;
@@ -560,173 +636,188 @@
 	int getChunkSize() {
 		return chunkSize;
 	}
-
-    /* 
-     * @see com.metamatrix.common.application.Application#initialize(java.util.Properties)
-     */
-    public void start(DQPConfigSource configSource) throws ApplicationInitializationException {
-        
-        // Load services into DQP
-        for(int i=0; i<DQPServiceNames.ALL_SERVICES.length; i++) {
-            
-        	final String serviceName = DQPServiceNames.ALL_SERVICES[i];
-            final Class<? extends ApplicationService> type = DQPServiceNames.ALL_SERVICE_CLASSES[i];
-
-            ApplicationService appService = configSource.getServiceInstance(type);
-        	if (appService == null) {
-        		LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPLauncher.InstallService_ServiceIsNull", serviceName)); //$NON-NLS-1$
-        		continue;
-        	}
-        	
-        	appService = loader.loadService(serviceName, appService);
-        	String loggingContext = DQPServiceNames.SERVICE_LOGGING_CONTEXT[i];
-			if (loggingContext != null) {
-				appService = (ApplicationService)LogManager.createLoggingProxy(loggingContext, appService, new Class[] {type}, MessageLevel.DETAIL);
-			}
-            
-			appService.initialize(configSource.getProperties());
-        	this.environment.installService(serviceName, appService);
-            LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPLauncher.InstallService_ServiceInstalled", serviceName)); //$NON-NLS-1$
-        }
-        
-		ConfigurationService cs = (ConfigurationService)this.environment.findService(DQPServiceNames.CONFIGURATION_SERVICE);
-		Properties p = configSource.getProperties();
-		if (cs != null) {
-			p = cs.getSystemProperties();
-		}
-		start(p);
-    }
-    
 	
-	public void start(Properties props) {
-		PropertiesUtils.setBeanProperties(this, props, null);
+	public void start(DQPConfiguration config) {
 		
-        this.processorTimeslice = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_TIMESLICE, DEFAULT_PROCESSOR_TIMESLICE);
-        this.maxFetchSize = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_FETCH_SIZE, DEFAULT_MAX_FETCH_SIZE);
-        this.processorDebugAllowed = PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.PROCESSOR_DEBUG_ALLOWED, true);
-        this.maxCodeTableRecords = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLE_RECORDS_PER_TABLE, DEFAULT_MAX_CODE_TABLE_RECORDS);
-        this.maxCodeTables = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLES, DEFAULT_MAX_CODE_TABLES);
-        this.maxCodeRecords = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLE_RECORDS, DEFAULT_MAX_CODE_RECORDS);
+		Assertion.isNotNull(this.workManager);
+
+		this.processorTimeslice = config.getTimeSliceInMilli();
+        this.maxFetchSize = config.getMaxRowsFetchSize();
+        this.processorDebugAllowed = config.isProcessDebugAllowed();
+        this.maxCodeTableRecords = config.getCodeTablesMaxRowsPerTable();
+        this.maxCodeTables = config.getCodeTablesMaxCount();
+        this.maxCodeRecords = config.getCodeTablesMaxRows();
         
-        this.chunkSize = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.STREAMING_BATCH_SIZE, 100) * 1024;
+        this.chunkSize = config.getLobChunkSizeInKB() * 1024;
         
         //result set cache
-        if(PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.USE_RESULTSET_CACHE, true)){ 
-			this.rsCache = new SessionAwareCache<CachedResults>(PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_RESULTSET_CACHE_ENTRIES, DEFAULT_MAX_RESULTSET_CACHE_ENTRIES));
+        if (config.isResultSetCacheEnabled()) {
+			this.rsCache = new SessionAwareCache<CachedResults>(config.getResultSetCacheMaxEntries());
         }
 
         //prepared plan cache
-        int maxSizeTotal = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_PLAN_CACHE_SIZE, SessionAwareCache.DEFAULT_MAX_SIZE_TOTAL);
-        prepPlanCache = new SessionAwareCache<PreparedPlan>(maxSizeTotal);
+        prepPlanCache = new SessionAwareCache<PreparedPlan>(config.getPreparedPlanCacheMaxCount());
 		
         // Processor debug flag
         LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Processor_debug_allowed_{0}", this.processorDebugAllowed)); //$NON-NLS-1$
                         
         //get buffer manager
-        BufferService bufferService = (BufferService) this.environment.findService(DQPServiceNames.BUFFER_SERVICE);
-        bufferManager = bufferService.getBufferManager();
-        contextCache = bufferService.getContextCache();
+        this.bufferManager = bufferService.getBufferManager();
+        this.contextCache = bufferService.getContextCache();
 
-        transactionService = (TransactionService )this.environment.findService(DQPServiceNames.TRANSACTION_SERVICE);
-        metadataService = (MetadataService) this.environment.findService(DQPServiceNames.METADATA_SERVICE);
-
-        // Create the worker pools to tie the queues together
-        processWorkerPool = WorkerPoolFactory.newWorkerPool(PROCESS_PLAN_QUEUE_NAME, PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_POOL_MAX_THREADS, DEFAULT_MAX_PROCESS_WORKERS)); 
- 
+        this.processWorkerPool = new StatsCapturingWorkManager(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
+        
         dataTierMgr = new DataTierManagerImpl(this,
-                                            (DataService) this.environment.findService(DQPServiceNames.DATA_SERVICE),
-                                            (VDBService) this.environment.findService(DQPServiceNames.VDB_SERVICE),
-                                            (BufferService) this.environment.findService(DQPServiceNames.BUFFER_SERVICE),
-                                            metadataService,
+                                            this.connectorManagerRepository,
+                                            this.bufferService,
+                                            this.workManager,
                                             this.maxCodeTables,
                                             this.maxCodeRecords,
-                                            this.maxCodeTableRecords);        
+                                            this.maxCodeTableRecords);    
+
 	}
 	
-	public List getXmlSchemas(String docName) throws MetaMatrixComponentException,
-			QueryMetadataException {
+	public void setBufferService(BufferService service) {
+		this.bufferService = service;
+		setContextCache(service.getContextCache());
+	}
+	
+	public void setAuthorizationService(AuthorizationService service) {
+		this.authorizationService = service;
+	}
+
+	public void setContextCache(DQPContextCache cache) {
+		this.contextCache = cache;
+	}
+
+	public void setTransactionService(TransactionService service) {
+		this.transactionService = service;
+	}
+	
+	public List<String> getXmlSchemas(String docName) throws MetaMatrixComponentException, QueryMetadataException {
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-        QueryMetadataInterface metadata = metadataService.lookupMetadata(workContext.getVdbName(), workContext.getVdbVersion());
+        QueryMetadataInterface metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
 
         Object groupID = metadata.getGroupID(docName);
         return metadata.getXMLSchemas(groupID);
 	}
 
-	public void cancelRequest(long requestID)
+	@Override
+	public boolean cancelRequest(long requestID)
 			throws MetaMatrixProcessingException, MetaMatrixComponentException {
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-		this.cancelRequest(workContext.getRequestID(requestID));
+		return this.cancelRequest(workContext.getRequestID(requestID));
 	}
 	
-	public void begin() throws XATransactionException {
+	// local txn
+	public ResultsFuture<?> begin() throws XATransactionException {
     	String threadId = DQPWorkContext.getWorkContext().getConnectionID();
-        try {
-			this.getTransactionService().begin(threadId);
-		} catch (SystemException e) {
-			throw new XATransactionException(e);
-		}
+    	this.getTransactionService().begin(threadId);
+    	return ResultsFuture.NULL_FUTURE;
 	}
 	
-	public void commit() throws XATransactionException {
-		String threadId = DQPWorkContext.getWorkContext().getConnectionID();
-        try {
-			this.getTransactionService().commit(threadId);
-		} catch (SystemException e) {
-			throw new XATransactionException(e);
-		}
+	// local txn
+	public ResultsFuture<?> commit() throws XATransactionException {
+		final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+		Callable<Void> processor = new Callable<Void>() {
+			@Override
+			public Void call() throws Exception {
+				getTransactionService().commit(threadId);
+				return null;
+			}
+		};
+		return addWork(processor);
 	}
 	
-	public void rollback() throws XATransactionException {
-		try {
-			this.getTransactionService().rollback(
-					DQPWorkContext.getWorkContext().getConnectionID());
-		} catch (SystemException e) {
-			throw new XATransactionException(e);
-		}
+	// local txn
+	public ResultsFuture<?> rollback() throws XATransactionException {
+		final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+		Callable<Void> processor = new Callable<Void>() {
+			@Override
+			public Void call() throws Exception {
+				getTransactionService().rollback(threadId);
+				return null;
+			}
+		};
+		return addWork(processor);
 	}
 
-	public void commit(MMXid xid, boolean onePhase)
-			throws XATransactionException {
+	// global txn
+	public ResultsFuture<?> commit(final MMXid xid, final boolean onePhase) throws XATransactionException {
+		final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+		Callable<Void> processor = new Callable<Void>() {
+			@Override
+			public Void call() throws Exception {
+				getTransactionService().commit(threadId, xid, onePhase, false);
+				return null;
+			}
+		};
+		return addWork(processor);
+	}
+	// global txn
+	public ResultsFuture<?> end(MMXid xid, int flags) throws XATransactionException {
 		String threadId = DQPWorkContext.getWorkContext().getConnectionID();
-		this.getTransactionService().commit(threadId, xid, onePhase);
+		this.getTransactionService().end(threadId, xid, flags, false);
+		return ResultsFuture.NULL_FUTURE;
 	}
-
-	public void end(MMXid xid, int flags) throws XATransactionException {
+	// global txn
+	public ResultsFuture<?> forget(MMXid xid) throws XATransactionException {
 		String threadId = DQPWorkContext.getWorkContext().getConnectionID();
-		this.getTransactionService().end(threadId, xid, flags);
+		this.getTransactionService().forget(threadId, xid, false);
+		return ResultsFuture.NULL_FUTURE;
 	}
+		
+	// global txn
+	public ResultsFuture<Integer> prepare(final MMXid xid) throws XATransactionException {
+		Callable<Integer> processor = new Callable<Integer>() {
+			@Override
+			public Integer call() throws Exception {
+				return getTransactionService().prepare(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+			}
+		};
+		return addWork(processor);
+	}
 
-	public void forget(MMXid xid) throws XATransactionException {
-		String threadId = DQPWorkContext.getWorkContext().getConnectionID();
-		this.getTransactionService().forget(threadId, xid);
+	private <T> ResultsFuture<T> addWork(Callable<T> processor) {
+		ResultsFuture<T> result = new ResultsFuture<T>();
+		ResultsReceiver<T> receiver = result.getResultsReceiver();
+		try {
+			this.workManager.scheduleWork(new FutureWork<T>(receiver, processor));
+		} catch (WorkException e) {
+			throw new MetaMatrixRuntimeException(e);
+		}
+		return result;
 	}
 	
-	public int prepare(MMXid xid) throws XATransactionException {
-		return this.getTransactionService().prepare(
-				DQPWorkContext.getWorkContext().getConnectionID(),
-				xid);
+	// global txn
+	public ResultsFuture<Xid[]> recover(int flag) throws XATransactionException {
+		ResultsFuture<Xid[]> result = new ResultsFuture<Xid[]>();
+		result.getResultsReceiver().receiveResults(this.getTransactionService().recover(flag, false));
+		return result;
 	}
-	
-	public Xid[] recover(int flag) throws XATransactionException {
-		return this.getTransactionService().recover(flag);
+	// global txn
+	public ResultsFuture<?> rollback(final MMXid xid) throws XATransactionException {
+		Callable<Void> processor = new Callable<Void>() {
+			@Override
+			public Void call() throws Exception {
+				getTransactionService().rollback(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+				return null;
+			}
+		};
+		return addWork(processor);
 	}
-
-	public void rollback(MMXid xid) throws XATransactionException {
-		this.getTransactionService().rollback(
-				DQPWorkContext.getWorkContext().getConnectionID(),
-				xid);
-	}
-
-	public void start(MMXid xid, int flags, int timeout)
+	// global txn
+	public ResultsFuture<?> start(MMXid xid, int flags, int timeout)
 			throws XATransactionException {
 		String threadId = DQPWorkContext.getWorkContext().getConnectionID();
-		this.getTransactionService().start(threadId, xid, flags, timeout);
+		this.getTransactionService().start(threadId, xid, flags, timeout, false);
+		return ResultsFuture.NULL_FUTURE;
 	}
 
 	public MetadataResult getMetadata(long requestID)
 			throws MetaMatrixComponentException, MetaMatrixProcessingException {
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-		MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, this.environment, workContext.getVdbName(), workContext.getVdbVersion());
+		MetaDataProcessor processor = new MetaDataProcessor(this, this.prepPlanCache,  workContext.getVdbName(), workContext.getVdbVersion());
 		return processor.processMessage(workContext.getRequestID(requestID), workContext, null, true);
 	}
 
@@ -734,21 +825,28 @@
 			boolean allowDoubleQuotedVariable)
 			throws MetaMatrixComponentException, MetaMatrixProcessingException {
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-		MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, this.environment, workContext.getVdbName(), workContext.getVdbVersion());
+		MetaDataProcessor processor = new MetaDataProcessor(this, this.prepPlanCache, workContext.getVdbName(), workContext.getVdbVersion());
 		return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
 	}
 	
-	public ApplicationEnvironment getEnvironment() {
-		return environment;
+	public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
+		this.connectorManagerRepository = repo;
 	}
 	
-	@Inject
-	public void setCacheFactory(CacheFactory cacheFactory) {
-		this.cacheFactory = cacheFactory;
-		this.environment.setCacheFactory(cacheFactory);
+	public ConnectorManagerRepository getConnectorManagerRepository() {
+		return this.connectorManagerRepository;
 	}
 	
-	public void setEnvironment(ApplicationEnvironment environment) {
-		this.environment = environment;
+	public void setSessionService(SessionService service) {
+		this.sessionService = service;
+		service.setDqp(this);
 	}
+	
+	public SessionService getSessionService() {
+		return this.sessionService;
+	}
+	
+	public AuthorizationService getAuthorizationService() {
+		return this.authorizationService;
+	}
 }
\ No newline at end of file

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,8 +24,11 @@
 
 import java.io.Serializable;
 
+import javax.security.auth.Subject;
+
+import org.teiid.adminapi.impl.VDBMetaData;
+
 import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
 import com.metamatrix.platform.security.api.SessionToken;
 
 public class DQPWorkContext implements Serializable {
@@ -45,14 +48,22 @@
 	public static void setWorkContext(DQPWorkContext context) {
 		CONTEXTS.set(context);
 	}
+
+	public static void releaseWorkContext() {
+		CONTEXTS.set(null);
+	}	
 	
-    private Serializable trustedPayload;
     private String vdbName;
-    private String vdbVersion;
+    private int vdbVersion;
     private String appName;
     private SessionToken sessionToken;
     private String clientAddress;
     private String clientHostname;
+    private Subject subject;
+	private String securityDomain;
+	private Object securityContext;
+	private VDBMetaData vdb;
+	private boolean admin;
     
     public DQPWorkContext() {
 	}
@@ -60,19 +71,20 @@
     /**
      * @return
      */
-    public Serializable getTrustedPayload() {
-        return trustedPayload;
-    }
-
-    /**
-     * @return
-     */
     public String getUserName() {
 		if (this.sessionToken == null) {
 			return null;
 		}
         return this.sessionToken.getUsername();
     }
+    
+    public Subject getSubject() {
+        return this.subject;
+    }
+    
+    public void setSubject(Subject subject) {
+        this.subject = subject;
+    }
 
     /**
      * @return
@@ -84,18 +96,11 @@
     /**
      * @return
      */
-    public String getVdbVersion() {
+    public int getVdbVersion() {
         return vdbVersion;
     }
 
     /**
-     * @param serializable
-     */
-    public void setTrustedPayload(Serializable trustedPayload) {
-        this.trustedPayload = trustedPayload;
-    }
-
-    /**
      * @param string
      */
     public void setVdbName(String vdbName) {
@@ -105,20 +110,17 @@
     /**
      * @param string
      */
-    public void setVdbVersion(String vdbVersion) {
+    public void setVdbVersion(int vdbVersion) {
         this.vdbVersion = vdbVersion;
     }
 
 	public String getConnectionID() {
-		if (this.sessionToken == null) {
-			return null;
-		}
-		return this.sessionToken.getSessionIDValue();
+		return String.valueOf(getSessionId());
 	}
 	
-	public MetaMatrixSessionID getSessionId() {
+	public long getSessionId() {
 		if (this.sessionToken == null) {
-			return null;
+			return -1;
 		}
 		return this.sessionToken.getSessionID();
 	}
@@ -162,8 +164,44 @@
 	public void reset() {
 		setSessionToken(null);
 		setAppName(null);
-		setTrustedPayload(null);
 		setVdbName(null);
-		setVdbVersion(null);
+		setVdbVersion(0);
+		setSecurityContext(null);
+		setSecurityDomain(null);
+		setVdb(null);
+		setSubject(null);
+		setSessionToken(null);
 	}
+
+	public void setSecurityDomain(String securityDomain) {
+		this.securityDomain = securityDomain;
+	}
+	
+	public String getSecurityDomain() {
+		return this.securityDomain;
+	}
+
+	public Object getSecurityContext() {
+		return this.securityContext;
+	}
+	
+	public void setSecurityContext(Object securityContext) {
+		this.securityContext = securityContext;
+	}
+
+	public void setVdb(VDBMetaData vdb) {
+		this.vdb = vdb;
+	}
+	
+	public VDBMetaData getVDB() {
+		return vdb;
+	}
+
+	public void markAsAdmin() {
+		this.admin = true;
+	}
+	
+	public boolean isAdmin() {
+		return this.admin;
+	}
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,22 +31,29 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
+import javax.resource.spi.work.WorkManager;
 import javax.sql.rowset.serial.SerialBlob;
 import javax.sql.rowset.serial.SerialClob;
 
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.language.SQLReservedWords;
 import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
 import org.teiid.connector.metadata.runtime.Column;
 import org.teiid.connector.metadata.runtime.Datatype;
 import org.teiid.connector.metadata.runtime.ForeignKey;
 import org.teiid.connector.metadata.runtime.KeyRecord;
+import org.teiid.connector.metadata.runtime.Procedure;
 import org.teiid.connector.metadata.runtime.ProcedureParameter;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
 import org.teiid.connector.metadata.runtime.Schema;
 import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 import org.teiid.dqp.internal.process.CodeTableCache.CacheKey;
 import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -54,33 +61,24 @@
 import com.metamatrix.common.buffer.TupleBatch;
 import com.metamatrix.common.buffer.TupleSource;
 import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
 import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.log.MessageLevel;
 import com.metamatrix.core.util.Assertion;
 import com.metamatrix.dqp.DQPPlugin;
 import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
 import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.metadata.runtime.api.MetadataSourceUtil;
 import com.metamatrix.query.processor.CollectionTupleSource;
 import com.metamatrix.query.processor.ProcessorDataManager;
 import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.lang.StoredProcedure;
 import com.metamatrix.query.sql.lang.UnaryFromClause;
+import com.metamatrix.query.sql.symbol.Constant;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 import com.metamatrix.query.util.CommandContext;
 
@@ -108,29 +106,28 @@
 	
 	// Resources
 	private DQPCore requestMgr;
-    private DataService dataService;
-    private VDBService vdbService;
     private BufferService bufferService;
-    private MetadataService metadataService;
+    private ConnectorManagerRepository connectorManagerRepository;
+    private WorkManager workManager;
 
 	// Processor state
     private CodeTableCache codeTableCache;
     
-    public DataTierManagerImpl(DQPCore requestMgr,
-        DataService dataService, VDBService vdbService, BufferService bufferService, MetadataService metadataService, 
-        int maxCodeTables, int maxCodeRecords, int maxCodeTableRecords) {
+    public DataTierManagerImpl(DQPCore requestMgr, ConnectorManagerRepository connectorRepo, BufferService bufferService, WorkManager wm, int maxCodeTables, int maxCodeRecords, int maxCodeTableRecords) {
 
 		this.requestMgr = requestMgr;
-        this.dataService = dataService;
-        this.vdbService = vdbService;
+        this.connectorManagerRepository = connectorRepo;
         this.bufferService = bufferService;
-        this.metadataService = metadataService;
+        this.workManager = wm;
 
         this.codeTableCache = new CodeTableCache(maxCodeTables, maxCodeRecords, maxCodeTableRecords);
 	}
+    
+    private ConnectorManager getCM(String connectorName) {
+    	return this.connectorManagerRepository.getConnectorManager(connectorName);
+    }
 
-	public TupleSource registerRequest(Object processorId, Command command,
-			String modelName, String connectorBindingId, int nodeID) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+	public TupleSource registerRequest(Object processorId, Command command, String modelName, String connectorBindingId, int nodeID) throws MetaMatrixComponentException, MetaMatrixProcessingException {
 		RequestWorkItem workItem = requestMgr.getRequestWorkItem((RequestID)processorId);
 		
 		if(CoreConstants.SYSTEM_MODEL.equals(modelName)) {
@@ -138,7 +135,7 @@
 		}
 		
 		AtomicRequestMessage aqr = createRequest(processorId, command, modelName, connectorBindingId, nodeID);
-        DataTierTupleSource tupleSource = new DataTierTupleSource(aqr.getCommand().getProjectedSymbols(), aqr, this, aqr.getConnectorID(), workItem);
+        DataTierTupleSource tupleSource = new DataTierTupleSource(aqr.getCommand().getProjectedSymbols(), aqr, this, aqr.getConnectorName(), workItem);
         tupleSource.open();
         return tupleSource;
 	}
@@ -154,8 +151,9 @@
 	private TupleSource processSystemQuery(Command command,
 			RequestWorkItem workItem) throws MetaMatrixComponentException {
 		String vdbName = workItem.getDqpWorkContext().getVdbName();
-		String vdbVersion = workItem.getDqpWorkContext().getVdbVersion();
-		CompositeMetadataStore metadata = this.metadataService.getMetadataObjectSource(vdbName, vdbVersion);
+		int vdbVersion = workItem.getDqpWorkContext().getVdbVersion();
+		VDBMetaData vdb = workItem.getDqpWorkContext().getVDB();
+		CompositeMetadataStore metadata = vdb.getAttachment(CompositeMetadataStore.class);
 		Collection rows = new ArrayList();
 		if (command instanceof Query) {
 			Query query = (Query)command;
@@ -175,27 +173,27 @@
 				rows.add(Arrays.asList(vdbName, vdbVersion));
 				break;
 			case SCHEMAS:
-				for (Schema model : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
+				for (Schema model : getVisibleSchemas(vdb, metadata)) {
 					rows.add(Arrays.asList(vdbName, model.getName(), model.isPhysical(), model.getUUID(), model.getAnnotation(), model.getPrimaryMetamodelUri()));
 				}
 				break;
 			case PROCEDURES:
-				for (Schema schema : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
-					for (ProcedureRecordImpl proc : schema.getProcedures().values()) {
-						rows.add(Arrays.asList(vdbName, proc.getSchema().getName(), proc.getName(), proc.getNameInSource(), proc.getResultSet() != null, proc.getUUID(), proc.getAnnotation()));
+				for (Schema schema : getVisibleSchemas(vdb, metadata)) {
+					for (Procedure proc : schema.getProcedures().values()) {
+						rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), proc.getNameInSource(), proc.getResultSet() != null, proc.getUUID(), proc.getAnnotation()));
 					}
 				}
 				break;
 			case PROCEDUREPARAMS:
-				for (Schema schema : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
-					for (ProcedureRecordImpl proc : schema.getProcedures().values()) {
+				for (Schema schema : getVisibleSchemas(vdb, metadata)) {
+					for (Procedure proc : schema.getProcedures().values()) {
 						for (ProcedureParameter param : proc.getParameters()) {
-							rows.add(Arrays.asList(vdbName, proc.getSchema().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), param.getType().toString(), param.isOptional(), 
+							rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), param.getType().toString(), param.isOptional(), 
 									param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID()));
 						}
 						if (proc.getResultSet() != null) {
 							for (Column param : proc.getResultSet().getColumns()) {
-								rows.add(Arrays.asList(vdbName, proc.getSchema().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), ProcedureParameter.Type.ResultSet.toString(), false, 
+								rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), ProcedureParameter.Type.ResultSet.toString(), false, 
 										param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID()));
 							}
 						}
@@ -205,7 +203,7 @@
 			case PROPERTIES: //TODO: consider storing separately in the metadatastore 
 				Collection<AbstractMetadataRecord> records = new LinkedHashSet<AbstractMetadataRecord>();
 				records.addAll(metadata.getDatatypes());
-				for (Schema schema : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
+				for (Schema schema : getVisibleSchemas(vdb, metadata)) {
 					records.add(schema);
 					records.addAll(schema.getTables().values());
 					for (Table table : schema.getTables().values()) {
@@ -213,7 +211,7 @@
 						records.addAll(table.getColumns());
 						records.addAll(table.getAllKeys());
 					}
-					for (ProcedureRecordImpl proc : schema.getProcedures().values()) {
+					for (Procedure proc : schema.getProcedures().values()) {
 						records.add(proc);
 						records.addAll(proc.getParameters());
 						if (proc.getResultSet() != null) {
@@ -228,7 +226,7 @@
 				}
 				break;
 			default:
-				for (Schema schema : getVisibleSchemas(vdbName, vdbVersion, metadata)) {
+				for (Schema schema : getVisibleSchemas(vdb, metadata)) {
 					for (Table table : schema.getTables().values()) {
 						switch (sysTable) {
 						case TABLES:
@@ -242,14 +240,14 @@
 								}
 								rows.add(Arrays.asList(vdbName, schema.getName(), table.getName(), column.getName(), column.getPosition(), column.getNameInSource(), 
 										column.getDatatype().getRuntimeTypeName(), column.getScale(), column.getLength(), column.isFixedLength(), column.isSelectable(), column.isUpdatable(),
-										column.isCaseSensitive(), column.isSigned(), column.isCurrency(), column.isAutoIncrementable(), column.getNullType().toString(), column.getMinValue(), 
-										column.getMaxValue(), column.getSearchType().toString(), column.getFormat(), column.getDefaultValue(), column.getDatatype().getJavaClassName(), column.getPrecision(), 
+										column.isCaseSensitive(), column.isSigned(), column.isCurrency(), column.isAutoIncremented(), column.getNullType().toString(), column.getMinimumValue(), 
+										column.getMaximumValue(), column.getSearchType().toString(), column.getFormat(), column.getDefaultValue(), column.getDatatype().getJavaClassName(), column.getPrecision(), 
 										column.getCharOctetLength(), column.getRadix(), column.getUUID(), column.getAnnotation()));
 							}
 							break;
 						case KEYS:
 							for (KeyRecord key : table.getAllKeys()) {
-								rows.add(Arrays.asList(vdbName, table.getSchema().getName(), table.getName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(), 
+								rows.add(Arrays.asList(vdbName, table.getParent().getName(), table.getName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(), 
 										false, (key instanceof ForeignKey)?((ForeignKey)key).getUniqueKeyID():null, key.getUUID()));
 							}
 							break;
@@ -266,8 +264,8 @@
 							for (ForeignKey key : table.getForeignKeys()) {
 								short postition = 0;
 								for (Column column : key.getColumns()) {
-									Table pkTable = key.getPrimaryKey().getTable();
-									rows.add(Arrays.asList(vdbName, pkTable.getSchema().getName(), pkTable.getName(), key.getPrimaryKey().getColumns().get(postition).getName(), vdbName, schema.getName(), table.getName(), column.getName(),
+									Table pkTable = key.getPrimaryKey().getParent();
+									rows.add(Arrays.asList(vdbName, pkTable.getParent().getName(), pkTable.getName(), key.getPrimaryKey().getColumns().get(postition).getName(), vdbName, schema.getName(), table.getName(), column.getName(),
 											++postition, DatabaseMetaData.importedKeyNoAction, DatabaseMetaData.importedKeyNoAction, key.getName(), key.getPrimaryKey().getName(), DatabaseMetaData.importedKeyInitiallyDeferred));
 								}
 							}
@@ -278,36 +276,36 @@
 				break;
 			}
 		} else {					
-			StoredProcedure proc = (StoredProcedure)command;
+			TransformationMetadata indexMetadata = vdb.getAttachment(TransformationMetadata.class);
+			StoredProcedure proc = (StoredProcedure)command;			
 			final SystemProcs sysTable = SystemProcs.valueOf(proc.getProcedureCallableName().substring(CoreConstants.SYSTEM_MODEL.length() + 1).toUpperCase());
 			switch (sysTable) {
 			case GETVDBRESOURCEPATHS:
-		        Set<String> filePaths = metadata.getMetadataSource().getEntries();
+		        String[] filePaths = indexMetadata.getVDBResourcePaths();
 		        for (String filePath : filePaths) {
-		        	if (vdbService.getFileVisibility(vdbName, vdbVersion, filePath) != ModelInfo.PUBLIC) {
-		        		continue;
-		        	}
 		        	rows.add(Arrays.asList(filePath, filePath.endsWith(".INDEX"))); //$NON-NLS-1$
 		        }
 				break;
 			case GETBINARYVDBRESOURCE:
-				String filePath = (String)proc.getParameter(0).getValue();
-				if (metadata.getMetadataSource().getEntries().contains(filePath) && vdbService.getFileVisibility(vdbName, vdbVersion, filePath) == ModelInfo.PUBLIC) {
+				String filePath = (String)((Constant)proc.getParameter(0).getExpression()).getValue();
+				byte[] contents = indexMetadata.getBinaryVDBResource(filePath);
+				if (contents != null) {
 					try {
-						rows.add(Arrays.asList(new SerialBlob(MetadataSourceUtil.getFileContentAsString(filePath, metadata.getMetadataSource()).getBytes())));
+						rows.add(Arrays.asList(new SerialBlob(contents)));
 					} catch (SQLException e) {
 						throw new MetaMatrixComponentException(e);
-					}
+					}					
 				}
 				break;
 			case GETCHARACTERVDBRESOURCE:
-				filePath = (String)proc.getParameter(0).getValue();
-				if (metadata.getMetadataSource().getEntries().contains(filePath) && vdbService.getFileVisibility(vdbName, vdbVersion, filePath) == ModelInfo.PUBLIC) {
+				filePath = (String)((Constant)proc.getParameter(0).getExpression()).getValue();
+				String filecontents = indexMetadata.getCharacterVDBResource(filePath);
+				if (filecontents != null) {
 					try {
-						rows.add(Arrays.asList(new SerialClob(MetadataSourceUtil.getFileContentAsString(filePath, metadata.getMetadataSource()).toCharArray())));
+						rows.add(Arrays.asList(new SerialClob(filecontents.toCharArray())));
 					} catch (SQLException e) {
 						throw new MetaMatrixComponentException(e);
-					}
+					}					
 				}
 				break;
 			}
@@ -315,10 +313,11 @@
 		return new CollectionTupleSource(rows.iterator(), command.getProjectedSymbols());
 	}
 	
-	private List<Schema> getVisibleSchemas(String vdbName, String vdbVersion, CompositeMetadataStore metadata) throws MetaMatrixComponentException {
+	private List<Schema> getVisibleSchemas(VDBMetaData vdb, CompositeMetadataStore metadata) {
 		ArrayList<Schema> result = new ArrayList<Schema>(); 
 		for (Schema schema : metadata.getSchemas().values()) {
-			if(vdbService.getModelVisibility(vdbName, vdbVersion, schema.getName()) == ModelInfo.PUBLIC) {
+			ModelMetaData model = vdb.getModel(schema.getName());
+			if(model.isVisible()) {
 				result.add(schema);
 			}
 		}
@@ -333,7 +332,6 @@
 	    RequestMessage request = workItem.requestMsg;
 		// build the atomic request based on original request + context info
         AtomicRequestMessage aqr = new AtomicRequestMessage(request, workItem.getDqpWorkContext(), nodeID);
-        aqr.markSubmissionStart();
         aqr.setCommand(command);
         aqr.setModelName(modelName);
         aqr.setUseResultSetCache(request.useResultSetCache());
@@ -343,57 +341,44 @@
         }
         aqr.setFetchSize(this.bufferService.getBufferManager().getConnectorBatchSize());
         if (connectorBindingId == null) {
-        	List bindings = vdbService.getConnectorBindingNames(workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion(), modelName);
+        	VDBMetaData vdb = workItem.getDqpWorkContext().getVDB();
+        	ModelMetaData model = vdb.getModel(modelName);
+        	List<String> bindings = model.getSourceNames();
 	        if (bindings == null || bindings.size() != 1) {
 	            // this should not happen, but it did occur when setting up the SystemAdmin models
 	            throw new MetaMatrixComponentException(DQPPlugin.Util.getString("DataTierManager.could_not_obtain_connector_binding", new Object[]{modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion() })); //$NON-NLS-1$
 	        }
-	        connectorBindingId = (String)bindings.get(0); 
+	        connectorBindingId = model.getSourceJndiName(bindings.get(0)); 
 	        Assertion.isNotNull(connectorBindingId, "could not obtain connector id"); //$NON-NLS-1$
         }
-        aqr.setConnectorBindingID(connectorBindingId);
-        // Select any connector instance for this connector binding
-        ConnectorID connectorID = this.dataService.selectConnector(connectorBindingId);
-        // if we had this as null before
-        aqr.setConnectorID(connectorID);
+        aqr.setConnectorName(connectorBindingId);
 		return aqr;
 	}
 	
-	String getConnectorName(String connectorBindingID) {
-        try {
-            return vdbService.getConnectorName(connectorBindingID);
-        } catch (MetaMatrixComponentException t) {
-            // OK
-        }
-        return connectorBindingID;
+	void executeRequest(AtomicRequestMessage aqr, String connectorName,ResultsReceiver<AtomicResultsMessage> receiver) throws MetaMatrixComponentException {
+		try {
+			getCM(connectorName).executeRequest(this.workManager, receiver, aqr);
+		} catch (ConnectorException e) {
+			throw new MetaMatrixComponentException(e);
+		}
 	}
+
+	public void closeRequest(AtomicRequestID request, String connectorName) {
+		getCM(connectorName).closeRequest(request);
+	}
 	
-	void executeRequest(AtomicRequestMessage aqr, ConnectorID connectorId,
-			ResultsReceiver<AtomicResultsMessage> receiver)
-			throws MetaMatrixComponentException {
-		this.dataService.executeRequest(aqr, connectorId, receiver);
+	public void cancelRequest(AtomicRequestID request, String connectorName) {
+		getCM(connectorName).cancelRequest(request);
 	}
 
-	public void closeRequest(AtomicRequestID request, ConnectorID connectorId) {
+	void requestBatch(AtomicRequestID request, String connectorName) throws MetaMatrixComponentException {
 		try {
-			this.dataService.closeRequest(request, connectorId);
-		} catch (MetaMatrixComponentException e) {
-			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-				LogManager.logDetail(LogConstants.CTX_DQP, e, e.getMessage());
-			}
+			getCM(connectorName).requstMore(request);
+		} catch (ConnectorException e) {
+			throw new MetaMatrixComponentException(e);
 		}
 	}
-	
-	public void cancelRequest(AtomicRequestID request, ConnectorID connectorId)
-		throws MetaMatrixComponentException {
-		this.dataService.cancelRequest(request, connectorId);
-	}
 
-	void requestBatch(AtomicRequestID request, ConnectorID connectorId)
-			throws MetaMatrixComponentException {
-		this.dataService.requestBatch(request, connectorId);
-	}
-
     /** 
      * Notify each waiting request that the code table data is now available.
      * @param requests
@@ -437,7 +422,7 @@
         String keyElementName)
         throws MetaMatrixComponentException, MetaMatrixProcessingException {
 
-        String query = ReservedWords.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + ReservedWords.FROM + ' ' + codeTableName; //$NON-NLS-1$ 
+        String query = SQLReservedWords.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + SQLReservedWords.FROM + ' ' + codeTableName; //$NON-NLS-1$ 
         
         final CacheKey codeRequestId = this.codeTableCache.createCacheRequest(codeTableName, returnElementName, keyElementName, context);
 
@@ -465,5 +450,5 @@
     public void clearCodeTables() {
         this.codeTableCache.clearAll();
     }
-
+    
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,7 +31,6 @@
 import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.core.util.Assertion;
 import com.metamatrix.dqp.exception.SourceWarning;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
 
@@ -45,7 +44,7 @@
     private final List schema;
     private final AtomicRequestMessage aqr;
     private final DataTierManagerImpl dataMgr;
-    private final ConnectorID connectorId;
+    private final String connectorName;
     private final RequestWorkItem workItem;
     
     // Data state
@@ -64,11 +63,11 @@
     /**
      * Constructor for DataTierTupleSource.
      */
-    public DataTierTupleSource(List schema, AtomicRequestMessage aqr, DataTierManagerImpl dataMgr, ConnectorID connectorID, RequestWorkItem workItem) {
+    public DataTierTupleSource(List schema, AtomicRequestMessage aqr, DataTierManagerImpl dataMgr, String connectorName, RequestWorkItem workItem) {
         this.schema = schema;       
         this.aqr = aqr;
         this.dataMgr = dataMgr;
-        this.connectorId = connectorID;
+        this.connectorName = connectorName;
         this.workItem = workItem;
     }
 
@@ -104,9 +103,9 @@
         synchronized (this) {
         	this.waitingForData = true;
 	        try {
-	        	this.dataMgr.executeRequest(aqr, this.connectorId, this);
+	        	this.dataMgr.executeRequest(aqr, this.connectorName, this);
 	        } catch (MetaMatrixComponentException e) {
-	        	exceptionOccurred(e);
+	        	exceptionOccurred(e, true);
 	        }
         }
     }
@@ -139,7 +138,7 @@
         } 
         // Request the next batch immediately
         if (!this.isLast && !waitingForData) {
-            this.dataMgr.requestBatch(this.aqr.getAtomicRequestID(), connectorId);
+            this.dataMgr.requestBatch(this.aqr.getAtomicRequestID(), this.connectorName);
             
             // update waitingForData
             this.waitingForData = true;
@@ -150,11 +149,11 @@
     }
     
     public void fullyCloseSource() {
-    	this.dataMgr.closeRequest(aqr.getAtomicRequestID(), connectorId);
+    	this.dataMgr.closeRequest(aqr.getAtomicRequestID(), this.connectorName);
     }
     
     public void cancelRequest() throws MetaMatrixComponentException {
-    	this.dataMgr.cancelRequest(aqr.getAtomicRequestID(), connectorId);
+    	this.dataMgr.cancelRequest(aqr.getAtomicRequestID(), this.connectorName);
     }
 
     /**
@@ -162,24 +161,30 @@
      */
     public void closeSource() {
     	if (this.supportsImplicitClose) {
-    		this.dataMgr.closeRequest(aqr.getAtomicRequestID(), connectorId);
+    		this.dataMgr.closeRequest(aqr.getAtomicRequestID(), this.connectorName);
     	}
     }
 
 	public void exceptionOccurred(Throwable e) {
+		exceptionOccurred(e, false);
+	}
+    
+    private void exceptionOccurred(Throwable e, boolean removeState) {
+    
 		synchronized (this) {
 			if(workItem.requestMsg.supportsPartialResults()) {
 				nextBatch = new List[0];
 				nextBatchIsLast = true;
-		        String connectorBindingName = dataMgr.getConnectorName(aqr.getConnectorBindingID());
-		        SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), connectorBindingName, e, true);
+		        SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), aqr.getConnectorName(), e, true);
 		        workItem.addSourceFailureDetails(sourceFailure);
 			} else {
 				this.exception = e;
 			}	
 			waitingForData = false;
 		}
-		workItem.closeAtomicRequest(aqr.getAtomicRequestID());
+		if (removeState) {
+			workItem.closeAtomicRequest(aqr.getAtomicRequestID());
+		}
 		this.workItem.moreWork();
 	}
 
@@ -201,9 +206,8 @@
 	        waitingForData = false;
 		}
 		if (response.getWarnings() != null) {
-	        String connectorBindingName = dataMgr.getConnectorName(aqr.getConnectorBindingID());
 			for (Exception warning : response.getWarnings()) {
-				SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), connectorBindingName, warning, true);
+				SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), aqr.getConnectorName(), warning, true);
 		        workItem.addSourceFailureDetails(sourceFailure);
 			}
 		}
@@ -217,8 +221,8 @@
 		return aqr;
 	}
 
-	public ConnectorID getConnectorId() {
-		return connectorId;
+	public String getConnectorName() {
+		return this.connectorName;
 	}
 	
 	public boolean isTransactional() {

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,6 +26,8 @@
 import java.nio.charset.Charset;
 import java.sql.SQLException;
 
+import javax.resource.spi.work.Work;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.common.lob.ByteLobChunkStream;
@@ -40,7 +42,7 @@
 import com.metamatrix.dqp.DQPPlugin;
 import com.metamatrix.dqp.util.LogConstants;
 
-public class LobWorkItem implements Runnable {
+public class LobWorkItem implements Work {
 	
 	private RequestWorkItem parent;
 	private int chunkSize; 
@@ -133,4 +135,9 @@
     	Assertion.isNull(this.resultsReceiver, "Cannot request results with a pending request"); //$NON-NLS-1$
     	this.resultsReceiver = resultsReceiver;
     }
+
+	@Override
+	public void release() {
+		
+	}
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,13 +22,14 @@
 
 package org.teiid.dqp.internal.process;
 
-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 java.util.Set;
 
+import org.teiid.connector.language.SQLReservedWords;
 import org.teiid.dqp.internal.process.DQPCore.ClientState;
 import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
 import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
@@ -38,16 +39,12 @@
 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.application.ApplicationEnvironment;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.common.types.XMLType;
 import com.metamatrix.dqp.client.MetadataResult;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
 import com.metamatrix.dqp.metadata.ResultsMetadataDefaults;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.VDBService;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.metadata.SupportConstants;
@@ -56,7 +53,6 @@
 import com.metamatrix.query.parser.ParseInfo;
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.lang.XQuery;
@@ -75,22 +71,17 @@
 public class MetaDataProcessor {
 
     // Resources
-    private MetadataService metadataService;
     private DQPCore requestManager;
     private QueryMetadataInterface metadata;
     private SessionAwareCache<PreparedPlan> planCache;
-    private ApplicationEnvironment env;
         
     private String vdbName;
-    private String vdbVersion;
+    private int vdbVersion;
     private RequestID requestID;
     
-    
-    public MetaDataProcessor(MetadataService metadataService, DQPCore requestManager, SessionAwareCache<PreparedPlan> planCache, ApplicationEnvironment env, String vdbName, String vdbVersion) {
-        this.metadataService = metadataService;    
+    public MetaDataProcessor(DQPCore requestManager, SessionAwareCache<PreparedPlan> planCache, String vdbName, int vdbVersion) {
         this.requestManager = requestManager;
         this.planCache = planCache;
-        this.env = env;
         this.vdbName = vdbName;
         this.vdbVersion = vdbVersion;
     }
@@ -105,13 +96,12 @@
      * @throws MetaMatrixProcessingException 
      */
     MetadataResult processMessage(RequestID requestId, DQPWorkContext workContext, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException {
-        final VDBService vdbService = (VDBService)env.findService(DQPServiceNames.VDB_SERVICE);
         this.requestID = requestId;
         
-        this.metadata = metadataService.lookupMetadata(vdbName, vdbVersion);
+        this.metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
         
         // If multi-source, use the multi-source wrapper as well
-        Collection multiModels = vdbService.getMultiSourceModels(vdbName, vdbVersion);
+        Set<String> multiModels = workContext.getVDB().getMultiSourceModelNames();
         if(multiModels != null && multiModels.size() > 0) { 
             this.metadata = new MultiSourceMetadataWrapper(this.metadata, multiModels);
         }
@@ -325,7 +315,7 @@
         
         Expression expression = symbol.getExpression();
         String function = symbol.getAggregateFunction();
-        if(function.equals(ReservedWords.MIN) || function.equals(ReservedWords.MAX)){
+        if(function.equals(SQLReservedWords.MIN) || function.equals(SQLReservedWords.MAX)){
             if(expression instanceof ElementSymbol) {
                 return createColumnMetadata(shortColumnName, (ElementSymbol)expression);
             }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -41,6 +41,7 @@
 import com.metamatrix.dqp.util.LogConstants;
 import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.eval.Evaluator;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.batch.BatchedUpdatePlanner;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
 import com.metamatrix.query.processor.ProcessorPlan;
@@ -102,7 +103,7 @@
 		List<SPParameter> spParams = proc.getParameters();
 		proc.clearParameters();
 		int inParameterCount = values.size();
-		if (this.requestMsg.isPreparedBatchUpdate() && values.size() > 0) {
+		if (this.requestMsg.isBatchedUpdate() && values.size() > 0) {
 			inParameterCount = ((List)values.get(0)).size();
 		}
 		int index = 1;
@@ -160,13 +161,13 @@
             createCommandContext();
         }
                 
-        if (requestMsg.isPreparedBatchUpdate()) {
+        if (requestMsg.isBatchedUpdate()) {
 	        handlePreparedBatchUpdate();
         } else {
 	        List<Reference> params = prepPlan.getReferences();
 	        List<?> values = requestMsg.getParameterValues();
 	
-	    	PreparedStatementRequest.resolveParameterValues(params, values, this.context);
+	    	PreparedStatementRequest.resolveParameterValues(params, values, this.context, this.metadata);
         }
     }
 
@@ -185,7 +186,7 @@
      */
 	private void handlePreparedBatchUpdate() throws QueryMetadataException,
 			MetaMatrixComponentException, QueryResolverException, QueryPlannerException, QueryValidatorException {
-		List<List<?>> paramValues = requestMsg.getParameterValues();
+		List<List<?>> paramValues = (List<List<?>>) requestMsg.getParameterValues();
 		if (paramValues.isEmpty()) {
 			throw new QueryValidatorException("No batch values sent for prepared batch update"); //$NON-NLS-1$
 		}
@@ -205,7 +206,7 @@
 		List<VariableContext> contexts = new LinkedList<VariableContext>();
 		List<List<Object>> multiValues = new ArrayList<List<Object>>(this.prepPlan.getReferences().size());
 		for (List<?> values : paramValues) {
-	    	PreparedStatementRequest.resolveParameterValues(this.prepPlan.getReferences(), values, this.context);
+	    	PreparedStatementRequest.resolveParameterValues(this.prepPlan.getReferences(), values, this.context, this.metadata);
 			contexts.add(this.context.getVariableContext());
 			if(supportPreparedBatchUpdate){
 				if (multiValues.isEmpty()) {
@@ -256,7 +257,7 @@
 	 * @throws QueryValidatorException 
 	 */
 	public static void resolveParameterValues(List<Reference> params,
-	                                    List values, CommandContext context) throws QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
+	                                    List values, CommandContext context, QueryMetadataInterface metadata) throws QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
 		VariableContext result = new VariableContext();
 	    //the size of the values must be the same as that of the parameters
 	    if (params.size() != values.size()) {
@@ -274,7 +275,7 @@
         	if(value != null && !(value instanceof List)) {
                 try {
                     String targetTypeName = DataTypeManager.getDataTypeName(param.getType());
-                    Expression expr = ResolverUtil.convertExpression(new Constant(value), targetTypeName);
+                    Expression expr = ResolverUtil.convertExpression(new Constant(value), targetTypeName, metadata);
                     value = Evaluator.evaluate(expr);
 				} catch (ExpressionEvaluationException e) {
                     String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,15 +24,12 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
-import javax.transaction.SystemException;
-
-import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
 import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
 import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
@@ -45,7 +42,6 @@
 import com.metamatrix.api.exception.query.QueryPlannerException;
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.application.ApplicationEnvironment;
 import com.metamatrix.common.buffer.BufferManager;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.types.DataTypeManager;
@@ -56,16 +52,13 @@
 import com.metamatrix.dqp.DQPPlugin;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
 import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.VDBService;
 import com.metamatrix.dqp.util.LogConstants;
 import com.metamatrix.jdbc.api.ExecutionProperties;
 import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.eval.SecurityFunctionEvaluator;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.metadata.TempMetadataAdapter;
 import com.metamatrix.query.metadata.TempMetadataStore;
@@ -110,12 +103,11 @@
 	// init state
     protected RequestMessage requestMsg;
     private String vdbName;
-    private String vdbVersion;
-    private ApplicationEnvironment env;
-    private VDBService vdbService;
+    private int vdbVersion;
     private BufferManager bufferManager;
     private ProcessorDataManager processorDataManager;
     private TransactionService transactionService;
+    private AuthorizationService authService;
     private TempTableStore tempTableStore;
     protected IDGenerator idGenerator = new IDGenerator();
     private boolean procDebugAllowed = false;
@@ -125,7 +117,7 @@
     // acquired state
     protected CapabilitiesFinder capabilitiesFinder;
     protected QueryMetadataInterface metadata;
-    private Set multiSourceModels;
+    private Set<String> multiSourceModels;
 
     // internal results
     protected boolean addedLimit;
@@ -137,36 +129,37 @@
     protected List schemas;
     
     protected TransactionContext transactionContext;
-    
+    protected ConnectorManagerRepository connectorManagerRepo; 
     private int chunkSize;
     
     protected Command userCommand;
     protected boolean returnsUpdateCount;
 
     void initialize(RequestMessage requestMsg,
-                              ApplicationEnvironment env,
                               BufferManager bufferManager,
                               ProcessorDataManager processorDataManager,
                               TransactionService transactionService,
+                              AuthorizationService authService,
                               boolean procDebugAllowed,
                               TempTableStore tempTableStore,
                               DQPWorkContext workContext,
-                              int chunckSize) {
+                              int chunckSize,
+                              ConnectorManagerRepository repo) {
 
         this.requestMsg = requestMsg;
         this.vdbName = workContext.getVdbName();        
         this.vdbVersion = workContext.getVdbVersion();
-        this.env = env;
-        this.vdbService = (VDBService) env.findService(DQPServiceNames.VDB_SERVICE);
         this.bufferManager = bufferManager;
         this.processorDataManager = processorDataManager;
         this.transactionService = transactionService;
+        this.authService = authService;
         this.procDebugAllowed = procDebugAllowed;
         this.tempTableStore = tempTableStore;
         idGenerator.setDefaultFactory(new IntegerIDFactory());
         this.workContext = workContext;
         this.requestId = workContext.getRequestID(this.requestMsg.getExecutionId());
         this.chunkSize = chunckSize;
+        this.connectorManagerRepo = repo;
     }
     
 	void setMetadata(CapabilitiesFinder capabilitiesFinder, QueryMetadataInterface metadata, Set multiSourceModels) {
@@ -185,25 +178,11 @@
         	return;
         }
     	// Prepare dependencies for running the optimizer        
-        this.capabilitiesFinder =
-            new CachedFinder(
-                (DataService) this.env.findService(DQPServiceNames.DATA_SERVICE),
-                requestMsg,
-                workContext);        
+        this.capabilitiesFinder = new CachedFinder(this.connectorManagerRepo, workContext.getVDB());        
         
-        MetadataService metadataService = (MetadataService) this.env.findService(DQPServiceNames.METADATA_SERVICE);
-        if(metadataService == null){
-        	//should not come here. Per defect 15087, 
-        	//in a rare situation it might be null
-        	//try to get it again
-        	metadataService = (MetadataService) this.env.findService(DQPServiceNames.METADATA_SERVICE);
-        	if(metadataService == null){
-	        	String msg = DQPPlugin.Util.getString("Request.MetadataServiceIsNull"); //$NON-NLS-1$
-                throw new MetaMatrixComponentException(msg);
-        	}
-        }
-        metadata = metadataService.lookupMetadata(vdbName, vdbVersion);            
 
+        metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
+
         if (metadata == null) {
             throw new MetaMatrixComponentException(DQPPlugin.Util.getString("DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}", this.vdbName, this.vdbVersion)); //$NON-NLS-1$
         }
@@ -211,9 +190,9 @@
         this.metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
     
         // Check for multi-source models and further wrap the metadata interface
-        List multiSourceModelList = vdbService.getMultiSourceModels(this.vdbName, this.vdbVersion);
+        Set<String> multiSourceModelList = workContext.getVDB().getMultiSourceModelNames();
         if(multiSourceModelList != null && multiSourceModelList.size() > 0) {
-        	this.multiSourceModels = new HashSet(multiSourceModelList);
+        	this.multiSourceModels = multiSourceModelList;
             this.metadata = new MultiSourceMetadataWrapper(this.metadata, this.multiSourceModels);
         }
     }
@@ -236,8 +215,9 @@
         	StoredProcedure proc = (StoredProcedure)userCommand;
         	returnsResultSet = proc.returnsResultSet();
         }
-    	if (this.requestMsg.getRequireResultSet() != null && this.requestMsg.getRequireResultSet() != returnsResultSet) {
-        	throw new QueryValidatorException(DQPPlugin.Util.getString(this.requestMsg.getRequireResultSet()?"Request.no_result_set":"Request.result_set")); //$NON-NLS-1$ //$NON-NLS-2$
+    	if ((this.requestMsg.getResultsMode() == ResultsMode.UPDATECOUNT && !returnsUpdateCount) 
+    			|| (this.requestMsg.getResultsMode() == ResultsMode.RESULTSET && !returnsResultSet)) {
+        	throw new QueryValidatorException(DQPPlugin.Util.getString(this.requestMsg.getResultsMode()==ResultsMode.RESULTSET?"Request.no_result_set":"Request.result_set")); //$NON-NLS-1$ //$NON-NLS-2$
     	}
 
     	// Create command context, used in rewriting, planning, and processing
@@ -268,13 +248,14 @@
         if (multiSourceModels != null) {
             MultiSourcePlanToProcessConverter modifier = new MultiSourcePlanToProcessConverter(
 					metadata, idGenerator, analysisRecord, capabilitiesFinder,
-					multiSourceModels, vdbName, vdbService, vdbVersion, context);
+					multiSourceModels, workContext, context);
             context.setPlanToProcessConverter(modifier);
         }
 
-        context.setSecurityFunctionEvaluator((SecurityFunctionEvaluator)this.env.findService(DQPServiceNames.AUTHORIZATION_SERVICE));
+        context.setSecurityFunctionEvaluator(this.authService);
         context.setTempTableStore(tempTableStore);
         context.setQueryProcessorFactory(this);
+        context.setMetadata(this.metadata);
     }
 
     protected void checkReferences(List<Reference> references) throws QueryValidatorException {
@@ -309,7 +290,7 @@
     private Command parseCommand() throws QueryParserException {
         String[] commands = requestMsg.getCommands();
         ParseInfo parseInfo = createParseInfo(this.requestMsg);
-        if (!requestMsg.isBatchedUpdate()) {
+        if (requestMsg.isPreparedStatement() || requestMsg.isCallableStatement() || !requestMsg.isBatchedUpdate()) {
         	String commandStr = commands[0];
             return QueryParser.getQueryParser().parseCommand(commandStr, parseInfo);
         } 
@@ -352,9 +333,9 @@
         if (tc != null){ 
             Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST, "Transaction already associated with request."); //$NON-NLS-1$
         }
-        
-        if (tc == null || !tc.isInTransaction()) {
-            //if not under a transaction
+
+        // If local or global transaction is not started.
+        if (tc == null || tc.getXid() == null) {
             
             boolean startAutoWrapTxn = false;
             
@@ -376,8 +357,6 @@
                     tc = transactionService.start(tc);
                 } catch (XATransactionException err) {
                     throw new MetaMatrixComponentException(err);
-                } catch (SystemException err) {
-                    throw new MetaMatrixComponentException(err);
                 }
             }
         } 
@@ -592,13 +571,9 @@
         return new QueryProcessor(plan, copy, bufferManager, processorDataManager);
 	}
 
-	protected void validateAccess(Command command)
-			throws QueryValidatorException, MetaMatrixComponentException {
-		// Validate the query (may only want to validate entitlement)
-		AuthorizationService authSvc = (AuthorizationService) this.env.findService(DQPServiceNames.AUTHORIZATION_SERVICE);
-
+	protected void validateAccess(Command command) throws QueryValidatorException, MetaMatrixComponentException {
 		// See if entitlement checking is turned on
-		AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.workContext.getConnectionID(), authSvc, this.vdbService, this.vdbName, this.vdbVersion);
+		AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.authService, this.workContext.getVDB());
 		validateWithVisitor(visitor, this.metadata, command);
 	}
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -33,10 +33,6 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
-
-import org.teiid.connector.xa.api.TransactionContext;
 import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -60,6 +56,7 @@
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.ResultsMessage;
 import com.metamatrix.dqp.service.CommandLogMessage;
+import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.dqp.service.TransactionService;
 import com.metamatrix.dqp.util.LogConstants;
 import com.metamatrix.query.analysis.AnalysisRecord;
@@ -85,7 +82,7 @@
 	/*
 	 * Obtained at construction time 
 	 */
-    private final DQPCore dqpCore;
+	protected final DQPCore dqpCore;
     final RequestMessage requestMsg;    
     final RequestID requestID;
     private Request request; //provides the processing plan, held on a temporary basis
@@ -123,11 +120,14 @@
     private TupleBatch savedBatch;
     private Map<Integer, LobWorkItem> lobStreams = Collections.synchronizedMap(new HashMap<Integer, LobWorkItem>(4));
     
+    /**The time when command begins processing on the server.*/
+    private long processingTimestamp = System.currentTimeMillis();
+    
     public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext) {
         this.requestMsg = requestMsg;
         this.requestID = requestID;
         this.processorTimeslice = dqpCore.getProcessorTimeSlice();
-        this.transactionService = dqpCore.getTransactionServiceDirect();
+        this.transactionService = dqpCore.getTransactionService();
         this.dqpCore = dqpCore;
         this.request = request;
         this.dqpWorkContext = workContext;
@@ -221,11 +221,12 @@
         			this.processingException = new IllegalStateException("Request is already closed"); //$NON-NLS-1$
         		}
         		sendError();
-        	}        	    		        	
+        	}        
+        	DQPWorkContext.releaseWorkContext();
         }
     }
 
-	protected void processMore() throws SystemException, BlockedException, MetaMatrixCoreException {
+	protected void processMore() throws BlockedException, MetaMatrixCoreException {
 		if (this.processor != null) {
 			this.processor.getContext().setTimeSliceEnd(System.currentTimeMillis() + this.processorTimeslice);
 		}
@@ -315,9 +316,7 @@
         		this.transactionService.rollback(transactionContext);
             } catch (XATransactionException e1) {
                 LogManager.logWarning(LogConstants.CTX_DQP, e1, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$           
-            } catch (SystemException err) {
-                LogManager.logWarning(LogConstants.CTX_DQP, err, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$
-            }
+            } 
 		}
 		
 		isClosed = true;
@@ -361,7 +360,7 @@
 		resultsBuffer.setForwardOnly(isForwardOnly());
 		analysisRecord = request.analysisRecord;
 		transactionContext = request.transactionContext;
-		if (this.transactionContext != null && this.transactionContext.isInTransaction()) {
+		if (this.transactionContext != null && this.transactionContext.getXid() != null) {
 			this.transactionState = TransactionState.ACTIVE;
 		}
 	    if (analysisRecord.recordQueryPlan()) {
@@ -570,9 +569,8 @@
 	            if (transactionService != null) {
 	                try {
 	                    transactionService.cancelTransactions(requestID.getConnectionID(), true);
-	                } catch (InvalidTransactionException err) {
+	                } catch (XATransactionException err) {
 	                    LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + requestID.getConnectionID()); //$NON-NLS-1$
-	                } catch (SystemException err) {
 	                    throw new MetaMatrixComponentException(err);
 	                }
 	            }
@@ -643,8 +641,8 @@
      */
     private void logCommandError() {
         String transactionID = null;
-        if (this.transactionContext != null && this.transactionContext.isInTransaction()) {
-            transactionID = this.transactionContext.getTxnID();
+        if (this.transactionContext != null && this.transactionContext.getXid() != null) {
+            transactionID = this.transactionContext.getXid().toString();
         }
         CommandLogMessage message = new CommandLogMessage(System.currentTimeMillis(), requestID.toString(), transactionID == null ? null : transactionID, requestID.getConnectionID(), dqpWorkContext.getUserName(), dqpWorkContext.getVdbName(), dqpWorkContext.getVdbVersion(), -1, false, true);
         LogManager.log(MessageLevel.INFO, LogConstants.CTX_COMMANDLOGGING, message);
@@ -672,9 +670,6 @@
 		return transactionContext;
 	}
 	
-	void setTransactionContext(TransactionContext transactionContext) {
-		this.transactionContext = transactionContext;
-	}
 	
 	Collection<DataTierTupleSource> getConnectorRequests() {
 		return new LinkedList<DataTierTupleSource>(this.connectorInfo.values());
@@ -696,5 +691,23 @@
 	public DQPWorkContext getDqpWorkContext() {
 		return dqpWorkContext;
 	}
-
+	
+	public long getProcessingTimestamp() {
+		return processingTimestamp;
+	}
+	
+	@Override
+    protected boolean assosiateSecurityContext() {
+		if (dqpWorkContext.getSubject() != null) {
+        	return dqpCore.getSecurityHelper().assosiateSecurityContext(dqpWorkContext.getSecurityDomain(),dqpWorkContext.getSecurityContext());			
+		}
+		return false;
+	}
+    
+	@Override
+    protected void clearSecurityContext() {
+		if (dqpWorkContext.getSubject() != null) {
+        	dqpCore.getSecurityHelper().clearSecurityContext(dqpWorkContext.getSecurityDomain());			
+		}
+	}
 }
\ No newline at end of file

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Util.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.process;
-
-import com.metamatrix.admin.objects.MMQueueWorkerPool;
-import com.metamatrix.common.queue.WorkerPoolStats;
-
-public class Util {
-
-	public static MMQueueWorkerPool convertStats(final WorkerPoolStats src, String ... identifier) {        
-	    MMQueueWorkerPool pool = new MMQueueWorkerPool(identifier); 
-	    pool.setRegistered(true);
-	    pool.setQueued(src.getQueued());
-	    pool.setThreads(src.getActiveThreads());
-	    pool.setHighestQueued(src.getHighestQueued());
-	    pool.setHighestThreads(src.getHighestActiveThreads());
-	    pool.setTotalCompleted(src.getTotalCompleted());
-	    pool.setTotalSubmitted(src.getTotalSubmitted());
-	    return pool;
-	}
-
-}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,10 +23,10 @@
 package org.teiid.dqp.internal.process.multisource;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -41,9 +41,9 @@
  */
 public class MultiSourceMetadataWrapper extends BasicQueryMetadataWrapper {
 	
-    private Collection multiSourceModels;
+    private Set<String> multiSourceModels;
     
-    public MultiSourceMetadataWrapper(QueryMetadataInterface actualMetadata, Collection multiSourceModels){
+    public MultiSourceMetadataWrapper(QueryMetadataInterface actualMetadata, Set<String> multiSourceModels){
     	super(actualMetadata);
         this.multiSourceModels = multiSourceModels;
     }	

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,16 +23,18 @@
 package org.teiid.dqp.internal.process.multisource;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.CriteriaEvaluationException;
 import com.metamatrix.api.exception.query.QueryPlannerException;
 import com.metamatrix.api.exception.query.QueryValidatorException;
 import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.dqp.service.VDBService;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
@@ -51,19 +53,15 @@
 public class MultiSourcePlanToProcessConverter extends PlanToProcessConverter {
 	
 	private Set<String> multiSourceModels;
-	private String vdbName;
-	private String vdbVersion;
-	private VDBService vdbService;
+	private DQPWorkContext workContext;
 	
 	public MultiSourcePlanToProcessConverter(QueryMetadataInterface metadata,
 			IDGenerator idGenerator, AnalysisRecord analysisRecord,
 			CapabilitiesFinder capFinder, Set<String> multiSourceModels,
-			String vdbName, VDBService vdbService, String vdbVersion, CommandContext context) {
+			DQPWorkContext workContext, CommandContext context) {
 		super(metadata, idGenerator, analysisRecord, capFinder);
 		this.multiSourceModels = multiSourceModels;
-		this.vdbName = vdbName;
-		this.vdbService = vdbService;
-		this.vdbVersion = vdbVersion;
+		this.workContext = workContext;
 	}
 
 	protected RelationalNode convertNode(PlanNode planNode) throws QueryPlannerException, MetaMatrixComponentException {
@@ -86,24 +84,23 @@
 		if(!this.multiSourceModels.contains(modelName)) {
             return accessNode;
         }
-        List bindings = vdbService.getConnectorBindingNames(vdbName, vdbVersion, modelName);
-        List<AccessNode> accessNodes = new ArrayList<AccessNode>(bindings.size());
-        Iterator bindingIter = bindings.iterator();
         
-        while(bindingIter.hasNext()) {
-            String bindingUUID = (String) bindingIter.next();
-            String bindingName = vdbService.getConnectorName(bindingUUID);
+		VDBMetaData vdb = workContext.getVDB();
+        ModelMetaData model = vdb.getModel(modelName);
+        List<AccessNode> accessNodes = new ArrayList<AccessNode>();
+        
+        for(String sourceName:model.getSourceNames()) {
             
             // Create a new cloned version of the access node and set it's model name to be the bindingUUID
             AccessNode instanceNode = (AccessNode) accessNode.clone();
             instanceNode.setID(getID());
-            instanceNode.setConnectorBindingId(bindingUUID);
+            instanceNode.setConnectorBindingId(model.getSourceJndiName(sourceName));
             
             // Modify the command to pull the instance column and evaluate the criteria
             Command command = (Command)instanceNode.getCommand().clone();
             
             // Replace all multi-source elements with the source name
-            DeepPreOrderNavigator.doVisit(command, new MultiSourceElementReplacementVisitor(bindingName));
+            DeepPreOrderNavigator.doVisit(command, new MultiSourceElementReplacementVisitor(sourceName));
 
             // Rewrite the command now that criteria may have been simplified
             try {

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,15 +31,16 @@
 import java.util.List;
 import java.util.Map;
 
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.process.DQPWorkContext;
 import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.vdb.api.ModelInfo;
 import com.metamatrix.dqp.DQPPlugin;
 import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.VDBService;
 import com.metamatrix.query.function.FunctionLibrary;
 import com.metamatrix.query.metadata.TempMetadataID;
 import com.metamatrix.query.resolver.util.ResolverUtil;
@@ -59,23 +60,12 @@
 
 public class AuthorizationValidationVisitor extends AbstractValidationVisitor {
 
-    private String connectionID;
     private AuthorizationService authInterface;
-    private VDBService vdbService;
-    private String vdbName;
-    private String vdbVersion;
+    private VDBMetaData vdb;
 
-    public AuthorizationValidationVisitor(
-        String connectionID,
-        AuthorizationService authInterface,
-        VDBService vdbService,
-        String vdbName,
-        String vdbVersion) {
-        this.connectionID = connectionID;
+    public AuthorizationValidationVisitor(AuthorizationService authInterface, VDBMetaData vdb) {
         this.authInterface = authInterface;
-        this.vdbService = vdbService;
-        this.vdbName = vdbName;
-        this.vdbVersion = vdbVersion;
+        this.vdb = vdb;
     }
 
     // ############### Visitor methods for language objects ##################
@@ -281,7 +271,7 @@
 
         if (!nameToSymbolMap.isEmpty()) {
             try {
-                Collection inaccessibleResources = this.authInterface.getInaccessibleResources(connectionID, actionCode, nameToSymbolMap.keySet(), auditContext);
+                Collection inaccessibleResources = this.authInterface.getInaccessibleResources(actionCode, nameToSymbolMap.keySet(), auditContext);
                 if(inaccessibleResources.size() > 0) {                              
                     List inaccessibleSymbols = new ArrayList(inaccessibleResources.size());
                     Iterator nameIter = inaccessibleResources.iterator();
@@ -294,7 +284,7 @@
                     // is not authorized in the exception message
                     
                     handleValidationError(
-                        DQPPlugin.Util.getString("ERR.018.005.0095", new Object[]{this.connectionID, getActionLabel(actionCode)}), //$NON-NLS-1$                    
+                        DQPPlugin.Util.getString("ERR.018.005.0095", new Object[]{DQPWorkContext.getWorkContext().getConnectionID(), getActionLabel(actionCode)}), //$NON-NLS-1$                    
                         inaccessibleSymbols);
                 }
             } catch(MetaMatrixComponentException e) {
@@ -310,8 +300,8 @@
         }
         try {
 		    String modelName = getMetadata().getFullName(modelID);
-		    int visibility = this.vdbService.getModelVisibility(this.vdbName, this.vdbVersion, modelName);
-		    if(visibility != ModelInfo.PUBLIC) {
+		    ModelMetaData model = vdb.getModel(modelName);
+		    if(!model.isVisible()) {
 		        handleValidationError(DQPPlugin.Util.getString("ERR.018.005.0088", getMetadata().getFullName(group.getMetadataID()))); //$NON-NLS-1$
 		    }
         } catch (MetaMatrixComponentException e) {

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.transaction;
+
+import javax.resource.spi.XATerminator;
+
+public class ContainerTransactionProvider implements TransactionProvider {
+	XATerminator terminator;
+		
+	public ContainerTransactionProvider(XATerminator terminator) {
+		this.terminator = terminator;
+	}
+
+	@Override
+	public XATerminator getXATerminator() {
+		return terminator;
+	}
+}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.transaction;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.transaction.Transaction;
-import javax.transaction.xa.XAResource;
-
-import org.teiid.connector.xa.api.TransactionContext;
-
-import com.metamatrix.common.xa.MMXid;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.DQPPlugin;
-
-class TransactionContextImpl implements
-                              TransactionContext, Externalizable {
-
-    private String threadId;
-    private MMXid xid;
-    private String txnID;
-    private Transaction transaction;
-    private Scope transactionType = Scope.NONE;
-    private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
-    private int transactionTimeout = -1;
-    private Set<XAResource> xaResources = Collections.newSetFromMap(new ConcurrentHashMap<XAResource, Boolean>());
-    private long creationTime;
-    
-    public TransactionContextImpl() {}
-    
-    public boolean isInTransaction() {
-        return getTransaction() != null;
-    }
-
-    /**
-     * @param transaction
-     *            The transaction to set.
-     */
-    void setTransaction(Transaction transaction, String id) {
-        this.transaction = transaction;
-        this.txnID = id;
-        this.creationTime = System.currentTimeMillis();
-    }
-    
-    long getCreationTime() {
-		return creationTime;
-	}
-    
-    /**
-     * @return Returns the transaction.
-     */
-    public Transaction getTransaction() {
-        return transaction;
-    }
-
-    /**
-     * @return Returns the txnID.
-     */
-    public String getTxnID() {
-        return this.txnID;
-    }
-
-    void setTransactionType(Scope transactionType) {
-        this.transactionType = transactionType;
-    }
-
-    public Scope getTransactionType() {
-        return transactionType;
-    }
-
-    /**
-     * @see java.lang.Object#toString()
-     */
-    public String toString() {
-        StringBuffer sb = new StringBuffer();
-        this.buildString(sb);
-        return sb.toString();
-    }
-
-    private void buildString(StringBuffer sb) {
-        sb.append("TxnContext: ").append(this.txnID); //$NON-NLS-1$
-    }
-
-    void setThreadId(String threadId) {
-        this.threadId = threadId;
-    }
-
-    String getThreadId() {
-        return threadId;
-    }
-
-    public MMXid getXid() {
-        return this.xid;
-    }
-
-    void setXid(MMXid xid) {
-        this.xid = xid;
-    }
-
-    Set<String> getSuspendedBy() {
-        return this.suspendedBy;
-    }
-
-    /** 
-     * @see org.teiid.connector.xa.api.TransactionContext#getTransactionTimeout()
-     */
-    int getTransactionTimeout() {
-        return this.transactionTimeout;
-    }
-    
-    void setTransactionTimeout(int transactionTimeout) {
-        this.transactionTimeout = transactionTimeout;
-    }
-    
-    void addXAResource(XAResource resource) {
-    	this.xaResources.add(resource);
-    }
-    
-    Set<XAResource> getXAResources() {
-    	return xaResources;
-    }
-
-    /** 
-     * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
-     */
-    public void readExternal(ObjectInput in) throws IOException,
-                                            ClassNotFoundException {
-        
-    }
-
-    /** 
-     * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
-     */
-    public void writeExternal(ObjectOutput out) throws IOException {
-        if (this.transaction != null) {
-            throw new MetaMatrixRuntimeException(DQPPlugin.Util.getString("TransactionContextImpl.remote_not_supported")); //$NON-NLS-1$
-        }
-    }
-
-}
\ No newline at end of file

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,43 +22,11 @@
 
 package org.teiid.dqp.internal.transaction;
 
-import java.sql.SQLException;
-import java.util.Properties;
-
 import javax.resource.spi.XATerminator;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
 
-import com.metamatrix.common.xa.MMXid;
-import com.metamatrix.common.xa.XATransactionException;
 
-
 public interface TransactionProvider {
 	
-	public interface XAConnectionSource {
-		
-		XAResource getXAResource() throws SQLException;
-		
-		void close();
-		
-	}
-    
-    void init(Properties props) throws XATransactionException;
-
     XATerminator getXATerminator();
 
-    TransactionManager getTransactionManager();
-
-    Transaction importTransaction(MMXid xid, int timeout) throws XAException, SystemException;
-    
-    String getTransactionID(Transaction tx);
-    
-    void shutdown();
-    
-    void registerRecoverySource(String name, XAConnectionSource resource);
-    
-    void removeRecoverySource(String name);    
 }
\ No newline at end of file

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,42 +25,26 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
+import javax.resource.NotSupportedException;
 import javax.transaction.InvalidTransactionException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
-import org.teiid.adminapi.AdminComponentException;
 import org.teiid.adminapi.AdminException;
 import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
+import org.teiid.adminapi.impl.TransactionMetadata;
 
-import com.metamatrix.admin.objects.MMAdminObject;
-import com.metamatrix.admin.objects.TransactionImpl;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.common.xa.MMXid;
 import com.metamatrix.common.xa.XATransactionException;
 import com.metamatrix.core.util.Assertion;
 import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.dqp.service.TransactionService;
 
 public class TransactionServerImpl implements TransactionService {
@@ -68,15 +52,15 @@
     private static class TransactionMapping {
 
         // (connection -> transaction for global and local)
-        private Map<String, TransactionContextImpl> threadToTransactionContext = new HashMap<String, TransactionContextImpl>();
-        // (MMXid -> global transactions keyed)
-        private Map<MMXid, TransactionContextImpl> xidToTransactionContext = new HashMap<MMXid, TransactionContextImpl>();
+        private Map<String, TransactionContext> threadToTransactionContext = new HashMap<String, TransactionContext>();
+        // (MMXid -> global transactions keyed) 
+        private Map<Integer, TransactionContext> xidToTransactionContext = new HashMap<Integer, TransactionContext>();
         
-        public synchronized TransactionContextImpl getOrCreateTransactionContext(String threadId) {
-            TransactionContextImpl tc = threadToTransactionContext.get(threadId);
+        public synchronized TransactionContext getOrCreateTransactionContext(String threadId) {
+            TransactionContext tc = threadToTransactionContext.get(threadId);
 
             if (tc == null) {
-                tc = new TransactionContextImpl();
+                tc = new TransactionContext();
                 tc.setThreadId(threadId);
                 threadToTransactionContext.put(threadId, tc);
             }
@@ -84,34 +68,34 @@
             return tc;
         }
         
-        public synchronized TransactionContextImpl getTransactionContext(String threadId) {
+        public synchronized TransactionContext getTransactionContext(String threadId) {
             return threadToTransactionContext.get(threadId);
         }
 
-        public synchronized TransactionContextImpl getTransactionContext(MMXid xid) {
-            return xidToTransactionContext.get(xid);
+        public synchronized TransactionContext getTransactionContext(MMXid xid) {
+            return xidToTransactionContext.get(xid.hashCode());
         }
-
-        public synchronized TransactionContextImpl removeTransactionContext(String threadId) {
+        
+        public synchronized TransactionContext getTransactionContext(int hash) {
+            return xidToTransactionContext.get(hash);
+        }
+        
+        public synchronized TransactionContext removeTransactionContext(String threadId) {
             return threadToTransactionContext.remove(threadId);
         }
 
-        public synchronized void removeTransactionContext(TransactionContextImpl tc) {
+        public synchronized void removeTransactionContext(TransactionContext tc) {
             if (tc.getXid() != null) {
-                this.xidToTransactionContext.remove(tc.getXid());
+                this.xidToTransactionContext.remove(tc.getXid().hashCode());
             }
             if (tc.getThreadId() != null) {
                 this.threadToTransactionContext.remove(tc.getThreadId());
             }
         }
         
-        public synchronized void removeTransactionContext(MMXid xid) {
-            this.xidToTransactionContext.remove(xid);
-        }
-
-        public synchronized void addTransactionContext(TransactionContextImpl tc) {
+        public synchronized void addTransactionContext(TransactionContext tc) {
             if (tc.getXid() != null) {
-                this.xidToTransactionContext.put(tc.getXid(), tc);
+                this.xidToTransactionContext.put(tc.getXid().hashCode(), tc);
             }
             if (tc.getThreadId() != null) {
                 this.threadToTransactionContext.put(tc.getThreadId(), tc);
@@ -123,6 +107,7 @@
     
     private TransactionProvider provider;
     private String processName = "embedded"; //$NON-NLS-1$
+    private XidFactory xidFactory;
 
     public TransactionServerImpl() {
     }
@@ -135,148 +120,131 @@
         this.provider = theProvider;
     }
 
-    @SuppressWarnings("finally")
-	public int prepare(final String threadId,
-                       MMXid xid) throws XATransactionException {
-        TransactionContextImpl impl = checkXAState(threadId, xid, true, false);
-        if (!impl.getSuspendedBy().isEmpty()) {
+    /**
+     * Global Transaction 
+     */
+	public int prepare(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException {
+        TransactionContext tc = checkXAState(threadId, xid, true, false);
+        if (!tc.getSuspendedBy().isEmpty()) {
             throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.suspended_exist", xid)); //$NON-NLS-1$
+        }		
+        
+        if (tc.shouldRollback()) {
+        	throw new XATransactionException(XAException.XAER_RMERR, DQPPlugin.Util.getString("TransactionServer.rollback_set", xid));
         }
+        
+        // In the container this pass though
+        if (singleTM) {        	    	
+	    	return XAResource.XA_RDONLY;
+        }
+        
         try {
-        	getTransactionManager().resume(impl.getTransaction());
-        	try {
-        		endAssociations(impl);
-        	} finally {
-        		return this.provider.getXATerminator().prepare(xid);
-        	}
-        } catch (XAException err) {
-            throw new XATransactionException(err);
-        } catch (SystemException err) {
-        	throw new XATransactionException(err);
-		} catch (InvalidTransactionException err) {
-			throw new XATransactionException(err);
-		} catch (IllegalStateException err) {
-			throw new XATransactionException(err);
-		} finally {
-			try {
-				getTransactionManager().suspend();
-			} catch (SystemException err) {
-				throw new XATransactionException(err);
-			}
-		}
-    }
-    
-    private void endAssociations(TransactionContextImpl impl) throws XATransactionException, SystemException {
-        Transaction tx = getTransactionManager().getTransaction();
-        Assertion.isNotNull(tx);
-        for (XAResource resource : impl.getXAResources()) {
-        	if (!tx.delistResource(resource, XAResource.TMSUCCESS)) {
-                throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.failed_to_delist")); //$NON-NLS-1$
-            }
+        	return this.provider.getXATerminator().prepare(tc.getXid());
+        } catch (XAException e) {
+            throw new XATransactionException(e);
         }
-        impl.getXAResources().clear();
     }
-
-    public void commit(final String threadId,
-                       MMXid xid,
-                       boolean onePhase) throws XATransactionException {
-
-        TransactionContextImpl tc = checkXAState(threadId, xid, true, false);        
-        try {
-            if (onePhase && prepare(threadId, xid) == XAResource.XA_RDONLY) {
-                return;
-            }
-            // TODO: for one phase, MM needs to check if there are multiple resources involved
-            // or single, in its txn, if it has single it can use onePhase.
-            // Also, Arjuna has bug JBTM-457, where on single phase commit, they do not call the synchronization
-            // when they fix the bug, we can re-write next couple lines differently to make use of the
-            // optimization of onePhase.
-            this.provider.getXATerminator().commit(xid, false);
-        } catch (XAException err) {
-            throw new XATransactionException(err);
+    
+    /**
+     * Global Transaction 
+     */    
+    public void commit(final String threadId, MMXid xid, boolean onePhase, boolean singleTM) throws XATransactionException {
+    	TransactionContext tc = checkXAState(threadId, xid, true, false);  
+    	try {
+    		// In the case of single TM, the container directly commits the sources.
+        	if (!singleTM) {
+        		// In the case of onePhase containers call commit directly. If Teiid is also one phase let it pass through,
+        		// otherwise force the prepare.
+        		boolean singlePhase = tc.isOnePhase();
+        		if (onePhase && !singlePhase) {
+        			prepare(threadId, xid, singleTM);
+        		}
+        		this.provider.getXATerminator().commit(tc.getXid(), singlePhase);
+        	}
+    	} catch (XAException e) {
+            throw new XATransactionException(e);
         } finally {
-            this.transactions.removeTransactionContext(tc);
-        }
+    		this.transactions.removeTransactionContext(tc);
+    	}
     }
-
-    public void rollback(final String threadId,
-                         MMXid xid) throws XATransactionException {
-        TransactionContextImpl tc = checkXAState(threadId, xid, true, false);
-        try {
-            this.provider.getXATerminator().rollback(xid);
-        } catch (XAException err) {
-            throw new XATransactionException(err);
+    
+    /**
+     * Global Transaction 
+     */
+    public void rollback(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException {
+    	TransactionContext tc = checkXAState(threadId, xid, true, false);  
+    	try {
+    		// In the case of single TM, the container directly roll backs the sources.
+        	if (!singleTM) {
+        		this.provider.getXATerminator().rollback(tc.getXid());
+        	}
+    	} catch (XAException e) {
+            throw new XATransactionException(e);
         } finally {
-            this.transactions.removeTransactionContext(tc);
-        }
+    		this.transactions.removeTransactionContext(tc);
+    	}
     }
 
-    public Xid[] recover(int flag) throws XATransactionException {
-        try {
-            return this.provider.getXATerminator().recover(flag);
-        } catch (XAException err) {
-            throw new XATransactionException(err);
-        }
+    /**
+     * Global Transaction 
+     */    
+    public Xid[] recover(int flag, boolean singleTM) throws XATransactionException {
+    	// In case of single TM, container knows this list.
+    	if (singleTM) {
+    		return new Xid[0];
+    	}
+    	
+    	try {
+			return this.provider.getXATerminator().recover(flag);
+		} catch (XAException e) {
+			throw new XATransactionException(e);
+		}
     }
 
-    public void forget(final String threadId,
-                       MMXid xid) throws XATransactionException {
+    /**
+     * Global Transaction 
+     */    
+    public void forget(final String threadId, MMXid xid, boolean singleTM) throws XATransactionException {
+    	TransactionContext tc = checkXAState(threadId, xid, true, false); 
         try {
+        	if (singleTM) {
+        		return;
+        	}
             this.provider.getXATerminator().forget(xid);
         } catch (XAException err) {
             throw new XATransactionException(err);
         } finally {
-            this.transactions.removeTransactionContext(xid);
+        	this.transactions.removeTransactionContext(tc);
         }
     }
 
-    public void start(final String threadId,
-                      final MMXid xid,
-                      int flags,
-                      int timeout) throws XATransactionException {
+    /**
+     * Global Transaction 
+     */
+    public void start(final String threadId, final MMXid xid, int flags, int timeout, boolean singleTM) throws XATransactionException {
         
-        TransactionContextImpl tc = null;
+        TransactionContext tc = null;
 
         switch (flags) {
             case XAResource.TMNOFLAGS: {
-                checkXAState(threadId, xid, false, false);
-                tc = transactions.getOrCreateTransactionContext(threadId);
-                if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
-                    throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
-                }
-                Transaction tx;
                 try {
-                    tx = this.provider.importTransaction(xid, timeout);
-                } catch (XAException err) {
-                    throw new XATransactionException(err);
-                } catch (SystemException err) {
-                	throw new XATransactionException(err);
-                }
-                
-                try {
-                    tx.registerSynchronization(new Synchronization() {
-
-                        public void afterCompletion(int arg0) {
-                            transactions.removeTransactionContext(xid);
-                        }
-
-                        public void beforeCompletion() {
-                        }});
-                } catch (RollbackException err) {
-                    throw new XATransactionException(err, XAException.XA_RBROLLBACK);
-                } catch (SystemException err) {
-                    throw new XATransactionException(err, XAException.XAER_RMERR);
-                }
-                tc.setTransaction(tx, provider.getTransactionID(tx));
-                tc.setTransactionTimeout(timeout);
-                tc.setXid(xid);
-                tc.setTransactionType(TransactionContext.Scope.GLOBAL);
+					checkXAState(threadId, xid, false, false);
+					tc = transactions.getOrCreateTransactionContext(threadId);
+					if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
+					    throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
+					}
+					tc.setTransactionTimeout(timeout);
+					tc.setXid(xid);
+					tc.setTransactionType(TransactionContext.Scope.GLOBAL);
+				} catch (NotSupportedException e) {
+					throw new XATransactionException(XAException.XAER_INVAL, e.getMessage()); //$NON-NLS-1$
+				}
                 break;
             }
             case XAResource.TMJOIN:
             case XAResource.TMRESUME: {
                 tc = checkXAState(threadId, xid, true, false);
-                TransactionContextImpl threadContext = transactions.getOrCreateTransactionContext(threadId);
+                TransactionContext threadContext = transactions.getOrCreateTransactionContext(threadId);
                 if (threadContext.getTransactionType() != TransactionContext.Scope.NONE) {
                     throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
                 }
@@ -294,10 +262,11 @@
         transactions.addTransactionContext(tc);
     }
 
-    public void end(final String threadId,
-                    MMXid xid,
-                    int flags) throws XATransactionException {
-        TransactionContextImpl tc = checkXAState(threadId, xid, true, true);
+    /**
+     * Global Transaction 
+     */    
+    public void end(final String threadId, MMXid xid, int flags, boolean singleTM) throws XATransactionException {
+        TransactionContext tc = checkXAState(threadId, xid, true, true);
         try {
             switch (flags) {
                 case XAResource.TMSUSPEND: {
@@ -309,11 +278,7 @@
                     break;
                 }
                 case XAResource.TMFAIL: {
-                    try {
-                        tc.getTransaction().setRollbackOnly();
-                    } catch (SystemException err) {
-                        throw new XATransactionException(err, XAException.XAER_RMERR);
-                    }
+                	tc.setRollbackOnly();
                     break;
                 }
                 default:
@@ -325,10 +290,8 @@
         }
     }
 
-    private TransactionContextImpl checkXAState(final String threadId,
-                                                    final MMXid xid,
-                                                    boolean transactionExpected, boolean threadBound) throws XATransactionException {
-        TransactionContextImpl tc = transactions.getTransactionContext(xid);
+    private TransactionContext checkXAState(final String threadId, final MMXid xid, boolean transactionExpected, boolean threadBound) throws XATransactionException {
+        TransactionContext tc = transactions.getTransactionContext(xid);
         
         if (transactionExpected && tc == null) {
             throw new XATransactionException(XAException.XAER_NOTA, DQPPlugin.Util.getString("TransactionServer.no_global_transaction", xid)); //$NON-NLS-1$
@@ -356,23 +319,18 @@
         return tc;
     }
 
-    private TransactionContextImpl checkLocalTransactionState(String threadId,
-                                               boolean transactionExpected) throws NotSupportedException,
-                                                                           SystemException,
-                                                                           InvalidTransactionException {
+    private TransactionContext checkLocalTransactionState(String threadId, boolean transactionExpected) 
+    	throws InvalidTransactionException {
 
-        final TransactionContextImpl tc = transactions.getOrCreateTransactionContext(threadId);
+        final TransactionContext tc = transactions.getOrCreateTransactionContext(threadId);
 
-        final TransactionManager tm = getTransactionManager();
-
         if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
             if (tc.getTransactionType() != TransactionContext.Scope.LOCAL) {
-                throw new NotSupportedException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
+                throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
             }
             if (!transactionExpected) {
-                throw new NotSupportedException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
+                throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
             }
-            tm.resume(tc.getTransaction());
         } else if (transactionExpected) {
             throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.no_transaction", threadId)); //$NON-NLS-1$
         }
@@ -380,191 +338,146 @@
         return tc;
     }
 
-    public TransactionContext begin(String threadId) throws XATransactionException, SystemException {
+    /**
+     * Local Transaction 
+     */
+    public TransactionContext begin(String threadId) throws XATransactionException {
         try {
-            TransactionContextImpl tc = checkLocalTransactionState(threadId, false);
-            final TransactionManager tm = getTransactionManager();
-            tm.begin();
-            Transaction tx = tm.suspend();
-            tc.setTransaction(tx, provider.getTransactionID(tx));
+            TransactionContext tc = checkLocalTransactionState(threadId, false);
+            tc.setXid(this.xidFactory.createXid());
+            tc.setCreationTime(System.currentTimeMillis());
             tc.setTransactionType(TransactionContext.Scope.LOCAL);
             return tc;
         } catch (InvalidTransactionException err) {
             throw new XATransactionException(err);
-        } catch (NotSupportedException err) {
-            throw new XATransactionException(err);
-        } 
+        }
     }
 
-    public void commit(String threadId) throws XATransactionException, SystemException {
-        TransactionContextImpl tc;
+    /**
+     * Local Transaction 
+     */    
+    public void commit(String threadId) throws XATransactionException {
+        TransactionContext tc;
         try {
             tc = checkLocalTransactionState(threadId, true);
         } catch (InvalidTransactionException err) {
             throw new XATransactionException(err);
-        } catch (NotSupportedException err) {
-            throw new XATransactionException(err);
         } 
-        final TransactionManager tm = getTransactionManager();
+
+        if (tc.shouldRollback()) {
+        	rollback(threadId);
+        }
         try {
-        	try {
-        		endAssociations(tc);
-        	} finally {
-        		tm.commit();
+        	if (tc.isInTransaction()) {
+            	directCommit(tc);
         	}
-        } catch (IllegalStateException err) {
-            throw new XATransactionException(err);
-        } catch (RollbackException err) {
-            throw new XATransactionException(err);
-        } catch (HeuristicMixedException err) {
-            throw new XATransactionException(err);
-        } catch (HeuristicRollbackException err) {
-            throw new XATransactionException(err);
+        } catch (XAException e) {
+            throw new XATransactionException(e);
         } finally {
             transactions.removeTransactionContext(tc);
         }
-        
     }
 
-    public void rollback(String threadId) throws XATransactionException, SystemException {
-        TransactionContextImpl tc;
+    /**
+     * Local Transaction 
+     */    
+    public void rollback(String threadId) throws XATransactionException {
+        TransactionContext tc;
         try {
             tc = checkLocalTransactionState(threadId, true);
         } catch (InvalidTransactionException err) {
             throw new XATransactionException(err);
-        } catch (NotSupportedException err) {
-            throw new XATransactionException(err);
         } 
-        final TransactionManager tm = getTransactionManager();
         
         try {
-            tm.rollback();
-        } catch (IllegalStateException err) {
-            throw new XATransactionException(err);
+        	if (tc.isInTransaction()) {
+        		this.provider.getXATerminator().rollback(tc.getXid());
+        	}
+        } catch (XAException e) {
+            throw new XATransactionException(e);
         } finally {
             transactions.removeTransactionContext(tc);
         }
     }
 
-    public TransactionManager getTransactionManager() {
-        return provider.getTransactionManager();
-    }
 
     public TransactionContext getOrCreateTransactionContext(String threadId) {
         return transactions.getOrCreateTransactionContext(threadId);
     }
 
-    // request level transaction
-    public TransactionContext start(TransactionContext context) throws XATransactionException, SystemException {
-        TransactionManager tm = getTransactionManager();
-
-        TransactionContextImpl tc = (TransactionContextImpl)context;
-
-        try {
-            if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
-                throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
-            }
-            tm.begin();
-            Transaction tx = tm.suspend();
-            
-            tc.setTransaction(tx, provider.getTransactionID(tx));
-            tc.setTransactionType(TransactionContext.Scope.REQUEST);
-            return tc;
-        } catch (NotSupportedException e) {
-            throw new XATransactionException(e);
+    /**
+     * Request level transaction
+     */
+    public TransactionContext start(TransactionContext context) throws XATransactionException{
+        if (context.getTransactionType() != TransactionContext.Scope.NONE) {
+            throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
         }
+        context.setXid(this.xidFactory.createXid());
+        context.setCreationTime(System.currentTimeMillis());
+        context.setTransactionType(TransactionContext.Scope.REQUEST);
+        return context;
     }
 
-    public TransactionContext commit(TransactionContext context) throws XATransactionException, SystemException {
+    /**
+     * Request level transaction
+     */    
+    public TransactionContext commit(TransactionContext context) throws XATransactionException {
         Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
-        TransactionContextImpl tc = (TransactionContextImpl)context;
         
         //commit may be called multiple times by the processworker, if this is a subsequent call, then the current
         //context will not be active
-        TransactionContextImpl currentContext = transactions.getTransactionContext(tc.getThreadId());
-        if (currentContext == null || currentContext.getTransactionType() == TransactionContext.Scope.NONE) {
-            return currentContext;
+        TransactionContext tc = transactions.getTransactionContext(context.getThreadId());
+        if (tc == null || tc.getTransactionType() == TransactionContext.Scope.NONE) {
+            return tc;
         }
-        TransactionManager tm = getTransactionManager();
         
+        Assertion.assertTrue(!tc.shouldRollback());
+        
         try {
-            tm.resume(context.getTransaction());
-            try {
-            	endAssociations(tc);
-            } finally {
-            	tm.commit();
-            }
-        } catch (InvalidTransactionException e) {
+        	if (tc.isInTransaction()) {
+            	directCommit(tc);
+        	}
+        } catch (XAException e) {
             throw new XATransactionException(e);
-        } catch (RollbackException e) {
-            throw new XATransactionException(e);
-        } catch (HeuristicMixedException e) {
-            throw new XATransactionException(e);
-        } catch (HeuristicRollbackException e) {
-            throw new XATransactionException(e);
         } finally {
-            transactions.removeTransactionContext(tc);
+            transactions.removeTransactionContext(context);
         }
         return context;
     }
 
-    public TransactionContext rollback(TransactionContext context) throws XATransactionException, SystemException {
+	private void directCommit(TransactionContext tc) throws XAException {
+		boolean commit = true;
+		boolean onePhase = tc.isOnePhase();
+		if (!onePhase) {
+			int prepare = this.provider.getXATerminator().prepare(tc.getXid());
+			commit = (prepare == XAResource.XA_OK);
+		}
+		
+		if (commit) {
+			this.provider.getXATerminator().commit(tc.getXid(), onePhase);
+		}
+	}
+
+    /**
+     * Request level transaction
+     */    
+    public TransactionContext rollback(TransactionContext context) throws XATransactionException {
         Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
-        TransactionManager tm = getTransactionManager();
         try {
-            tm.resume(context.getTransaction());
-        	tm.rollback();
-        } catch (InvalidTransactionException e) {
+	        this.provider.getXATerminator().rollback(context.getXid());
+        } catch (XAException e) {
             throw new XATransactionException(e);
         } finally {
-            transactions.removeTransactionContext((TransactionContextImpl)context);
-        }        
-        return context;
-    }
-
-    public TransactionContext enlist(TransactionContext context,
-                                     XAResource resource) throws XATransactionException {
-        TransactionManager tm = getTransactionManager();
-        TransactionContextImpl tc = (TransactionContextImpl)context;
-        
-        try {
-            if (tc.getTransactionTimeout() > 0 && tc.getTransactionTimeout() != resource.getTransactionTimeout()) {
-                resource.setTransactionTimeout(tc.getTransactionTimeout());
-            }
-            Transaction tx = tm.getTransaction();
-            if (tx == null) {
-                tm.resume(context.getTransaction());
-            } else if (!tx.equals(context.getTransaction())) {
-                throw new XATransactionException(context.getTransaction() + " != " + tx); //$NON-NLS-1$
-            }
-
-            if (!context.getTransaction().enlistResource(resource)) {
-				context.getTransaction().delistResource(resource, XAResource.TMFAIL);
-                throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.failed_to_enlist")); //$NON-NLS-1$
-            }
-            tc.addXAResource(resource);
-        } catch (SystemException err) {
-            throw new XATransactionException(err);
-        } catch (InvalidTransactionException err) {
-            throw new XATransactionException(err);
-        } catch (RollbackException err) {
-            throw new XATransactionException(err);
-        } catch (IllegalStateException err) {
-            throw new XATransactionException(err);
-        } catch (XAException err) {
-            throw new XATransactionException(err);
+            transactions.removeTransactionContext(context);
         }
-
-        return context;
+        return context;      
     }
 
-    /** 
-     * @throws IllegalStateException 
-     * @throws InvalidTransactionException 
-     * @see com.metamatrix.dqp.transaction.TransactionServer#cancelTransactions(java.lang.String)
+    /**
+     * Request level transaction
      */
-    public void cancelTransactions(String threadId, boolean requestOnly) throws InvalidTransactionException, SystemException {
-        TransactionContextImpl tc = transactions.getTransactionContext(threadId);
+    public void cancelTransactions(String threadId, boolean requestOnly) throws XATransactionException {
+        TransactionContext tc = transactions.getTransactionContext(threadId);
         
         if (tc == null || tc.getTransactionType() == TransactionContext.Scope.NONE) {
             return;
@@ -574,133 +487,64 @@
             return;
         }
         
-        cancelTransaction(tc);
-    }
-
-	private void cancelTransaction(TransactionContextImpl tc)
-			throws InvalidTransactionException, SystemException {
-		TransactionManager tm = getTransactionManager();
+        tc.setRollbackOnly();
         
-        try {
-            tm.resume(tc.getTransaction());
-            tm.setRollbackOnly();
-        } finally {
-            tm.suspend();
-            //transactions.removeTransactionContext(tc);
+        if (requestOnly) {
+        	rollback(tc);
         }
-	}    
-    
-    public synchronized void registerRecoverySource(String name, XAConnectionSource resource) {
-        this.provider.registerRecoverySource(name, resource);
+        else {
+        	rollback(threadId);
+        }
     }
 
-    public synchronized void removeRecoverySource(String name) {
-        this.provider.removeRecoverySource(name);
-    }
-
 	@Override
 	public Collection<org.teiid.adminapi.Transaction> getTransactions() {
-		Set<TransactionContextImpl> txnSet = Collections.newSetFromMap(new IdentityHashMap<TransactionContextImpl, Boolean>());
+		Set<TransactionContext> txnSet = Collections.newSetFromMap(new IdentityHashMap<TransactionContext, Boolean>());
 		synchronized (this.transactions) {
 			txnSet.addAll(this.transactions.threadToTransactionContext.values());
 			txnSet.addAll(this.transactions.xidToTransactionContext.values());
 		}
 		Collection<org.teiid.adminapi.Transaction> result = new ArrayList<org.teiid.adminapi.Transaction>(txnSet.size());
-		for (TransactionContextImpl transactionContextImpl : txnSet) {
-			if (transactionContextImpl.getTxnID() == null) {
+		for (TransactionContext TransactionContext : txnSet) {
+			if (TransactionContext.getXid() == null) {
 				continue;
 			}
-			TransactionImpl txnImpl = new TransactionImpl(processName, transactionContextImpl.getTxnID());
-			txnImpl.setAssociatedSession(transactionContextImpl.getThreadId());
-			txnImpl.setCreated(new Date(transactionContextImpl.getCreationTime()));
-			txnImpl.setScope(transactionContextImpl.getTransactionType().toString());
-			try {
-				txnImpl.setStatus(getStatusString(transactionContextImpl.getTransaction().getStatus()));
-			} catch (SystemException e) {
-				txnImpl.setStatus(getStatusString(Status.STATUS_UNKNOWN));
-			}
-			txnImpl.setXid(transactionContextImpl.getXid());
+			TransactionMetadata txnImpl = new TransactionMetadata();
+			txnImpl.setAssociatedSession(Long.parseLong(TransactionContext.getThreadId()));
+			txnImpl.setCreatedTime(TransactionContext.getCreationTime());
+			txnImpl.setScope(TransactionContext.getTransactionType().toString());
+			txnImpl.setXid(TransactionContext.getXid().toString());
 			result.add(txnImpl);
 		}
 		return result;
 	}
 	
-	public static String getStatusString(int status) {
-		switch (status) {
-		case Status.STATUS_ACTIVE:
-			return "ACTIVE"; //$NON-NLS-1$
-		case Status.STATUS_COMMITTED:
-			return "COMMITTED"; //$NON-NLS-1$
-		case Status.STATUS_COMMITTING:
-			return "COMMITTING"; //$NON-NLS-1$
-		case Status.STATUS_MARKED_ROLLBACK:
-			return "MARKED_ROLLBACK"; //$NON-NLS-1$
-		case Status.STATUS_NO_TRANSACTION:
-			return "NO_TRANSACTION"; //$NON-NLS-1$
-		case Status.STATUS_PREPARED:
-			return "PREPARED"; //$NON-NLS-1$
-		case Status.STATUS_PREPARING:
-			return "PREPARING"; //$NON-NLS-1$
-		case Status.STATUS_ROLLEDBACK:
-			return "ROLLEDBACK"; //$NON-NLS-1$
-		case Status.STATUS_ROLLING_BACK:
-			return "ROLLING_BACK";			 //$NON-NLS-1$
-		}
-		return "UNKNOWN"; //$NON-NLS-1$
-	}
-	
 	@Override
-	public void terminateTransaction(Xid transactionId) throws AdminException {
-		if (transactionId == null) {
+	public void terminateTransaction(String xid) throws AdminException {
+		if (xid == null) {
 			return;
 		}
-		TransactionContextImpl context = this.transactions.getTransactionContext(new MMXid(transactionId));
-		if (context != null) {
-			try {
-				cancelTransaction(context);
-			} catch (InvalidTransactionException e) {
-				throw new AdminProcessingException(e);
-			} catch (SystemException e) {
-				throw new AdminComponentException(e);
+		TransactionContext context = this.transactions.getTransactionContext(xid.hashCode());
+		context.setRollbackOnly();
+		
+		try {
+			if (context.getTransactionType() == TransactionContext.Scope.REQUEST ) {
+				rollback(context);
 			}
+			
+			if (context.getTransactionType() == TransactionContext.Scope.LOCAL ) {
+				rollback(context.getThreadId());
+			}
+			
+			if (context.getTransactionType() == TransactionContext.Scope.GLOBAL ) {
+				throw new AdminProcessingException("Can not terminate global transactions!");
+			}			
+		} catch (XATransactionException e) {
+			throw new AdminProcessingException(e.getMessage());
 		}
 	}
 	
-	@Override
-	public void terminateTransaction(String transactionId, String sessionId) throws AdminException {
-		if (transactionId == null) {
-			return;
-		}
-		String[] id = MMAdminObject.buildIdentifierArray(transactionId);
-		if (!this.processName.equalsIgnoreCase(id[0]) || id.length != 2) {
-			return;
-		}
-		TransactionContextImpl context = this.transactions.getTransactionContext(sessionId);
-		if (context != null && id[1].equalsIgnoreCase(context.getTxnID())) {
-			try {
-				cancelTransaction(context);
-			} catch (InvalidTransactionException e) {
-				throw new AdminProcessingException(e);
-			} catch (SystemException e) {
-				throw new AdminComponentException(e);
-			}
-		}
+	public void setXidFactory(XidFactory f) {
+		this.xidFactory = f;
 	}
-
-	@Override
-	public void initialize(Properties props)
-			throws ApplicationInitializationException {
-	}
-
-	@Override
-	public void start(ApplicationEnvironment environment)
-			throws ApplicationLifecycleException {
-		
-	}
-
-	@Override
-	public synchronized void stop() throws ApplicationLifecycleException {
-		this.provider.shutdown();
-	}    
-    
 }

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java (from rev 1900, branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.dqp.internal.transaction;
+
+import java.util.Random;
+
+import javax.transaction.xa.Xid;
+
+import com.metamatrix.common.xa.MMXid;
+
+public class XidFactory {
+	Random r = new Random(System.currentTimeMillis());
+	public Xid createXid() {
+		
+		byte[] global = new byte[10];
+		byte[] branch = new byte[10];
+		r.nextBytes(global);
+		r.nextBytes(branch);
+		
+		return new MMXid(78923, global, branch);
+	}
+}

Modified: trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,14 +28,13 @@
 import java.util.List;
 
 import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
+import org.teiid.connector.metadata.runtime.Procedure;
 import org.teiid.connector.metadata.runtime.Schema;
 import org.teiid.connector.metadata.runtime.Table;
 import org.teiid.connector.metadata.runtime.Table.Type;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
 
 /**
  * Aggregates the metadata from multiple stores.  
@@ -43,16 +42,22 @@
  */
 public class CompositeMetadataStore extends MetadataStore {
 
-	private MetadataSource metadataSource;
 	
-	public CompositeMetadataStore(List<MetadataStore> metadataStores, MetadataSource metadataSource) {
-		this.metadataSource = metadataSource;
+	public CompositeMetadataStore(MetadataStore metadataStore) {
+		addMetadataStore(metadataStore);
+	}
+	
+	public CompositeMetadataStore(List<MetadataStore> metadataStores) {
 		for (MetadataStore metadataStore : metadataStores) {
-			this.schemas.putAll(metadataStore.getSchemas());
-			this.datatypes.addAll(metadataStore.getDatatypes());
+			addMetadataStore(metadataStore);
 		}
 	}
 	
+	public void addMetadataStore(MetadataStore metadataStore) {
+		this.schemas.putAll(metadataStore.getSchemas());
+		this.datatypes.addAll(metadataStore.getDatatypes());
+	}
+	
 	public Schema getSchema(String fullName)
 			throws QueryMetadataException {
 		Schema result = getSchemas().get(fullName);
@@ -94,13 +99,13 @@
 		return result;
 	}
 	
-	public Collection<ProcedureRecordImpl> getStoredProcedure(String name)
+	public Collection<Procedure> getStoredProcedure(String name)
 			throws MetaMatrixComponentException, QueryMetadataException {
-		List<ProcedureRecordImpl> result = new LinkedList<ProcedureRecordImpl>();
+		List<Procedure> result = new LinkedList<Procedure>();
 		int index = name.indexOf(TransformationMetadata.DELIMITER_STRING);
 		if (index > -1) {
 			String schema = name.substring(0, index);
-			ProcedureRecordImpl proc = getSchema(schema).getProcedures().get(name.substring(index + 1));
+			Procedure proc = getSchema(schema).getProcedures().get(name.substring(index + 1));
 			if (proc != null) {
 				result.add(proc);
 		        return result;
@@ -109,7 +114,7 @@
 		//assume it's a partial name
 		name = TransformationMetadata.DELIMITER_STRING + name;
 		for (Schema schema : getSchemas().values()) {
-			for (ProcedureRecordImpl p : schema.getProcedures().values()) {
+			for (Procedure p : schema.getProcedures().values()) {
 				String fullName = p.getFullName();
 				if (fullName.regionMatches(true, fullName.length() - name.length(), name, 0, name.length())) {
 					result.add(p);	
@@ -122,10 +127,6 @@
 		return result;
 	}
 
-	public MetadataSource getMetadataSource() {
-		return metadataSource;
-	}
-	
 	/*
 	 * The next method is a hold over from XML/UUID resolving and will perform poorly
 	 */
@@ -133,7 +134,7 @@
 	public Collection<Table> getXMLTempGroups(Table tableRecord) {
 		ArrayList<Table> results = new ArrayList<Table>();
 		String namePrefix = tableRecord.getFullName() + TransformationMetadata.DELIMITER_STRING;
-		for (Table table : tableRecord.getSchema().getTables().values()) {
+		for (Table table : tableRecord.getParent().getTables().values()) {
 			if (table.getTableType() == Type.XmlStagingTable && table.getName().startsWith(namePrefix)) {
 				results.add(table);
 			}

Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,7 +24,9 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -34,14 +36,16 @@
 import java.util.Map;
 import java.util.Properties;
 
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
 import org.teiid.connector.metadata.runtime.Column;
 import org.teiid.connector.metadata.runtime.ColumnSet;
 import org.teiid.connector.metadata.runtime.Datatype;
 import org.teiid.connector.metadata.runtime.ForeignKey;
 import org.teiid.connector.metadata.runtime.KeyRecord;
+import org.teiid.connector.metadata.runtime.Procedure;
 import org.teiid.connector.metadata.runtime.ProcedureParameter;
-import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
 import org.teiid.connector.metadata.runtime.Schema;
 import org.teiid.connector.metadata.runtime.Table;
 import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
@@ -50,16 +54,21 @@
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.properties.UnmodifiableProperties;
 import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
+import com.metamatrix.common.util.LogConstants;
 import com.metamatrix.core.util.ArgCheck;
 import com.metamatrix.core.util.LRUCache;
+import com.metamatrix.core.util.ObjectConverterUtil;
 import com.metamatrix.core.util.StringUtil;
 import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.metadata.runtime.api.MetadataSourceUtil;
 import com.metamatrix.query.QueryPlugin;
+import com.metamatrix.query.function.FunctionLibrary;
+import com.metamatrix.query.function.FunctionTree;
+import com.metamatrix.query.function.SystemFunctionManager;
+import com.metamatrix.query.function.UDFSource;
+import com.metamatrix.query.function.metadata.FunctionMethod;
 import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.mapping.xml.MappingDocument;
 import com.metamatrix.query.mapping.xml.MappingLoader;
@@ -74,9 +83,10 @@
  * Modelers implementation of QueryMetadataInterface that reads columns, groups, models etc.
  * index files for various metadata properties.
  */
-public class TransformationMetadata extends BasicQueryMetadata {
-
-    /** Delimiter character used when specifying fully qualified entity names */
+public class TransformationMetadata extends BasicQueryMetadata implements Serializable {
+	private static final long serialVersionUID = 1058627332954475287L;
+	
+	/** Delimiter character used when specifying fully qualified entity names */
     public static final char DELIMITER_CHAR = StringUtil.Constants.DOT_CHAR;
     public static final String DELIMITER_STRING = String.valueOf(DELIMITER_CHAR);
     
@@ -86,9 +96,10 @@
     private static UnmodifiableProperties EMPTY_PROPS = new UnmodifiableProperties(new Properties());
     
     private final CompositeMetadataStore store;
-	private String vdbVersion;
-	private VDBService vdbService;
-
+    private Map<VirtualFile, Boolean> vdbEntries;
+    private FunctionLibrary functionLibrary;
+    private VDBMetaData vdbMetaData;
+    
     /*
      * TODO: move caching to jboss cache structure
      */
@@ -100,15 +111,18 @@
      * TransformationMetadata constructor
      * @param context Object containing the info needed to lookup metadta.
      */
-    public TransformationMetadata(final CompositeMetadataStore store) {
-    	this(store, null, null);
-    }
-    
-    public TransformationMetadata(final CompositeMetadataStore store, VDBService service, String vdbVersion) {
+    public TransformationMetadata(VDBMetaData vdbMetadata, final CompositeMetadataStore store, Map<VirtualFile, Boolean> vdbEntries, Collection <FunctionMethod> udfMethods) {
     	ArgCheck.isNotNull(store);
+    	this.vdbMetaData = vdbMetadata;
         this.store = store;
-        this.vdbService = service;
-        this.vdbVersion = vdbVersion;
+        if (vdbEntries == null) {
+        	vdbEntries = Collections.emptyMap();
+        }
+        this.vdbEntries = vdbEntries;
+        if (udfMethods == null) {
+        	udfMethods = Collections.emptyList();
+        }
+        this.functionLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(udfMethods)));
     }
     
     //==================================================================================
@@ -163,7 +177,7 @@
 		
 		Collection<String> filteredResult = new ArrayList<String>(matches.size());
 		for (Table table : matches) {
-	        if (vdbService == null || vdbService.getModelVisibility(getVirtualDatabaseName(), vdbVersion, table.getParent().getName()) == ModelInfo.PUBLIC) {
+			if (vdbMetaData == null || vdbMetaData.getModel(table.getParent().getName()).isVisible()) {
 	        	filteredResult.add(table.getFullName());
 	        }
 		}
@@ -277,9 +291,9 @@
         Collection<StoredProcedureInfo> results = this.procedureCache.get(lowerGroupName);
         
         if (results == null) {
-        	Collection<ProcedureRecordImpl> procRecords = getMetadataStore().getStoredProcedure(lowerGroupName); 
+        	Collection<Procedure> procRecords = getMetadataStore().getStoredProcedure(lowerGroupName); 
         	results = new ArrayList<StoredProcedureInfo>(procRecords.size());
-        	for (ProcedureRecordImpl procRecord : procRecords) {
+        	for (Procedure procRecord : procRecords) {
                 String procedureFullName = procRecord.getFullName();
 
                 // create the storedProcedure info object that would hold procedure's metadata
@@ -288,7 +302,7 @@
                 procInfo.setProcedureID(procRecord);
 
                 // modelID for the procedure
-                procInfo.setModelID(procRecord.getSchema());
+                procInfo.setModelID(procRecord.getParent());
 
                 // get the parameter metadata info
                 for (ProcedureParameter paramRecord : procRecord.getParameters()) {
@@ -303,7 +317,7 @@
 
                 // if the procedure returns a resultSet, obtain resultSet metadata
                 if(procRecord.getResultSet() != null) {
-                    ColumnSet<ProcedureRecordImpl> resultRecord = procRecord.getResultSet();
+                    ColumnSet<Procedure> resultRecord = procRecord.getResultSet();
                     // resultSet is the last parameter in the procedure
                     int lastParamIndex = procInfo.getParameters().size() + 1;
                     SPParameter param = new SPParameter(lastParamIndex, SPParameter.RESULT_SET, resultRecord.getFullName());
@@ -335,7 +349,7 @@
         
         for (StoredProcedureInfo storedProcedureInfo : results) {
         	Schema schema = (Schema)storedProcedureInfo.getModelID();
-	        if(vdbService == null || vdbService.getModelVisibility(getVirtualDatabaseName(), vdbVersion, schema.getName()) == ModelInfo.PUBLIC){
+	        if(vdbMetaData == null || vdbMetaData.getModel(schema.getName()).isVisible()){
 	        	if (result != null) {
 	    			throw new QueryMetadataException(QueryPlugin.Util.getString("ambiguous_procedure", fullyQualifiedProcedureName)); //$NON-NLS-1$
 	    		}
@@ -396,7 +410,7 @@
 
     public Object getMinimumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
         if(elementID instanceof Column) {
-            return ((Column) elementID).getMinValue();            
+            return ((Column) elementID).getMinimumValue();            
         } else if(elementID instanceof ProcedureParameter){
             return null;
         } else {
@@ -406,7 +420,7 @@
 
     public Object getMaximumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
         if(elementID instanceof Column) {
-            return ((Column) elementID).getMaxValue();            
+            return ((Column) elementID).getMaximumValue();            
         } else if(elementID instanceof ProcedureParameter){
             return null;
         } else {
@@ -427,7 +441,7 @@
      * @since 4.2
      */
     public boolean isProcedure(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
-    	if(groupID instanceof ProcedureRecordImpl) {
+    	if(groupID instanceof Procedure) {
             return true;            
         } 
     	if(groupID instanceof Table){
@@ -559,7 +573,7 @@
                     }
                     return true;
                 case SupportConstants.Element.AUTO_INCREMENT:
-                    return columnRecord.isAutoIncrementable();
+                    return columnRecord.isAutoIncremented();
                 case SupportConstants.Element.CASE_SENSITIVE:
                     return columnRecord.isCaseSensitive();
                 case SupportConstants.Element.SIGNED:
@@ -773,14 +787,24 @@
         return null;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see com.metamatrix.query.metadata.QueryMetadataInterface#getVirtualDatabaseName()
      */
     public String getVirtualDatabaseName() throws MetaMatrixComponentException, QueryMetadataException {
-    	return this.getMetadataStore().getMetadataSource().getName();
+    	if (vdbMetaData == null) {
+    		return null;
+    	}
+    	return vdbMetaData.getName();
     }
 
-    /* (non-Javadoc)
+    public int getVirtualDatabaseVersion() {
+    	if (vdbMetaData == null) {
+    		return 0;
+    	}
+    	return vdbMetaData.getVersion();
+    }
+    
+    /**
      * @see com.metamatrix.query.metadata.QueryMetadataInterface#getXMLTempGroups(java.lang.Object)
      */
     public Collection getXMLTempGroups(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
@@ -948,8 +972,7 @@
      * @see com.metamatrix.query.metadata.BasicQueryMetadata#getBinaryVDBResource(java.lang.String)
      * @since 4.3
      */
-    public byte[] getBinaryVDBResource(String resourcePath) throws MetaMatrixComponentException,
-                                                           QueryMetadataException {
+    public byte[] getBinaryVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
         String content = this.getCharacterVDBResource(resourcePath);
         if(content != null) {
             return content.getBytes();
@@ -961,9 +984,23 @@
      * @see com.metamatrix.query.metadata.BasicQueryMetadata#getCharacterVDBResource(java.lang.String)
      * @since 4.3
      */
-    public String getCharacterVDBResource(String resourcePath) throws MetaMatrixComponentException,
-                                                              QueryMetadataException {
-    	return MetadataSourceUtil.getFileContentAsString(resourcePath, this.getMetadataStore().getMetadataSource());
+    public String getCharacterVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
+    	for (VirtualFile f:this.vdbEntries.keySet()) {
+    		if (f.getPathName().equals(resourcePath)) {
+    			Boolean v = this.vdbEntries.get(f);
+    			if (v.booleanValue()) {
+	    			try {
+						return ObjectConverterUtil.convertToString(f.openStream());
+					} catch (IOException e) {
+						LogManager.logError(LogConstants.CTX_CONFIG, e, e.getMessage());
+					}
+    			}
+    			else {
+    				break;
+    			}
+    		}
+    	}
+    	return null;
     }
     
     public CompositeMetadataStore getMetadataStore() {
@@ -974,9 +1011,15 @@
      * @see com.metamatrix.query.metadata.BasicQueryMetadata#getVDBResourcePaths()
      * @since 4.3
      */
-    public String[] getVDBResourcePaths() throws MetaMatrixComponentException,
-                                         QueryMetadataException {
-        return getMetadataStore().getMetadataSource().getEntries().toArray(new String[0]);
+    public String[] getVDBResourcePaths() throws MetaMatrixComponentException, QueryMetadataException {
+    	ArrayList<String> paths = new ArrayList<String>();
+    	for (VirtualFile f:this.vdbEntries.keySet()) {
+    		Boolean v = this.vdbEntries.get(f);
+    		if (v.booleanValue()) {
+    			paths.add(f.getPathName());
+    		}
+    	}
+        return paths.toArray(new String[paths.size()]);
     }
     
     /** 
@@ -1053,4 +1096,8 @@
 		return record.getUUID() + "/" + key; //$NON-NLS-1$
 	}
 
+	@Override
+	public FunctionLibrary getFunctionLibrary() {
+		return this.functionLibrary;
+	}
 }
\ No newline at end of file

Modified: trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj	2010-03-05 14:26:51 UTC (rev 1916)
@@ -60,16 +60,22 @@
 TOKEN: /* Data types */
 {
 	<STRING: "string">
+|   <VARCHAR: "varchar">
 |	<BOOLEAN: "boolean">
 |	<BYTE: "byte">
+|   <TINYINT: "tinyint">
 |	<SHORT: "short">
+|   <SMALLINT: "smallint">
 |	<CHAR: "char">
 |	<INTEGER: "integer">
 |	<LONG: "long">
+|   <BIGINT: "bigint">
 |	<BIGINTEGER: "biginteger">
-|	<FLOAT: "float"> 
+|	<FLOAT: "float">
+|   <REAL: "real"> 
 |	<DOUBLE: "double">
 |	<BIGDECIMAL: "bigdecimal">
+|   <DECIMAL: "decimal">
 |	<DATE: "date">
 |	<TIME: "time">
 |	<TIMESTAMP: "timestamp">
@@ -97,24 +103,54 @@
 
 TOKEN : /* Reserved words */
 {
-    <ALL: "all">
+    <ADD: "add">
+|   <ALL: "all">
+|   <ALTER: "alter">
 |   <AND: "and">
 |   <ANY: "any">
+|   <ARRAY: "array">
 |   <AS: "as">
 |   <ASC: "asc">
+|   <ATOMIC: "atomic">
+|   <AUTORIZATION: "authorization">
 |   <BEGIN: "begin">
 |   <BETWEEN: "between">
+|   <BINARY: "binary">
+|   <BOTH: "both">
 |   <BREAK: "break">
 |   <BY: "by">
+|   <CALL: "call">
+|   <CALLED: "called">
+|   <CASCADED: "cascaded">
 |   <CASE: "case">
+|   <CHARACTER: "character">
+|   <CHECK: "check">
+|   <CLOSE: "close">
+|   <COLLATE: "collate">
+|   <COLUMN: "column">
+|   <COMMIT: "commit">
+|   <CONNECT: "connect">
+|   <CONSTRAINT: "constraint">
 |   <CONTINUE: "continue">
+|   <CORRESPONDING: "corresponding">
+|   <CURRENT_DATE: "current_date">
+|   <CURRENT_TIME: "current_time">
+|   <CURRENT_TIMESTAMP: "current_timestamp">
+|   <CURRENT_USER: "current_user">
 |   <CREATE: "create">
 |   <CRITERIA: "criteria">
 |   <CROSS: "cross">
+|   <CURSOR: "cursor">
+|   <DAY: "day">
+|   <DEALLOCATE: "deallocate">
+|   <DEFAULT_KEYWORD: "default">
 |   <DEBUG: "debug">
 |   <DECLARE: "declare">
 |   <DELETE: "delete">
 |   <DESC: "desc">
+|   <DESCRIBE: "describe">
+|   <DETERMINISTIC: "deterministic">
+|   <DISCONNECT: "disconnect">
 |   <DISTINCT: "distinct">
 |   <DROP: "drop">
 |   <ELSE: "else">
@@ -124,63 +160,181 @@
 |   <EXCEPT: "except">
 |   <EXEC: "exec">
 |   <EXECUTE: "execute">
+|   <EXTERNAL: "external">
 |   <EXISTS: "exists">
 |   <FALSE: "false">
+|   <FETCH: "fetch">
+|   <FILTER: "filter">
 |   <FN: "fn">
 |   <FOR: "for">
+|   <FORIEGN: "foriegn">
 |   <FROM: "from">
 |   <FULL: "full">
+|   <FUNCTION: "function">
+|   <GET: "get">
+|   <GLOBAL: "global">
+|   <GRANT: "grant">
 |   <GROUP: "group">
 |   <HAS: "has">
 |   <HAVING: "having">
+|   <HOLD: "hold">
+|   <HOUR: "hour">
 |   <IF: "if">
+|   <IDENTITY: "identity">
+|   <IMMEDIATE: "immediate">
 |   <IN: "in">
+|   <INDICATOR: "indicator">
 |   <INNER: "inner">
+|   <INPUT: "input">
+|   <INOUT: "inout">
+|   <INSENSITIVE: "insensitive">
 |   <INSERT: "insert">
 |   <INTERSECT: "intersect">
+|   <INTERVAL: "interval">
 |   <INTO: "into">
 |   <IS: "is">
+|   <ISOLATION: "isolation">
 |   <JOIN: "join">
 |   <LEFT: "left">
+|   <LANGUAGE: "language">
+|   <LARGE: "large">
+|   <LEADING: "leading">
 |   <LIKE: "like">
 |   <LIMIT: "limit">
 |   <LOCAL: "local">
 |   <LOOP: "loop">
 |   <MAKEDEP: "makedep">
 |   <MAKENOTDEP: "makenotdep">
+|   <MATCH: "match">
+|   <MERGE: "merge">
+|   <METHOD: "method">
+|   <MINUTE: "minute">
+|   <MODIFIES: "modifies">
+|   <MODULE: "module">
+|   <MONTH: "month">
+|   <NATURAL: "natural">
+|   <NEW: "new">
 |	<NOCACHE: "nocache">
+|   <NO: "no">
+|   <NONE: "none">
 |   <NOT: "not">
 |   <NULL: "null">
+|   <OF: "of">
+|   <OLD: "old">
 |   <ON: "on">
+|   <ONLY: "only">
 |   <OJ: "oj">
+|   <OPEN: "open">
 |   <OPTION: "option">
 |   <OR: "or">
 |   <ORDER: "order">
 |   <OUTER: "outer">
+|   <OUTPUT: "output">
+|   <OVER: "over">
+|   <OVERLAPS: "OVERLAPS">
+|   <PARAMETER: "parameter">
+|   <PARTITION: "partition">
 |   <PLANONLY: "planonly">
+|   <PRECISION: "precision">
+|   <PREPARE: "prepare">
+|   <PRIMARY: "primary">
 |   <PROCEDURE: "procedure">
+|   <RANGE: "range">
+|   <READS: "reads">
+|   <RECURSIVE: "recursive">
+|   <REFERENCES: "REFERENCES">
+|   <REFERENCING: "REFERENCING">
+|   <RETURN: "return">
+|   <RETURNS: "returns">
+|   <REVOKE: "REVOKE">
 |   <RIGHT: "right">
+|   <ROLLBACK: "ROLLBACK">
+|   <ROLLUP: "ROLLUP">
+|   <ROW: "row">
+|   <ROWS: "rows">
+|   <SAVEPOINT: "savepoint">
+|   <SCROLL: "scroll">
+|   <SEARCH: "search">
+|   <SECOND: "second">
 |   <SELECT: "select">
+|   <SENSITIVE: "sensitive">
+|   <SESSION_USER: "session_user">
 |   <SET: "set">
 |   <SHOWPLAN: "showplan">
+|   <SIMILAR: "similar">
+|   <SPECIFIC: "specific">
 |   <SOME: "some">
+|   <SQL: "sql">
+|   <SQLEXCEPTION: "sqlexception">
+|   <SQLSTATE: "sqlstate">
+|   <SQLWARNING: "sqlwarning">
+|   <START: "start">
+|   <STATIC: "static">
+|   <SYSTEM: "system">
+|   <SYSTEM_USER: "system_user">
 |   <TABLE: "table">
 |   <TEMPORARY: "temporary">
 |   <THEN: "then">
+|   <TIMEZONE_HOUR: "timezone_hour">
+|   <TIMEZONE_MINUTE: "timezone_minute">
+|   <TO: "to">
+|   <TRAILING: "trailing">
 |   <TRANSLATE: "translate">
+|   <TRIGGER: "trigger">
 |   <TRUE: "true">
 |   <UNION: "union">
+|   <UNIQUE: "unique">
 |   <UNKNOWN: "unknown">
+|   <USER: "user">
 |   <UPDATE: "update">
 |   <USING: "using">
+|   <VALUE: "value">
 |   <VALUES: "values">
 |   <VIRTUAL: "virtual">
 |   <WHEN: "when">
+|   <WHENEVER: "whenever">
 |   <WHERE: "where">
 |   <WITH: "with">
 |   <WHILE: "while">
+|   <WINDOW: "window">
+|   <WITHIN: "within">
+|   <WITHOUT: "without">
+|   <YEAR: "year">
 }
 
+TOKEN : /* SQL/XML Reserved words */
+{
+    <XMLAGG: "xmlagg">
+|   <XMLATTRIBUTES: "xmlattributes">
+|   <XMLBINARY: "xmlbinary">
+|   <XMLCONCAT: "xmlconcat">
+|   <XMLCOMMENT: "xmlcomment">
+|   <XMLELEMENT: "xmlelement">
+|   <XMLFOREST: "xmlforest">
+|   <XMLNAMESPACES: "xmlnamespaces">
+|   <XMLPARSE: "xmlparse">
+|   <XMLPI: "xmlpi">
+|   <XMLROOT: "xmlroot">
+|   <XMLSERIALIZE: "xmlserialize">
+}
+
+TOKEN : /* SQL/MED Reserved words */
+{
+    <DATALINK: "datalink">
+|   <DLNEWCOPY: "dlnewcopy">
+|   <DLPREVIOUSCOPY: "dlpreviouscopy">
+|   <DLURLCOMPLETE: "dlurlcomplete">
+|   <DLURLCOMPLETEWRITE: "dlurlcompletewrite">
+|   <DLURLCOMPLETEONLY: "dlurlcompleteonly">
+|   <DLURLPATH: "dlurlpath">
+|   <DLURLPATHWRITE: "dlurlpathwrite">
+|   <DLURLPATHONLY: "dlurlpathonly">
+|   <DLURLSCHEME: "dlurlscheme">
+|   <DLURLSERVER: "dlurlserver">
+|   <DLVALUE: "dlvalue">
+|   <IMPORT: "import">
+}
+
 TOKEN : /* Special function words */
 {
 	<SQL_TSI_FRAC_SECOND: "SQL_TSI_FRAC_SECOND"> 
@@ -957,14 +1111,8 @@
 	   storedProcedure.setParameter(parameter);
 	 }
 	]
-	call = <ID>
+	<CALL> procName = id()
 	{
-		if (!"call".equalsIgnoreCase(call.image)) { //$NON-NLS-1$
-		   throw new ParseException(QueryPlugin.Util.getString("SQLParser.call_expected")); //$NON-NLS-1$
-		}
-	}
-	procName = id()
-	{
 		storedProcedure.setProcedureName(procName);
 	}
 		
@@ -1007,6 +1155,8 @@
 		 (execToken = <EXEC> { setQueryCacheOption(execToken, info); }) 
 		 |
 		 (execToken = <EXECUTE> { setQueryCacheOption(execToken, info); })
+		 |
+		 (execToken = <CALL> { setQueryCacheOption(execToken, info); })
 		)
 		procName = id()
 		{
@@ -2765,7 +2915,9 @@
 	)		
 	|
 	(
-		(funcToken = <LEFT> | funcToken = <RIGHT> | funcToken = <CHAR>)
+		(funcToken = <LEFT> | funcToken = <RIGHT> | funcToken = <CHAR> | funcToken = <USER> 
+		                    | funcToken = <YEAR> | funcToken = <MONTH> | funcToken = <HOUR>
+		                    | funcToken = <MINUTE> | funcToken = <SECOND>)
 		<LPAREN>
 		[
 			expression = expression(info)
@@ -2869,17 +3021,23 @@
 }
 {
 	(
-		typeToken = <STRING> | 
+		typeToken = <STRING> |
+		typeToken = <VARCHAR> | 
 		typeToken = <BOOLEAN> | 
 		typeToken = <BYTE> | 
+		typeToken = <TINYINT> |
 		typeToken = <SHORT> | 
+		typeToken = <SMALLINT> |
 		typeToken = <CHAR> | 
 		typeToken = <INTEGER> | 
 		typeToken = <LONG> | 
+		typeToken = <BIGINT> |
 		typeToken = <BIGINTEGER> | 
-		typeToken = <FLOAT> | 
+		typeToken = <FLOAT> |
+		typeToken = <REAL> | 
 		typeToken = <DOUBLE> | 
-		typeToken = <BIGDECIMAL> | 
+		typeToken = <BIGDECIMAL> |
+		typeToken = <DECIMAL> | 
 		typeToken = <DATE> | 
 		typeToken = <TIME> |
 		typeToken = <TIMESTAMP> |

Modified: trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties	2010-03-05 14:26:51 UTC (rev 1916)
@@ -33,11 +33,14 @@
 
 AtomicRequestID.Unable_to_create_ID_for_null_AtomicRequestMessage=Unable to create an ID for a null AtomicRequestMessage.
 AtomicRequestID.Unable_to_create_ID_for_AtomicRequestMessage_with_null_RequestID=Unable to create an ID for an AtomicRequestMessage with null RequestID.
+
+ConnectorManager.failed_to_lookup_connector=Failed to look up Connector instance {0}
+ConnectorManager.xa_capbility_not_supported=XA support by the Connector {0} is not possible when "SyncWorkers" is set to false 
+ConnectorManager.not_in_valid_state=Connector is not in OPEN state
 
 ConnectorManagerImpl.Initializing_connector=Initializing connector {0}
 ConnectorManagerImpl.Couldn__t_parse_property=Could not parse property: {0}
 Error_closing_client_connection=Error closing client connection in ConnectorManager
-failed_find_Connector_class=Could not find Connector class {0}
 failed_legacy=The specified connector class {0} is not an instance of a Teiid connector.  This may be due to an inappropriate classpath entry.  An attempt was also made to treat the class as a legacy MetaMatrix connector, however this was not successful either.
 failed_instantiate_Connector_class=Could not instantiate Connector class {0}
 failed_start_Connector=Could not start Connector {0}. {1}
@@ -63,6 +66,7 @@
 no_txn_manager=No Transaction Manger found in the configuration, Failed to start connector \"{0}\"
 Connector_State_not_active=Connector request state is not active for request {0} in Connector {1}
 Missing_required_property=Connector is missing required property {0} or wrong value supplied {1} 
+Cancel_failed=Request {0} failed to cancel.
 
 ConnectorWorker.Can__t_communicate_error_to_client=Can not not communicate error to client
 ConnectorWorker.Command_null=Command is null.
@@ -435,7 +439,7 @@
 TransactionServer.suspended_exist=Suspended work still exists on transaction {0}.
 TransactionServer.failed_to_enlist=Failed to enlist the XAResource in Transaction.
 TransactionServer.failed_to_delist=Failed to delist the XAResource from Transaction.
-
+TransactionServer.rollback_set=Rollback Only has been set on transaction {0}. This may be result of a cancel request.
 TransactionContextImpl.remote_not_supported=Remote connector calls under a transaction are not supported
 
 CodeTableCache.duplicate_key=Duplicate code table ''{0}'' key ''{1}'' value ''{2}''

Modified: trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,6 @@
 
 package com.metamatrix.common.buffer;
 
-import java.util.Properties;
-
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.common.buffer.impl.BufferManagerImpl;
 import com.metamatrix.common.buffer.impl.MemoryStorageManager;
@@ -51,8 +49,7 @@
     public static BufferManager getStandaloneBufferManager() throws MetaMatrixComponentException {
     	if (INSTANCE == null) {
 	        BufferManagerImpl bufferMgr = new BufferManagerImpl();
-	        Properties props = new Properties();
-	        bufferMgr.initialize(props);
+	        bufferMgr.initialize();
 	
 	        // Add unmanaged memory storage manager
 	        bufferMgr.setStorageManager(new MemoryStorageManager());

Copied: trunk/engine/src/test/java/com/metamatrix/common/buffer/impl (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl)

Deleted: trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java	2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,96 +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.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.RandomAccessFile;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Random;
-
-import org.junit.Test;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.common.buffer.StorageManager;
-import com.metamatrix.core.util.UnitTestUtil;
-public class TestFileStorageManager {
-		
-	public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles, String dir) throws MetaMatrixComponentException {
-        FileStorageManager sm = new FileStorageManager();
-        sm.setStorageDirectory(UnitTestUtil.getTestScratchPath() + (dir != null ? File.separator + dir : "")); //$NON-NLS-1$
-        if (maxFileSize != null) {
-        	sm.setMaxFileSizeDirect(maxFileSize);
-        }
-        if (openFiles != null) {
-        	sm.setMaxOpenFiles(openFiles);
-        }
-        sm.initialize();
-        return sm;
-	}
-    
-    @Test public void testAddGetBatch1() throws Exception {
-        StorageManager sm = getStorageManager(null, null, null);        
-        String tsID = "local,1:0";     //$NON-NLS-1$
-        // Add one batch
-        FileStore store = sm.createFileStore(tsID);
-        writeBytes(store);
-        // Get that batch
-        store.remove();
-    }
-            
-    @Test public void testCreatesSpillFiles() throws Exception {
-        FileStorageManager sm = getStorageManager(1024, null, null); // 1KB
-        String tsID = "local,1:0";     //$NON-NLS-1$
-        // Add one batch
-        FileStore store = sm.createFileStore(tsID);
-        writeBytes(store);
-        
-        Map<File, RandomAccessFile> cache = sm.getFileCache();
-        assertEquals(1, cache.size());
-
-        writeBytes(store);
-        
-        assertEquals(2, cache.size());
-        
-        store.remove();
-        
-        assertEquals(0, cache.size());
-    }
-
-    static Random r = new Random();
-    
-	private void writeBytes(FileStore store)
-			throws MetaMatrixComponentException {
-		byte[] bytes = new byte[2048];
-        r.nextBytes(bytes);
-        long start = store.write(bytes, 0, bytes.length);
-        byte[] bytesRead = new byte[2048];        
-        store.readFully(start, bytesRead, 0, bytesRead.length);
-        assertTrue(Arrays.equals(bytes, bytesRead));
-	}
-    
-}

Copied: trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java	                        (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,96 @@
+/*
+ * 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.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Random;
+
+import org.junit.Test;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.FileStore;
+import com.metamatrix.common.buffer.StorageManager;
+import com.metamatrix.core.util.UnitTestUtil;
+public class TestFileStorageManager {
+		
+	public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles, String dir) throws MetaMatrixComponentException {
+        FileStorageManager sm = new FileStorageManager();
+        sm.setStorageDirectory(UnitTestUtil.getTestScratchPath() + (dir != null ? File.separator + dir : "")); //$NON-NLS-1$
+        if (maxFileSize != null) {
+        	sm.setMaxFileSizeDirect(maxFileSize);
+        }
+        if (openFiles != null) {
+        	sm.setMaxOpenFiles(openFiles);
+        }
+        sm.initialize();
+        return sm;
+	}
+    
+    @Test public void testAddGetBatch1() throws Exception {
+        StorageManager sm = getStorageManager(null, null, null);        
+        String tsID = "local,1:0";     //$NON-NLS-1$
+        // Add one batch
+        FileStore store = sm.createFileStore(tsID);
+        writeBytes(store);
+        // Get that batch
+        store.remove();
+    }
+            
+    @Test public void testCreatesSpillFiles() throws Exception {
+        FileStorageManager sm = getStorageManager(1024, null, null); // 1KB
+        String tsID = "local,1:0";     //$NON-NLS-1$
+        // Add one batch
+        FileStore store = sm.createFileStore(tsID);
+        writeBytes(store);
+        
+        Map<File, RandomAccessFile> cache = sm.getFileCache();
+        assertEquals(1, cache.size());
+
+        writeBytes(store);
+        
+        assertEquals(2, cache.size());
+        
+        store.remove();
+        
+        assertEquals(0, cache.size());
+    }
+
+    static Random r = new Random();
+    
+	private void writeBytes(FileStore store)
+			throws MetaMatrixComponentException {
+		byte[] bytes = new byte[2048];
+        r.nextBytes(bytes);
+        long start = store.write(bytes, 0, bytes.length);
+        byte[] bytesRead = new byte[2048];        
+        store.readFully(start, bytesRead, 0, bytesRead.length);
+        assertTrue(Arrays.equals(bytes, bytesRead));
+	}
+    
+}

Copied: trunk/engine/src/test/java/com/metamatrix/common/queue (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/queue)

Deleted: trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java	2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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.common.queue;
-
-import java.sql.Timestamp;
-
-import javax.resource.spi.work.Work;
-
-/**
- */
-public class FakeWorkItem implements Work {
-
-	private static boolean DEBUG = false;
-	
-    long begin = 0;
-    long end = 0;
-    private long waitTime;
-
-    /**
-     * Constructor for FakeWorker.
-     */
-    public FakeWorkItem(long waitTime) {
-        this.waitTime = waitTime;
-    }
-
-    /**
-     * @see com.metamatrix.common.queue.QueueWorker#process(Object)
-     */
-    public void run() {
-        if(begin == 0) {
-            begin = System.currentTimeMillis();
-        }
-
-        log("Processing"); //$NON-NLS-1$
-        
-        // Sleep for time       
-        try { 
-            Thread.sleep(waitTime);
-        } catch(Exception e) {
-        }
-        
-        end = System.currentTimeMillis();
-        log("Done");    //$NON-NLS-1$
-    }
-    
-    private void log(String msg) {
-    	if (DEBUG) {
-    		System.out.println((new Timestamp(System.currentTimeMillis())).toString() + " " +  //$NON-NLS-1$
-    				Thread.currentThread().getName() + ": " + msg);     //$NON-NLS-1$
-    	}
-    }
-
-	@Override
-	public void release() {
-		
-	}
-
-}

Copied: trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java	                        (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,78 @@
+/*
+ * 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.queue;
+
+import java.sql.Timestamp;
+
+import javax.resource.spi.work.Work;
+
+/**
+ */
+public class FakeWorkItem implements Work {
+
+	private static boolean DEBUG = false;
+	
+    long begin = 0;
+    long end = 0;
+    private long waitTime;
+
+    /**
+     * Constructor for FakeWorker.
+     */
+    public FakeWorkItem(long waitTime) {
+        this.waitTime = waitTime;
+    }
+
+    /**
+     * @see com.metamatrix.common.queue.QueueWorker#process(Object)
+     */
+    public void run() {
+        if(begin == 0) {
+            begin = System.currentTimeMillis();
+        }
+
+        log("Processing"); //$NON-NLS-1$
+        
+        // Sleep for time       
+        try { 
+            Thread.sleep(waitTime);
+        } catch(Exception e) {
+        }
+        
+        end = System.currentTimeMillis();
+        log("Done");    //$NON-NLS-1$
+    }
+    
+    private void log(String msg) {
+    	if (DEBUG) {
+    		System.out.println((new Timestamp(System.currentTimeMillis())).toString() + " " +  //$NON-NLS-1$
+    				Thread.currentThread().getName() + ": " + msg);     //$NON-NLS-1$
+    	}
+    }
+
+	@Override
+	public void release() {
+		
+	}
+
+}

Deleted: trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java	2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,73 +0,0 @@
-package com.metamatrix.common.queue;
-
-import javax.resource.spi.work.ExecutionContext;
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkEvent;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkListener;
-import javax.resource.spi.work.WorkManager;
-
-import org.mockito.Mockito;
-
-public class FakeWorkManager implements WorkManager {
-	private Thread t;
-	
-	@Override
-	public void doWork(Work arg0) throws WorkException {
-		execute(arg0, null, true);
-	}
-
-	@Override
-	public void doWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
-		execute(arg0, arg3, true);
-	}
-
-	@Override
-	public void scheduleWork(Work arg0) throws WorkException {
-		execute(arg0, null, false);
-	}
-
-	@Override
-	public void scheduleWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
-		execute(arg0, arg3, false);
-	}
-
-	@Override
-	public long startWork(Work arg0) throws WorkException {
-		execute(arg0, null, false);
-		return 0;
-	}
-
-	@Override
-	public long startWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
-		execute(arg0, arg3, false);
-		return 0;
-	}
-
-	void execute(final Work arg0, final WorkListener arg3, boolean join) throws WorkException {
-		if (arg3 != null) {
-			arg3.workAccepted(Mockito.mock(WorkEvent.class));
-			arg3.workStarted(Mockito.mock(WorkEvent.class));
-		}
-		
-		t = new Thread(new Runnable() {
-			
-			@Override
-			public void run() {
-				arg0.run();
-				if (arg3 != null) {
-					arg3.workCompleted(Mockito.mock(WorkEvent.class));
-				}							
-			}
-		});
-		t.start();
-		if (join) {
-			try {
-				t.join();
-			} catch (InterruptedException e) {
-				throw new WorkException(e);
-			}
-		}
-	}
-		
-}

Copied: trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java	                        (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,73 @@
+package com.metamatrix.common.queue;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+
+import org.mockito.Mockito;
+
+public class FakeWorkManager implements WorkManager {
+	private Thread t;
+	
+	@Override
+	public void doWork(Work arg0) throws WorkException {
+		execute(arg0, null, true);
+	}
+
+	@Override
+	public void doWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
+		execute(arg0, arg3, true);
+	}
+
+	@Override
+	public void scheduleWork(Work arg0) throws WorkException {
+		execute(arg0, null, false);
+	}
+
+	@Override
+	public void scheduleWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
+		execute(arg0, arg3, false);
+	}
+
+	@Override
+	public long startWork(Work arg0) throws WorkException {
+		execute(arg0, null, false);
+		return 0;
+	}
+
+	@Override
+	public long startWork(Work arg0, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
+		execute(arg0, arg3, false);
+		return 0;
+	}
+
+	void execute(final Work arg0, final WorkListener arg3, boolean join) throws WorkException {
+		if (arg3 != null) {
+			arg3.workAccepted(Mockito.mock(WorkEvent.class));
+			arg3.workStarted(Mockito.mock(WorkEvent.class));
+		}
+		
+		t = new Thread(new Runnable() {
+			
+			@Override
+			public void run() {
+				arg0.run();
+				if (arg3 != null) {
+					arg3.workCompleted(Mockito.mock(WorkEvent.class));
+				}							
+			}
+		});
+		t.start();
+		if (join) {
+			try {
+				t.join();
+			} catch (InterruptedException e) {
+				throw new WorkException(e);
+			}
+		}
+	}
+		
+}

Deleted: trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java	2010-03-04 15:18:19 UTC (rev 1900)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,176 +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.queue;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkManager;
-import javax.resource.spi.work.WorkRejectedException;
-
-import org.junit.Test;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-
-/**
- */
-public class TestStatsCapturingWorkManager {
-	
-	private WorkManager manager = new FakeWorkManager();
-
-    @Test public void testQueuing() throws Exception {
-        final long SINGLE_WAIT = 50;
-        final int WORK_ITEMS = 10;
-        final int MAX_THREADS = 5;
-
-        final StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", MAX_THREADS); //$NON-NLS-1$
-        
-        for(int i=0; i<WORK_ITEMS; i++) {
-            pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
-        }
-        
-        pool.shutdown();        
-        pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
-        assertTrue(pool.isTerminated());
-        WorkerPoolStatisticsMetadata stats = pool.getStats();
-        assertEquals(10, stats.getTotalCompleted());
-        assertEquals("Expected threads to be maxed out", MAX_THREADS, stats.getHighestActiveThreads()); //$NON-NLS-1$
-    }
-
-    @Test public void testThreadReuse() throws Exception {
-        final long SINGLE_WAIT = 50;
-        final long NUM_THREADS = 5;
-
-        StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
-        
-        for(int i=0; i<NUM_THREADS; i++) {            
-        	pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
-            
-            try {
-                Thread.sleep(SINGLE_WAIT*2);
-            } catch(InterruptedException e) {                
-            }
-        }
-        
-        pool.shutdown();                
-        
-        WorkerPoolStatisticsMetadata stats = pool.getStats();
-        assertEquals("Expected 1 thread for serial execution", 1, stats.getHighestActiveThreads()); //$NON-NLS-1$
-        
-        pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
-    }
-    
-    @Test(expected=WorkRejectedException.class) public void testShutdown() throws Exception {
-    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
-        pool.shutdown();
-    	pool.scheduleWork(manager, new FakeWorkItem(1));
-    }
-    
-    /*@Test public void testScheduleCancel() throws Exception {
-    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
-    	ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
-    		@Override
-    		public void run() {
-    		}
-    	}, 0, 5, TimeUnit.MILLISECONDS);
-    	future.cancel(true);
-    	assertFalse(future.cancel(true));    	
-    }*/
-    
-    @Test public void testSchedule() throws Exception {
-    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
-        final ArrayList<String> result = new ArrayList<String>(); 
-    	pool.scheduleWork(manager, new Work() {
-			
-			@Override
-			public void run() {
-    			result.add("hello"); //$NON-NLS-1$
-			}
-			
-			@Override
-			public void release() {
-				
-			}
-		}, null, 5);
-    	Thread.sleep(10);
-    	pool.shutdown();
-    	pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
-    	assertEquals(1, result.size());
-    }
-    
-    /*@Test(expected=ExecutionException.class) public void testScheduleException() throws Exception {
-    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
-    	ScheduledFuture<?> future = pool.schedule(new Runnable() {
-    		@Override
-    		public void run() {
-    			throw new RuntimeException();
-    		}
-    	}, 0, TimeUnit.MILLISECONDS);
-    	future.get();
-    }*/
-    
-    /**
-     * Here each execution exceeds the period
-     */
-    /*@Test public void testScheduleRepeated() throws Exception {
-    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
-    	final ArrayList<String> result = new ArrayList<String>();
-    	ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
-    		@Override
-    		public void run() {
-    			result.add("hello"); //$NON-NLS-1$
-    			try {
-					Thread.sleep(75);
-				} catch (InterruptedException e) {
-					throw new RuntimeException(e);
-				}
-    		}
-    	}, 0, 10, TimeUnit.MILLISECONDS);
-    	Thread.sleep(100);
-    	future.cancel(true);
-    	assertEquals(2, result.size());
-    }*/
-    
-    @Test public void testFailingWork() throws Exception {
-    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
-    	final AtomicInteger count = new AtomicInteger();
-    	pool.scheduleWork(manager, new Work() {
-    		@Override
-    		public void run() {
-    			count.getAndIncrement();
-    			throw new RuntimeException();
-    		}
-    		
-    		@Override
-    		public void release() {
-    			
-    		}
-    	});
-    	Thread.sleep(100);
-    	assertEquals(1, count.get());
-    }
-        
-}

Copied: trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java	                        (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,176 @@
+/*
+ * 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.queue;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+
+import org.junit.Test;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+
+/**
+ */
+public class TestStatsCapturingWorkManager {
+	
+	private WorkManager manager = new FakeWorkManager();
+
+    @Test public void testQueuing() throws Exception {
+        final long SINGLE_WAIT = 50;
+        final int WORK_ITEMS = 10;
+        final int MAX_THREADS = 5;
+
+        final StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", MAX_THREADS); //$NON-NLS-1$
+        
+        for(int i=0; i<WORK_ITEMS; i++) {
+            pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
+        }
+        
+        pool.shutdown();        
+        pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+        assertTrue(pool.isTerminated());
+        WorkerPoolStatisticsMetadata stats = pool.getStats();
+        assertEquals(10, stats.getTotalCompleted());
+        assertEquals("Expected threads to be maxed out", MAX_THREADS, stats.getHighestActiveThreads()); //$NON-NLS-1$
+    }
+
+    @Test public void testThreadReuse() throws Exception {
+        final long SINGLE_WAIT = 50;
+        final long NUM_THREADS = 5;
+
+        StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+        
+        for(int i=0; i<NUM_THREADS; i++) {            
+        	pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
+            
+            try {
+                Thread.sleep(SINGLE_WAIT*2);
+            } catch(InterruptedException e) {                
+            }
+        }
+        
+        pool.shutdown();                
+        
+        WorkerPoolStatisticsMetadata stats = pool.getStats();
+        assertEquals("Expected 1 thread for serial execution", 1, stats.getHighestActiveThreads()); //$NON-NLS-1$
+        
+        pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+    }
+    
+    @Test(expected=WorkRejectedException.class) public void testShutdown() throws Exception {
+    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+        pool.shutdown();
+    	pool.scheduleWork(manager, new FakeWorkItem(1));
+    }
+    
+    /*@Test public void testScheduleCancel() throws Exception {
+    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+    	ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
+    		@Override
+    		public void run() {
+    		}
+    	}, 0, 5, TimeUnit.MILLISECONDS);
+    	future.cancel(true);
+    	assertFalse(future.cancel(true));    	
+    }*/
+    
+    @Test public void testSchedule() throws Exception {
+    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+        final ArrayList<String> result = new ArrayList<String>(); 
+    	pool.scheduleWork(manager, new Work() {
+			
+			@Override
+			public void run() {
+    			result.add("hello"); //$NON-NLS-1$
+			}
+			
+			@Override
+			public void release() {
+				
+			}
+		}, null, 5);
+    	Thread.sleep(10);
+    	pool.shutdown();
+    	pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+    	assertEquals(1, result.size());
+    }
+    
+    /*@Test(expected=ExecutionException.class) public void testScheduleException() throws Exception {
+    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+    	ScheduledFuture<?> future = pool.schedule(new Runnable() {
+    		@Override
+    		public void run() {
+    			throw new RuntimeException();
+    		}
+    	}, 0, TimeUnit.MILLISECONDS);
+    	future.get();
+    }*/
+    
+    /**
+     * Here each execution exceeds the period
+     */
+    /*@Test public void testScheduleRepeated() throws Exception {
+    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+    	final ArrayList<String> result = new ArrayList<String>();
+    	ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
+    		@Override
+    		public void run() {
+    			result.add("hello"); //$NON-NLS-1$
+    			try {
+					Thread.sleep(75);
+				} catch (InterruptedException e) {
+					throw new RuntimeException(e);
+				}
+    		}
+    	}, 0, 10, TimeUnit.MILLISECONDS);
+    	Thread.sleep(100);
+    	future.cancel(true);
+    	assertEquals(2, result.size());
+    }*/
+    
+    @Test public void testFailingWork() throws Exception {
+    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+    	final AtomicInteger count = new AtomicInteger();
+    	pool.scheduleWork(manager, new Work() {
+    		@Override
+    		public void run() {
+    			count.getAndIncrement();
+    			throw new RuntimeException();
+    		}
+    		
+    		@Override
+    		public void release() {
+    			
+    		}
+    	});
+    	Thread.sleep(100);
+    	assertEquals(1, count.get());
+    }
+        
+}

Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,79 +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.config;
-
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-import org.teiid.dqp.internal.process.DQPCore;
-
-import com.metamatrix.common.application.DQPConfigSource;
-import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.FakeAbstractService;
-import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.dqp.service.MetadataService;
-
-/**
- */
-public class TestDQPLauncher extends TestCase {
-
-    /**
-     * Constructor for TestDQPLauncher.
-     * @param name
-     */
-    public TestDQPLauncher(String name) {
-        super(name);
-    }
-    
-    public void testLaunch() throws Exception {
-        DQPConfigSource configSource = Mockito.mock(DQPConfigSource.class);
-        Mockito.stub(configSource.getProperties()).toReturn(new Properties());
-        
-        String[] services = new String[] {DQPServiceNames.BUFFER_SERVICE, DQPServiceNames.METADATA_SERVICE, DQPServiceNames.DATA_SERVICE};
-        
-        Mockito.stub(configSource.getServiceInstance(BufferService.class)).toReturn(new FakeBufferService());
-        Mockito.stub(configSource.getServiceInstance(MetadataService.class)).toReturn(new FakeMetadataService());
-        Mockito.stub(configSource.getServiceInstance(DataService.class)).toReturn(new AutoGenDataService());
-        
-        DQPCore dqpCore = new DQPCore();
-        dqpCore.start(configSource);
-    	
-        assertNotNull("DQP should not be null", dqpCore); //$NON-NLS-1$
-        
-        // Check that bootstrapping occurred
-        for(int i=0; i<services.length; i++) {
-            FakeAbstractService svc = (FakeAbstractService)dqpCore.getEnvironment().findService(services[i]);
-            assertEquals("service " + svc.getClass().getName() + " not init'ed correct # of times ", 1, svc.getInitializeCount()); //$NON-NLS-1$ //$NON-NLS-2$
-            assertEquals("service " + svc.getClass().getName() + " not start'ed correct # of times ", 1, svc.getStartCount()); //$NON-NLS-1$ //$NON-NLS-2$
-            assertEquals("service " + svc.getClass().getName() + " not stop'ed correct # of times ", 0, svc.getStopCount()); //$NON-NLS-1$ //$NON-NLS-2$
-        }
-
-    }
-    
-}

Modified: trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,16 +22,12 @@
 
 package com.metamatrix.dqp.message;
 
-import java.util.Date;
+import junit.framework.TestCase;
 
 import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
 import org.teiid.dqp.internal.process.DQPWorkContext;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
 import com.metamatrix.platform.security.api.SessionToken;
 
 public class TestAtomicRequestMessage extends TestCase {
@@ -47,32 +43,30 @@
     public static AtomicRequestMessage example() {
         RequestMessage rm = new RequestMessage();
         DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(2), "foo")); //$NON-NLS-1$
+        workContext.setSessionToken(new SessionToken(2, "foo")); //$NON-NLS-1$
         AtomicRequestMessage message = new AtomicRequestMessage(rm, workContext, 1000);
-        message.setCommand(TestQueryImpl.helpExample());
+        message.setCommand(TestQueryImpl.helpExample(true));
         message.setFetchSize(100);
         message.setPartialResults(true);
-        message.setProcessingTimestamp(new Date(12345678L));
         message.setRequestID(new RequestID(5000L));
         
         //AtomicRequestMessage-specific stuff
-        message.setConnectorBindingID("connectorBindingID"); //$NON-NLS-1$
-        message.setConnectorID(new ConnectorID("10000")); //$NON-NLS-1$
+        message.setConnectorName("connectorBindingID"); //$NON-NLS-1$
         return message;
     }
 
     public void testSerialize() throws Exception {
-    	AtomicRequestMessage copy = UnitTestUtil.helpSerialize(example());
+    	AtomicRequestMessage example = example();
+    	AtomicRequestMessage copy = UnitTestUtil.helpSerialize(example);
 
-        assertEquals(TestQueryImpl.helpExample(), copy.getCommand());
+        assertEquals(TestQueryImpl.helpExample(true), copy.getCommand());
         assertEquals(100, copy.getFetchSize());
 
-        assertEquals(new Date(12345678L), copy.getProcessingTimestamp());
+        assertEquals(example.getProcessingTimestamp(), copy.getProcessingTimestamp());
         assertEquals(new RequestID(5000L), copy.getRequestID());
         assertEquals("2", copy.getWorkContext().getConnectionID()); //$NON-NLS-1$
         //AtomicRequestMessage-specific stuff
-        assertEquals("connectorBindingID", copy.getConnectorBindingID()); //$NON-NLS-1$
-        assertEquals(new ConnectorID("10000"), copy.getConnectorID()); //$NON-NLS-1$
+        assertEquals("connectorBindingID", copy.getConnectorName()); //$NON-NLS-1$
         assertEquals(1000, copy.getAtomicRequestID().getNodeID());
     }
 }

Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,25 +25,19 @@
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Properties;
 
-import org.teiid.connector.metadata.runtime.MetadataStore;
+import javax.resource.spi.work.WorkManager;
+
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
-import org.teiid.dqp.internal.process.DQPWorkContext;
 
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.config.api.ConnectorBinding;
 import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
 import com.metamatrix.query.sql.symbol.SingleElementSymbol;
@@ -52,22 +46,17 @@
  * This data service will automatically generate results when called with a query - basically
  * the same as the old loopback connector.
  */
-public class AutoGenDataService extends FakeAbstractService implements DataService {
+public class AutoGenDataService extends ConnectorManager{
 
     // Number of rows that will be generated for each query
     private int rows = 10;
     private SourceCapabilities caps;
     
-    /**
-     * 
-     */
     public AutoGenDataService() {
-        this(new BasicSourceCapabilities());
+    	super("FakeConnector");
+        caps = new BasicSourceCapabilities();
     }
     
-    public AutoGenDataService(SourceCapabilities caps) {
-    	this.caps = caps;
-    }
 
     public void setRows(int rows) {
         this.rows = rows;
@@ -77,17 +66,9 @@
         return this.rows;
     }
 
-    /* 
-     * @see com.metamatrix.dqp.service.DataService#selectConnector(java.lang.String)
-     */
-    public ConnectorID selectConnector(String connectorBindingID) {
-        return null;
-    }
-    
-	public void executeRequest(AtomicRequestMessage request,
-			ConnectorID connector,
-			ResultsReceiver<AtomicResultsMessage> resultListener)
-			throws MetaMatrixComponentException {
+    @Override
+	public void executeRequest(WorkManager workManager, ResultsReceiver<AtomicResultsMessage> resultListener, AtomicRequestMessage request)
+			throws ConnectorException{
         List projectedSymbols = (request.getCommand()).getProjectedSymbols();               
         List[] results = createResults(projectedSymbols);
                 
@@ -165,94 +146,10 @@
     }
 
     @Override
-    public SourceCapabilities getCapabilities(RequestMessage request,
-    		DQPWorkContext dqpWorkContext, String modelName)
-    		throws MetaMatrixComponentException {
-    	return caps;
+	public SourceCapabilities getCapabilities(){
+        return caps;
     }
-        
-    /** 
-     * @see com.metamatrix.dqp.service.DataService#startConnectorBinding(java.lang.String)
-     * @since 4.3
-     */
-    public void startConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,
-                                                                  MetaMatrixComponentException {
-    }
 
-    /** 
-     * @see com.metamatrix.dqp.service.DataService#stopConnectorBinding(java.lang.String)
-     * @since 4.3
-     */
-    public void stopConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,
-                                                                 MetaMatrixComponentException {
-    }
 
-    /** 
-     * @see com.metamatrix.dqp.service.DataService#getConnectorBindings()
-     * @since 4.3
-     */
-    public List getConnectorBindings() throws MetaMatrixComponentException {
-        return null;
-    }
 
-    /** 
-     * @see com.metamatrix.dqp.service.DataService#getConnectorBindingState(java.lang.String)
-     * @since 4.3
-     */
-    public ConnectorStatus getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {
-        return null;
-    }
-
-    /** 
-     * @see com.metamatrix.dqp.service.DataService#getConnectorBinding(java.lang.String)
-     * @since 4.3
-     */
-    public ConnectorBinding getConnectorBinding(String connectorBindingName) throws MetaMatrixComponentException {
-        return null;
-    }
-
-    /** 
-     * @see com.metamatrix.dqp.service.DataService#getConnectorBindingStatistics(java.lang.String)
-     * @since 4.3
-     */
-    public Collection getConnectorBindingStatistics(String connectorBindingName) throws MetaMatrixComponentException {
-        return null;
-    }
-    
-    /** 
-     * @see com.metamatrix.dqp.service.DataService#getConnectionPoolStatistics(java.lang.String)
-     * @since 6.1
-     */
-    public Collection getConnectionPoolStatistics(String connectorBindingName) throws MetaMatrixComponentException {
-    	return null;
-    } 
-
-    /** 
-     * @see com.metamatrix.dqp.service.DataService#clearConnectorBindingCache(java.lang.String)
-     * @since 4.3
-     */
-    public void clearConnectorBindingCache(String connectorBindingName) throws MetaMatrixComponentException {
-    }
-
-	public void cancelRequest(AtomicRequestID request, ConnectorID connectorId)
-			throws MetaMatrixComponentException {
-		
-	}
-
-	public void closeRequest(AtomicRequestID request, ConnectorID connectorId)
-			throws MetaMatrixComponentException {
-		
-	}
-
-	public void requestBatch(AtomicRequestID request, ConnectorID connectorId)
-			throws MetaMatrixComponentException {
-		
-	}
-	
-    @Override
-    public MetadataStore getConnectorMetadata(String vdbName,
-    		String vdbVersion, String modelName, Properties importProperties) {
-    	throw new UnsupportedOperationException();
-    }
-
 }

Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAbstractService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAbstractService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAbstractService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,82 +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.service;
-
-import java.util.Properties;
-
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-
-/**
- */
-public class FakeAbstractService implements ApplicationService {
-
-    private int initializeCount = 0;
-    private int startCount = 0;
-    private int stopCount = 0;
-     
-
-    /**
-     * 
-     */
-    public FakeAbstractService() {
-    }
-
-    /* 
-     * @see com.metamatrix.common.application.ApplicationService#initialize(java.util.Properties)
-     */
-    public void initialize(Properties props) throws ApplicationInitializationException {
-        this.initializeCount++;
-    }
-
-    /* 
-     * @see com.metamatrix.common.application.ApplicationService#start(com.metamatrix.common.application.ApplicationEnvironment)
-     */
-    public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
-        this.startCount++;
-
-    }
-
-    /* 
-     * @see com.metamatrix.common.application.ApplicationService#stop()
-     */
-    public void stop() throws ApplicationLifecycleException {
-        this.stopCount++;
-
-    }
-    
-    public int getInitializeCount() {
-        return this.initializeCount;
-    }
-
-    public int getStartCount() {
-        return this.startCount;
-    }
-
-    public int getStopCount() {
-        return this.stopCount;
-    }
-
-}

Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAuthorizationService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAuthorizationService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeAuthorizationService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,19 +22,18 @@
 
 package com.metamatrix.dqp.service;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
 
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.security.AuthorizationException;
 import com.metamatrix.api.exception.security.AuthorizationMgmtException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.platform.security.api.AuthorizationPolicy;
 import com.metamatrix.platform.security.api.AuthorizationRealm;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-import com.metamatrix.platform.security.api.SessionToken;
 
 /**
  */
@@ -48,14 +47,14 @@
         this.defaultAllow = defaultAllow;
     }
 
-    public void addResource(String connectionID, int action, String resource) {
-        knownResources.add(new Resource(connectionID, action, resource));
+    public void addResource(int action, String resource) {
+        knownResources.add(new Resource(action, resource));
     }
 
     /*
      * @see com.metamatrix.dqp.service.AuthorizationService#getInaccessibleResources(java.lang.String, int, java.util.Collection, int)
      */
-    public Collection getInaccessibleResources(String connectionID, int action, Collection resources, int context)
+    public Collection getInaccessibleResources(int action, Collection resources, int context)
         throws MetaMatrixComponentException {
 
         List found = new ArrayList();
@@ -68,7 +67,7 @@
         while(rIter.hasNext()) {
             String resourceName = (String) rIter.next();
 
-            Resource key = new Resource(connectionID, action, resourceName);
+            Resource key = new Resource(action, resourceName);
             
             boolean foundResource = knownResources.contains(key);
             if (!foundResource && !defaultAllow) {
@@ -90,34 +89,11 @@
         return true;
     }
 
-    /*
-     * @see com.metamatrix.common.application.ApplicationService#initialize(java.util.Properties)
-     */
-    public void initialize(Properties props) throws ApplicationInitializationException {
-
-    }
-
-    /*
-     * @see com.metamatrix.common.application.ApplicationService#start(com.metamatrix.common.application.ApplicationEnvironment)
-     */
-    public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
-
-    }
-
-    /*
-     * @see com.metamatrix.common.application.ApplicationService#stop()
-     */
-    public void stop() throws ApplicationLifecycleException {
-
-    }
-
     private static class Resource {
-        public String connectionID;
         public int action;
         public String resource;
 
-        public Resource(String connectionID, int action, String resource) {
-            this.connectionID = connectionID;
+        public Resource(int action, String resource) {
             this.action = action;
             this.resource = resource;
         }
@@ -148,7 +124,6 @@
             Resource other = (Resource)obj;
 
             return other.action == this.action
-                   && other.connectionID.equalsIgnoreCase(this.connectionID)
                    && other.resource.equalsIgnoreCase(this.resource);
         }
     }
@@ -156,14 +131,13 @@
     /** 
      * @see com.metamatrix.dqp.service.AuthorizationService#hasRole(java.lang.String, java.lang.String, java.lang.String)
      */
-    public boolean hasRole(String connectionID,
-                           String roleType,
+    public boolean hasRole(String roleType,
                            String roleName) throws MetaMatrixComponentException {
         return false;
     }
 
 	@Override
-	public boolean isCallerInRole(SessionToken session, String roleName)
+	public boolean isCallerInRole(String roleName)
 			throws AuthorizationMgmtException {
 		return false;
 	}
@@ -176,12 +150,6 @@
 	}
 
 	@Override
-	public Collection<String> getRoleNamesForPrincipal(MetaMatrixPrincipalName principal) throws InvalidSessionException,
-			AuthorizationException, AuthorizationMgmtException {
-		return null;
-	}
-
-	@Override
 	public void updatePoliciesInRealm(AuthorizationRealm realm,
 			Collection<AuthorizationPolicy> policies)
 			throws AuthorizationMgmtException {

Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,18 +22,17 @@
 
 package com.metamatrix.dqp.service;
 
-import java.util.Properties;
-
 import org.teiid.dqp.internal.cache.DQPContextCache;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.cache.CacheFactory;
 import com.metamatrix.cache.FakeCache.FakeCacheFactory;
 import com.metamatrix.common.buffer.BufferManager;
 import com.metamatrix.common.buffer.BufferManagerFactory;
 
 /**
  */
-public class FakeBufferService extends FakeAbstractService implements BufferService {
+public class FakeBufferService implements BufferService {
 
     private BufferManager bufferMgr;
     
@@ -59,6 +58,14 @@
 
 	@Override
 	public DQPContextCache getContextCache() {
-		return new DQPContextCache(new Properties(), new FakeCacheFactory()); 
+		DQPContextCache cache =  new DQPContextCache();
+		cache.setCacheFactory(new FakeCacheFactory());
+		cache.setProcessName("test");
+		return cache;
 	}
+
+	@Override
+	public CacheFactory getCacheFactory() {
+		return null;
+	}
 }

Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,90 +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.service;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.metadata.CompositeMetadataStore;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-/**
- */
-public class FakeMetadataService extends FakeAbstractService implements MetadataService {
-
-    /**
-     * Map of vdbname.vdbversion -> QueryMetadataInterface 
-     */
-    private Map vdbMap = new HashMap();
-    
-    /**
-     * 
-     */
-    public FakeMetadataService() {
-        super();
-        
-        // Load some default VDBs
-        addVdb(null, null, FakeMetadataFactory.exampleBQTCached());
-        addVdb("bqt", "1", FakeMetadataFactory.exampleBQTCached()); //$NON-NLS-1$ //$NON-NLS-2$
-        addVdb("example1", "1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    private String getKey(String vdbName, String vdbVersion) {
-        if(vdbName == null) {
-            vdbName = ""; //$NON-NLS-1$
-        } 
-        if(vdbVersion == null) {
-            vdbVersion = ""; //$NON-NLS-1$
-        }
-        String vdbID = vdbName + "." + vdbVersion; //$NON-NLS-1$
-        return vdbID.toLowerCase();        
-    }
-
-    public synchronized void addVdb(String vdbName, String vdbVersion, QueryMetadataInterface metadata) {
-        this.vdbMap.put(getKey(vdbName, vdbVersion), metadata);
-    }
-
-    /* 
-     * @see com.metamatrix.dqp.service.MetadataService#lookupMetadata(java.lang.String, java.lang.String)
-     */
-    public synchronized QueryMetadataInterface lookupMetadata(String vdbName, String vdbVersion) {
-        return (QueryMetadataInterface) vdbMap.get(getKey(vdbName, vdbVersion));
-    }
-
-	@Override
-	public CompositeMetadataStore getMetadataObjectSource(String vdbName,
-			String vdbVersion) throws MetaMatrixComponentException {
-		return null;
-	}
-	
-	@Override
-	public Map<String, Datatype> getBuiltinDatatypes()
-			throws MetaMatrixComponentException {
-		return null;
-	}
-
-}

Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,276 +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.service;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.vdb.runtime.VDBKey;
-
-/**
- */
-public class FakeVDBService extends FakeAbstractService implements VDBService {
-    private Map vdbsMap = new HashMap();    // VdbInfo -> Map<Model name (upper), <ModelInfo>>
-    private Map bindingNames = new HashMap();   // binding UUID -> binding name
-    public Collection publicFiles = new HashSet();
-    private boolean defaultPrivate;
-    
-    private static class FakeModel {
-        String modelName;
-        boolean multiSource = false;
-        int visibility = ModelInfo.PUBLIC;;
-        List bindingNames = new ArrayList();    // mapped to UUIDs
-        List bindingUUIDs = new ArrayList();    // mapped to names
-    }
-    
-    public void setDefaultPrivate(boolean defaultPrivate) {
-		this.defaultPrivate = defaultPrivate;
-	}
-    
-    /**
-     * Method for testing - add a model with the specified properties.  The vdb will be created 
-     * automatically under the hood. 
-     * @param vdbName vdb name
-     * @param version vdb version
-     * @param modelName model name
-     * @param visibility MODEL_PUBLIC or MODEL_PRIVATE
-     * @param multiSource true if model is multi-source
-     * @since 4.2
-     */
-    public void addModel(String vdbName, String version, String modelName, int visibility, boolean multiSource) {
-        FakeModel model = new FakeModel();
-        model.visibility = visibility;
-        model.multiSource = multiSource;
-        model.modelName = modelName;
-        
-        VDBKey vdb = new VDBKey(vdbName, version);
-        Map vdbModels = (Map)this.vdbsMap.get(vdb);
-        if(vdbModels == null) {
-            vdbModels = new HashMap();
-            vdbsMap.put(vdb, vdbModels);
-        }
-        vdbModels.put(modelName.toUpperCase(), model);
-    }   
-
-    /**
-     * Method for testing - add a binding to a model with the specified names.  If the model does not
-     * exist, it will be created automatically with default properties.
-     * 
-     * @param vdbName vdb name
-     * @param version vdb version
-     * @param model
-     * @param connectorBindingID
-     * @param connectorBindingName
-     * @since 4.2
-     */
-    public void addBinding(String vdbName, String version, String modelName, String connectorBindingID, String connectorBindingName) {
-        FakeModel model = null;
-        
-        // Find existing model
-        VDBKey vdb = new VDBKey(vdbName, version);
-        Map vdbModels = (Map)this.vdbsMap.get(vdb);
-        if(vdbModels != null) {
-            model = (FakeModel) vdbModels.get(modelName.toUpperCase());
-        }
-
-        // If model hasn't been added yet, add it with defaults
-        if(model == null) {
-            addModel(vdbName, version, modelName, ModelInfo.PUBLIC, false);
-            
-            // Re-lookup
-            vdbModels = (Map)this.vdbsMap.get(vdb);
-            model = (FakeModel) vdbModels.get(modelName.toUpperCase());            
-        }
-        
-        // Add binding to model
-        model.bindingNames.add(connectorBindingName);
-        model.bindingUUIDs.add(connectorBindingID);
-        
-        // Add uuid to name mapping
-        this.bindingNames.put(connectorBindingID, connectorBindingName);               
-    }
-    
-    /* (non-Javadoc)
-     * @see com.metamatrix.dqp.service.VDBService#isActiveVDB(java.lang.String, java.lang.String)
-     */
-    public boolean isActiveVDB(String vdbName, String vdbVersion) {
-        return vdbsMap.containsKey(new VDBKey(vdbName, vdbVersion));
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.dqp.service.VDBService#getConnectorBinding(java.lang.String, java.lang.String, java.lang.String)
-     */
-    public List getConnectorBindingNames(String vdbName, String vdbVersion, String modelName) {
-    	VDBKey vdb = new VDBKey(vdbName, vdbVersion);
-        Map vdbModels = (Map)this.vdbsMap.get(vdb);
-        if(vdbModels != null) {
-            FakeModel model = (FakeModel) vdbModels.get(modelName.toUpperCase());
-            return model.bindingUUIDs;
-        }
-        
-        return Collections.EMPTY_LIST;
-    }
-    
-    /*
-     *  (non-Javadoc)
-     * @see com.metamatrix.dqp.service.VDBService#getConnectorName(java.lang.String)
-     */
-    public String getConnectorName(String connectorBindingID) {
-        return (String) this.bindingNames.get(connectorBindingID);
-    }
-    
-    /* (non-Javadoc)
-     * @see com.metamatrix.dqp.service.VDBService#getModelVisibility(java.lang.String, java.lang.String, java.lang.String)
-     */
-    public int getModelVisibility(String vdbName, String vdbVersion, String modelName) {
-    	VDBKey vdb = new VDBKey(vdbName, vdbVersion);
-        Map vdbModels = (Map)this.vdbsMap.get(vdb);
-        if(vdbModels != null) {
-            FakeModel model = (FakeModel) vdbModels.get(modelName.toUpperCase());
-            if(model != null) {
-                return model.visibility;
-            } 
-        }
-        if (defaultPrivate) {
-        	return ModelInfo.PRIVATE;
-        }
-        return ModelInfo.PUBLIC;
-    }
-    
-    /** 
-     * @see com.metamatrix.dqp.service.VDBConfiguration#getFileVisibility(java.lang.String, java.lang.String, java.lang.String)
-     * @since 4.2
-     */
-    public int getFileVisibility(String vdbName, String vdbVersion, String pathInVDB) throws MetaMatrixComponentException {
-    	if(this.publicFiles.contains(pathInVDB)) {
-            return ModelInfo.PUBLIC;
-        }
-        return ModelInfo.PRIVATE;
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.dqp.service.VDBService#getVDBResourceFile(java.lang.String, java.lang.String)
-     */
-    public String getVDBResourceFile(String vdbName, String vdbVersion) {
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.common.application.ApplicationService#initialize(java.util.Properties)
-     */
-    public void initialize(Properties props) throws ApplicationInitializationException {
-//        vdbsMap = props;
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.common.application.ApplicationService#start(com.metamatrix.common.application.ApplicationEnvironment)
-     */
-    public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
-        // TODO Auto-generated method stub
-
-    }
-
-    /* (non-Javadoc)
-     * @see com.metamatrix.common.application.ApplicationService#stop()
-     */
-    public void stop() throws ApplicationLifecycleException {
-        // TODO Auto-generated method stub
-
-    }
-
-    public List getMultiSourceModels(String vdbName,
-                                     String vdbVersion) throws MetaMatrixComponentException {
-
-    	VDBKey vdb = new VDBKey(vdbName, vdbVersion);
-        Map vdbModels = (Map)this.vdbsMap.get(vdb);
-        if(vdbModels != null) {
-            List multiModels = new ArrayList();
-            
-            Iterator modelIter = vdbModels.values().iterator();
-            while(modelIter.hasNext()) {
-                FakeModel model = (FakeModel) modelIter.next();
-                if(model.multiSource) {
-                    multiModels.add(model.modelName);
-                }
-            }
-            
-            return multiModels;
-        }
-        
-        return Collections.EMPTY_LIST;
-    }
-
-    /** 
-     * @see com.metamatrix.dqp.service.VDBService#getVDBResource(java.lang.String, java.lang.String)
-     * @since 4.3
-     */
-    public InputStream getVDBResource(String vdbName,
-                                 String vdbVersion) throws MetaMatrixComponentException {
-        return null;
-    }
-
-    /** 
-     * @see com.metamatrix.dqp.service.VDBService#getVDBStatus(java.lang.String, java.lang.String)
-     * @since 4.3
-     */
-    public int getVDBStatus(String vdbName,
-                            String vdbVersion) throws MetaMatrixComponentException {
-        return 0;
-    }
-
-    /** 
-     * @see com.metamatrix.dqp.service.VDBService#changeVDBStatus(java.lang.String, java.lang.String, int)
-     * @since 4.3
-     */
-    public void changeVDBStatus(String vdbName,String vdbVersion,int status) throws ApplicationLifecycleException,MetaMatrixComponentException {
-    }
-
-    /** 
-     * @see com.metamatrix.dqp.service.VDBService#getAvailableVDBs()
-     * @since 4.3
-     */
-    public List getAvailableVDBs() throws MetaMatrixComponentException {
-        return null;
-    }
-    
-    @Override
-    public VDBArchive getVDB(String vdbName, String vdbVersion)
-    		throws MetaMatrixComponentException {
-    	throw new UnsupportedOperationException();
-    }
-
-}

Modified: trunk/engine/src/test/java/com/metamatrix/query/analysis/TestAnalysisRecord.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/analysis/TestAnalysisRecord.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/analysis/TestAnalysisRecord.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,7 +24,7 @@
 
 import java.util.*;
 
-import com.metamatrix.core.util.StringUtilities;
+import com.metamatrix.core.util.StringUtil;
 
 import junit.framework.TestCase;
 
@@ -75,7 +75,7 @@
         rec.println("b"); //$NON-NLS-1$
         
         String log = rec.getDebugLog();
-        assertEquals("a" + StringUtilities.LINE_SEPARATOR + "b" + StringUtilities.LINE_SEPARATOR, log); //$NON-NLS-1$ //$NON-NLS-2$
+        assertEquals("a" + StringUtil.LINE_SEPARATOR + "b" + StringUtil.LINE_SEPARATOR, log); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
 }

Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -33,9 +33,9 @@
 import java.util.Properties;
 
 import org.junit.Test;
+import org.teiid.connector.language.SQLReservedWords;
 
 import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.symbol.Constant;
 import com.metamatrix.query.unittest.TimestampUtil;
 import com.metamatrix.query.util.CommandContext;
@@ -845,18 +845,18 @@
     }
 
     @Test public void testTimestampAdd2() throws Exception {
-    	assertEquals(TimestampUtil.createTimestamp(103, 11, 1, 18, 20, 30, 0), FunctionMethods.timestampAdd(ReservedWords.SQL_TSI_HOUR, 3, TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0)));
+    	assertEquals(TimestampUtil.createTimestamp(103, 11, 1, 18, 20, 30, 0), FunctionMethods.timestampAdd(SQLReservedWords.SQL_TSI_HOUR, 3, TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0)));
     }
 
     @Test public void testTimestampDiffTimeStamp_FracSec_1() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND, 
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND, 
                               TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 1),
                               TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 100000000),
                               new Long(99999999));
     }
 
     @Test public void testTimestampDiffTimeStamp_FracSec_2() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
                               // 1 day (8.64 x 10^10 nanos) and 1 nano
                               TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 2),
                               TimestampUtil.createTimestamp((2001-1900), 5, 22, 3, 9, 35, 3),
@@ -864,7 +864,7 @@
     }
 
     @Test public void testTimestampDiffTimeStamp_FracSec_3() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
                               // 1 day (8.64 x 10^10 nanos) less 1 nano
                               TimestampUtil.createTimestamp((2001-1900), 5, 22, 3, 9, 35, 2),
                               TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 3),
@@ -872,28 +872,28 @@
     }
 
     @Test public void testTimestampDiffTimeStamp_FracSec_4() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
                               TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0, 1),
                               TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0, 3),
                               new Long(00000002));
     }
 
     @Test public void testTimestampDiffTimeStamp_FracSec_5() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
                               TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0, 1),
                               TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0, 10),
                               new Long(9));
     }
 
     @Test public void testTimestampDiffTimeStamp_FracSec_6() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
                               TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0, 2),
                               TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0, 3),
                               new Long(1));
     }
 
     @Test public void testTimestampDiffTimeStamp_FracSec_7() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
                               // 1 nano diff
                               TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 2),
                               TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 3),
@@ -901,7 +901,7 @@
     }
 
     @Test public void testTimestampDiffTimeStamp_FracSec_8() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
                               // 1 nano diff
                               TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 3),
                               TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 2),
@@ -909,98 +909,98 @@
     }
 
     @Test public void testTimestampDiffTimeStamp_Min_1() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
                               TimestampUtil.createTimestamp(0, 0, 0, 2, 34, 12, 0),
                               TimestampUtil.createTimestamp(0, 0, 0, 12, 0, 0, 0),
                               new Long(565));
     }
 
     @Test public void testTimestampDiffTimeStamp_Min_2() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
                               TimestampUtil.createTimestamp((2001-1900), 0, 0, 2, 0, 0, 0),
                               TimestampUtil.createTimestamp((2001-1900), 0, 0, 0, 33, 12, 0),
                               new Long(-86));
     }
 
     @Test public void testTimestampDiffTimeStamp_Min_3() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
                               TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07, 58, 65497),
                               TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25, 42, 483219),
                               new Long(4277));
     }
 
     @Test public void testTimestampDiffTimeStamp_Min_4() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
                               TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07, 58, 0),
                               TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25, 42, 0),
                               new Long(4277));
     }
 
     @Test public void testTimestampDiffTimeStamp_Min_5() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
                               TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0, 1),
                               TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0, 0),
                               new Long(0));
     }
 
     @Test public void testTimestampDiffTimeStamp_Hour_1() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_HOUR,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR,
                               TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 0, 0, 0),
                               TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 59, 59, 999999999),
                               new Long(0));
     }
 
     @Test public void testTimestampDiffTimeStamp_Week_1() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_WEEK,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_WEEK,
                               TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 100),
                               TimestampUtil.createTimestamp((2001-1900), 4, 2, 5, 19, 35, 500),
                               new Long(-7));
     }
 
     @Test public void testTimestampDiffTimeStamp_Month_1() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
                               TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0, 0),
                               TimestampUtil.createTimestamp((2004-1900), 11, 20, 12, 0, 0, 0),
                               new Long(7));
     }
 
     @Test public void testTimestampDiffTimeStamp_Month_2() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
                               TimestampUtil.createTimestamp((2004-1900), 5, 1, 0, 0, 0, 1000000),
                               TimestampUtil.createTimestamp((2004-1900), 11, 1, 12, 0, 0, 1),
                               new Long(6));
     }
 
     @Test public void testTimestampDiffTimeStamp_Month_3() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
                               TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0, 1),
                               TimestampUtil.createTimestamp((2004-1900), 11, 18, 12, 0, 0, 1000000),
                               new Long(7));
     }
 
     @Test public void testTimestampDiffTimeStamp_Month_4() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
                               TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 0, 1000000),
                               TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0, 0),
                               new Long(7));
     }
 
     @Test public void testTimestampDiffTimeStamp_Month_5() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
                               TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1, 0),
                               TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0, 0),
                               new Long(7));
     }
 
     @Test public void testTimestampDiffTimeStamp_Month_6() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
                               TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1, 0),
                               TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 2, 0),
                               new Long(7));
     }
 
     @Test public void testTimestampDiffTimeStamp_Day_1() throws Exception {
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_DAY,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_DAY,
                               TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0, 0),
                               TimestampUtil.createTimestamp((2004-1900), 3, 1, 0, 0, 0, 0),
                               new Long(31));
@@ -1008,20 +1008,20 @@
 
     @Test public void testTimestampDiffTimeStamp_Day_2() throws Exception {
         // Leap year
-        helpTestTimestampDiff(ReservedWords.SQL_TSI_DAY,
+        helpTestTimestampDiff(SQLReservedWords.SQL_TSI_DAY,
                               TimestampUtil.createTimestamp((2004-1900), 1, 1, 0, 0, 0, 0),
                               TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0, 0),
                               new Long(29));
     }
 
 	@Test public void testTimestampDiffTime_Hour_1() throws Exception {
-		helpTestTimestampDiff(ReservedWords.SQL_TSI_HOUR, new Timestamp(
+		helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR, new Timestamp(
 				TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(
 				TimestampUtil.createTime(5, 5, 36).getTime()), new Long(2));
 	}
 
 	@Test public void testTimestampDiffTime_Hour_2() throws Exception {
-		helpTestTimestampDiff(ReservedWords.SQL_TSI_HOUR, new Timestamp(
+		helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR, new Timestamp(
 				TimestampUtil.createTime(5, 0, 30).getTime()), new Timestamp(
 				TimestampUtil.createTime(3, 0, 31).getTime()), new Long(-1));
 	}

Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,7 +22,12 @@
 
 package com.metamatrix.query.function;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -30,6 +35,7 @@
 import java.sql.Timestamp;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.Properties;
 import java.util.TimeZone;
@@ -38,13 +44,12 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.language.SQLReservedWords;
 
 import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.api.exception.query.InvalidFunctionException;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.common.util.TimestampWithTimezone;
 import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.unittest.TimestampUtil;
 import com.metamatrix.query.util.CommandContext;
 
@@ -63,7 +68,7 @@
 	private static final Class T_DATE = DataTypeManager.DefaultDataClasses.DATE;
 	private static final Class T_TIMESTAMP = DataTypeManager.DefaultDataClasses.TIMESTAMP;
 	
-	private FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
+	private FunctionLibrary library = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Collections.EMPTY_LIST)));
 
 	@Before public void setUp() { 
 		TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-06:00")); //$NON-NLS-1$ 
@@ -175,14 +180,14 @@
         } 
 	}
     
-    private void helpInvokeMethod(String fname, Class[] types, Object[] inputs, CommandContext context, Object expectedOutput) throws InvalidFunctionException, FunctionExecutionException {
+    private void helpInvokeMethod(String fname, Class[] types, Object[] inputs, CommandContext context, Object expectedOutput) throws FunctionExecutionException {
     	Object actualOutput = helpInvokeMethod(fname, types, inputs, context);
         assertEquals("Actual function output not equal to expected: ", expectedOutput, actualOutput); //$NON-NLS-1$
     }
 
 	private Object helpInvokeMethod(String fname, Class[] types,
 			Object[] inputs, CommandContext context)
-			throws InvalidFunctionException, FunctionExecutionException {
+			throws FunctionExecutionException {
 		if (types == null) {
             // Build type signature
             types = new Class[inputs.length];
@@ -196,27 +201,27 @@
         Object actualOutput = null;
         // Find function descriptor
         FunctionDescriptor descriptor = library.findFunction(fname, types);         
-        if (descriptor != null && descriptor.requiresContext()) {
+        if (descriptor.requiresContext()) {
             // Invoke function with inputs
             Object[] in = new Object[inputs.length+1];
             in[0] = context;
             for (int i = 0; i < inputs.length; i++) {
                 in[i+1] = inputs[i];
             }
-            actualOutput = library.invokeFunction(descriptor, in);
+            actualOutput = descriptor.invokeFunction(in);
         }
         else {
             // Invoke function with inputs
-            actualOutput = library.invokeFunction(descriptor, inputs);                
+            actualOutput = descriptor.invokeFunction(inputs);                
         }
 		return actualOutput;
 	}
     	    
-	private void helpInvokeMethodFail(String fname, Object[] inputs) throws InvalidFunctionException {
+	private void helpInvokeMethodFail(String fname, Object[] inputs) {
 		   helpInvokeMethodFail(fname, null, inputs);
 	}	
     	
-    private void helpInvokeMethodFail(String fname, Class<?> types[], Object[] inputs) throws InvalidFunctionException {
+    private void helpInvokeMethodFail(String fname, Class<?> types[], Object[] inputs) {
     	try {
             helpInvokeMethod(fname, types, inputs, null);
             fail("expected exception"); //$NON-NLS-1$
@@ -460,15 +465,13 @@
 
     // Walk through all functions by metadata 
     @Test public void testEnumerateForms() {
-        FunctionLibrary lib = FunctionLibraryManager.getFunctionLibrary();
-        
-        Collection categories = lib.getFunctionCategories();
+        Collection categories = library.getFunctionCategories();
         Iterator catIter = categories.iterator();
         while(catIter.hasNext()) { 
             String category = (String) catIter.next();
             //System.out.println("Category: " + category);
             
-            Collection functions = lib.getFunctionForms(category);
+            Collection functions = library.getFunctionForms(category);
             Iterator functionIter = functions.iterator();
             while(functionIter.hasNext()) { 
                 FunctionForm form = (FunctionForm) functionIter.next();
@@ -984,68 +987,68 @@
     
 	/** date + month --> count=18, inteval=month, result should be 2004-11-15 */
 	@Test public void testInvokeTimestampAddDate2() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_MONTH,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MONTH,  //$NON-NLS-1$
 			new Integer(18), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(104, 10, 15).getTime()));	
 	}
 
 	/** date + month --> count=-18, inteval=month, result should be 2001-11-15 */
 	@Test public void testInvokeTimestampAddDate2a() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_MONTH,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MONTH,  //$NON-NLS-1$
 			new Integer(-18), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(101, 10, 15).getTime()));	
 	}
 	
 	/** date + week --> count=6, inteval=week, result should be 2003-04-03 */
 	@Test public void testInvokeTimestampAddDate3() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_WEEK,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_WEEK,  //$NON-NLS-1$
 			new Integer(-6), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(103, 3, 3).getTime()));	
 	}
 
 	/** date + quarter --> count=3, inteval=quarter, result should be 2004-2-15 */
 	@Test public void testInvokeTimestampAddDate4() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_QUARTER,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_QUARTER,  //$NON-NLS-1$
 			new Integer(3), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(104, 1, 15).getTime()));	
 	}
 
 	/** date + year --> count=-1, inteval=year, result should be 2002-5-15 */
 	@Test public void testInvokeTimestampAddDate5() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_YEAR,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_YEAR,  //$NON-NLS-1$
 			new Integer(-1), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(102, 4, 15).getTime()));	
 	}
 			
 	/** time + minute --> count=23, inteval=3, result should be 03:32:12 */
 	@Test public void testInvokeTimestampAddTime1() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_MINUTE,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MINUTE,  //$NON-NLS-1$
 			new Integer(23), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, new Timestamp(TimestampUtil.createTime(3, 32, 12).getTime()));	
 	}
 
 	/** time + hour --> count=21, inteval=4, result should be 00:09:12 and overflow */
 	@Test public void testInvokeTimestampAddTime2() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_HOUR,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_HOUR,  //$NON-NLS-1$
 			new Integer(21), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, TimestampUtil.createTimestamp(70, 0, 2, 0, 9, 12, 0));	
 	}
 
 	/** time + hour --> count=2, inteval=4, result should be 01:12:12*/
 	@Test public void testInvokeTimestampAddTime3() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_HOUR,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_HOUR,  //$NON-NLS-1$
 			new Integer(2), new Timestamp(TimestampUtil.createTime(23, 12, 12).getTime())}, TimestampUtil.createTimestamp(70, 0, 2, 1, 12, 12, 0));	
 	}
 	
 	/** time + second --> count=23, inteval=2, result should be 03:10:01 */
 	@Test public void testInvokeTimestampAddTime4() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_SECOND,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_SECOND,  //$NON-NLS-1$
 			new Integer(49), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, new Timestamp(TimestampUtil.createTime(3, 10, 1).getTime()));	
 	}
 
 	/** timestamp + second --> count=23, inteval=2, result should be 2003-05-15 03:09:35.100  */
 	@Test public void testInvokeTimestampAddTimestamp1() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_SECOND,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_SECOND,  //$NON-NLS-1$
 			new Integer(23), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)}, 
 			TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 35, 100));	
 	}
 
 	/** timestamp + nanos --> count=1, inteval=1, result should be 2003-05-15 03:09:12.000000101  */
 	@Test public void testInvokeTimestampAddTimestamp2() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
 			new Integer(1), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)}, 
 			TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 101));	
 	}
@@ -1054,14 +1057,14 @@
 	 *  with increase in second and minutes, because second already at 59 sec originally
 	 */
 	@Test public void testInvokeTimestampAddTimestamp3() {
-		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
+		helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
 			new Integer(2100000000), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 59, 1)}, 
 			TimestampUtil.createTimestamp(103, 4, 15, 3, 10, 1, 100000003));	
 	}
 			
 	/** time --> interval=hour, time1 = 03:04:45, time2= 05:05:36 return = 2  */
 	@Test public void testInvokeTimestampDiffTime1() {
-		helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_HOUR,  //$NON-NLS-1$
+		helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_HOUR,  //$NON-NLS-1$
 				new Timestamp(TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(TimestampUtil.createTime(5, 5, 36).getTime()) }, 
 			new Long(2));	
 	}
@@ -1077,7 +1080,7 @@
 	 * time2= 2003-05-02 05:19:35.500 return = 45
 	 */
 	@Test public void testInvokeTimestampDiffTimestamp1() {
-		helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_WEEK,  //$NON-NLS-1$
+		helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_WEEK,  //$NON-NLS-1$
 			TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100), TimestampUtil.createTimestamp(103, 4, 2, 5, 19, 35, 500) }, 
 			new Long(45));	
 	}
@@ -1087,7 +1090,7 @@
      * time2= 2002-06-21 03:09:35.100000000 return = 999999999
      */
     @Test public void testInvokeTimestampDiffTimestamp2() {
-        helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
+        helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
             TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 1), TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100000000) }, 
             new Long(99999999));  
     }
@@ -1097,7 +1100,7 @@
      * time2= 2002-06-22 03:09:35.000000001 return = 
      */
     @Test public void testInvokeTimestampDiffTimestamp3() {
-        helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
+        helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
             TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 2), TimestampUtil.createTimestamp(102, 5, 22, 3, 9, 35, 1) }, 
             new Long(86399999999999L));  
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,6 @@
 
 package com.metamatrix.query.function;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -99,13 +97,9 @@
     	 	public Class getInvocationClass(String className) throws ClassNotFoundException { 
     	 	    throw new ClassNotFoundException("Could not find class " + className); //$NON-NLS-1$
     	 	}
-    	 	
-    	 	public void loadFunctions(InputStream source) throws IOException{
-    	 	}
     	};	 
     	
-    	FunctionLibraryManager.registerSource(dummySource);
-    	FunctionLibraryManager.reloadSources();
+    	new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(dummySource.getFunctionMethods())));
     }
     
     public void testNullCategory() {

Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -34,6 +34,7 @@
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.util.ResolverVisitor;
 import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
 
 public class TestResolvedFunctions extends TestCase {
 
@@ -88,7 +89,7 @@
                                               BlockedException,
                                               MetaMatrixComponentException, QueryResolverException {
         Expression expr = QueryParser.getQueryParser().parseExpression(sql);
-        ResolverVisitor.resolveLanguageObject(expr, null);
+        ResolverVisitor.resolveLanguageObject(expr, FakeMetadataFactory.example1());
         return Evaluator.evaluate(expr);
     }
     

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,13 +22,10 @@
 
 package com.metamatrix.query.optimizer;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import com.metamatrix.query.function.FunctionLibraryManager;
 import com.metamatrix.query.function.FunctionMetadataSource;
 import com.metamatrix.query.function.metadata.FunctionMethod;
 import com.metamatrix.query.function.metadata.FunctionParameter;
@@ -54,9 +51,6 @@
         return Class.forName(className); 
     }
     
- 	public void loadFunctions(InputStream source) throws IOException{
- 	}
-    
     // dummy function
     public static Object xyz() {
         return null;
@@ -67,9 +61,4 @@
         String string = (String)astring;
         return string.trim();
     }
-    
-    public static void setupFunctionLibrary() {
-        FunctionLibraryManager.registerSource(new FakeFunctionMetadataSource());        
-    }
-    
 }

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,6 +26,7 @@
 
 import org.junit.Test;
 
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
@@ -354,7 +355,7 @@
         caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = TestOptimizer.helpPlan(
               "select count(*), a.intnum from bqt1.smalla as a, bqt2.smallb as b where a.intkey = b.intkey group by a.intnum",  //$NON-NLS-1$
@@ -394,7 +395,7 @@
         
         String sql = "select a11.intkey ITEM_ID, sum(a11.intnum) WJXBFS1 from bqt1.smalla a11 join bqt2.smalla a12 on (a11.stringkey = a12.stringkey) join bqt2.smallb a13 on (a11.intkey = a13.intkey) where a13.intnum in (10) group by a11.intkey"; //$NON-NLS-1$
         
-        ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQT(), null, capFinder, 
+        ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder, 
                                       new String[] {"SELECT g_0.stringkey FROM bqt2.smalla AS g_0", "SELECT g_0.stringkey, g_0.intkey, SUM(g_0.intnum) FROM bqt1.smalla AS g_0 GROUP BY g_0.stringkey, g_0.intkey", "SELECT g_0.intkey FROM bqt2.smallb AS g_0 WHERE g_0.intnum = 10"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
         
         TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -423,7 +424,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = TestOptimizer.helpPlan(
               "select count(*) from bqt1.smalla",  //$NON-NLS-1$
@@ -442,7 +443,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = TestOptimizer.helpPlan(
               "select stringkey, max(intkey) from bqt1.smalla group by stringkey having count(intkey) = 1",  //$NON-NLS-1$
@@ -514,14 +515,14 @@
         String sql = "SELECT Q1.S, Q2.C, Q1.PRODUCT, Q1.REGION AS Q1R, Q2.REGION AS Q2R FROM " + //$NON-NLS-1$
             "(SELECT SUM(SALES) AS S, REGION, PRODUCT FROM DB2_TABLE WHERE PRODUCT IN ('GUNS', 'TOYS', 'VIDEOTAPES') GROUP BY REGION, PRODUCT) Q1 " + //$NON-NLS-1$
             "FULL OUTER JOIN " +  //$NON-NLS-1$
-            "(SELECT SUM(COSTS) AS C, REGION FROM ORACLE_TABLE WHERE YEAR = '1999' GROUP BY REGION) Q2 " + //$NON-NLS-1$
+            "(SELECT SUM(COSTS) AS C, REGION FROM ORACLE_TABLE WHERE \"YEAR\" = '1999' GROUP BY REGION) Q2 " + //$NON-NLS-1$
             "ON Q1.REGION = Q2.REGION"; //$NON-NLS-1$
 
         ProcessorPlan plan = helpPlan(sql,  
                                       metadata,
                                       null, capFinder,
                                       new String[] {"SELECT REGION, SUM(SALES), PRODUCT FROM db2model.DB2_TABLE WHERE PRODUCT IN ('GUNS', 'TOYS', 'VIDEOTAPES') GROUP BY REGION, PRODUCT", //$NON-NLS-1$
-                                                    "SELECT REGION, SUM(COSTS) FROM oraclemodel.Oracle_table WHERE YEAR = '1999' GROUP BY REGION"},  //$NON-NLS-1$
+                                                    "SELECT REGION, SUM(COSTS) FROM oraclemodel.Oracle_table WHERE \"YEAR\" = '1999' GROUP BY REGION"},  //$NON-NLS-1$
                                       SHOULD_SUCCEED );
 
         checkNodeTypes(plan, new int[] {
@@ -567,8 +568,8 @@
         ProcessorPlan plan = helpPlan(sql,  
                                       metadata,
                                       null, capFinder,
-                                      new String[] {"SELECT g_0.MONTH, g_0.YEAR FROM msModel.\"TIME\" AS g_0 WHERE g_0.YEAR = '1999'", //$NON-NLS-1$
-                                                    "SELECT DISTINCT g_0.MONTH AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.MONTH IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.MONTH, g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$ 
+                                      new String[] {"SELECT g_0.\"MONTH\", g_0.\"YEAR\" FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999'", //$NON-NLS-1$
+                                                    "SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.\"MONTH\" IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$ 
                                                     "SELECT g_0.CITY, g_0.REGION FROM oraclemodel.GEOGRAPHY AS g_0 WHERE g_0.REGION IN ('BORDEAUX', 'POLINESIA')"},  //$NON-NLS-1$
                                       ComparisonMode.EXACT_COMMAND_STRING );
 
@@ -615,8 +616,8 @@
         ProcessorPlan plan = helpPlan(sql,  
                                       metadata,
                                       null, capFinder,
-                                      new String[] {"SELECT g_0.MONTH, g_0.YEAR FROM msModel.\"TIME\" AS g_0 WHERE g_0.YEAR = '1999'", //$NON-NLS-1$
-                                          "SELECT DISTINCT g_0.MONTH AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.MONTH IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.MONTH, g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$ 
+                                      new String[] {"SELECT g_0.\"MONTH\", g_0.\"YEAR\" FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999'", //$NON-NLS-1$
+                                          "SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.\"MONTH\" IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$ 
                                           "SELECT g_0.CITY, g_0.REGION FROM oraclemodel.GEOGRAPHY AS g_0 WHERE g_0.REGION IN ('BORDEAUX', 'POLINESIA')"},  //$NON-NLS-1$
                                       ComparisonMode.EXACT_COMMAND_STRING );
 
@@ -663,8 +664,8 @@
         ProcessorPlan plan = helpPlan(sql,  
                                       metadata,
                                       null, capFinder,
-                                      new String[] {"SELECT DISTINCT g_0.MONTH AS c_0, g_1.REGION AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0, db2model.GEOGRAPHY2 AS g_1 WHERE (g_0.CITY = g_1.CITY) AND (g_1.REGION IN ('BORDEAUX', 'POLINESIA')) AND (g_0.MONTH IN (<dependent values>)) GROUP BY g_0.MONTH, g_1.REGION ORDER BY c_0", //$NON-NLS-1$ 
-                                                    "SELECT g_0.MONTH AS c_0, g_0.YEAR AS c_1 FROM msModel.\"TIME\" AS g_0 WHERE g_0.YEAR = '1999' ORDER BY c_0"},  //$NON-NLS-1$
+                                      new String[] {"SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_1.REGION AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0, db2model.GEOGRAPHY2 AS g_1 WHERE (g_0.CITY = g_1.CITY) AND (g_1.REGION IN ('BORDEAUX', 'POLINESIA')) AND (g_0.\"MONTH\" IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_1.REGION ORDER BY c_0", //$NON-NLS-1$ 
+                                                    "SELECT g_0.\"MONTH\" AS c_0, g_0.\"YEAR\" AS c_1 FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999' ORDER BY c_0"},  //$NON-NLS-1$
                                                     ComparisonMode.EXACT_COMMAND_STRING );
 
         checkNodeTypes(plan, new int[] {

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,6 +29,9 @@
 
 import junit.framework.TestCase;
 
+import org.teiid.metadata.TransformationMetadata;
+
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
@@ -731,11 +734,9 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
-        FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-        FakeMetadataObject g2 = metadata.getStore().findObject("BQT2.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+        FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+        FakeMetadataFactory.setCardinality("bqt2.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
          
         ProcessorPlan plan = TestOptimizer.helpPlan(
             "SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM (SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp, BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey",  //$NON-NLS-1$
@@ -777,11 +778,9 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
-        FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-        FakeMetadataObject g2 = metadata.getStore().findObject("BQT2.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+        TransformationMetadata metadata = FakeMetadataFactory.exampleBQT();
+        FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+        FakeMetadataFactory.setCardinality("bqt2.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
          
         ProcessorPlan plan = TestOptimizer.helpPlan(
             "SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM (SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp, BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey AND table1comp.key1 = BQT1.SmallA.StringNum",  //$NON-NLS-1$

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,18 +31,18 @@
 
 import org.junit.Test;
 
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
 import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
 import com.metamatrix.query.unittest.FakeMetadataFactory;
 
 public class TestInlineView  {
     
-    public static FakeMetadataFacade createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+    public static QueryMetadataInterface createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
@@ -245,7 +245,7 @@
 	
 	protected void runTest(InlineViewCase testCase) throws Exception {
 		FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
-    	FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+    	QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
     	
 		ProcessorPlan plan = TestOptimizer.helpPlan(testCase.userQuery, metadata, null, capFinder, new String[] {testCase.optimizedQuery}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); 
 
@@ -256,7 +256,7 @@
 	
     @Test public void testAliasCreationWithInlineView() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
-        FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+        QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
         
         ProcessorPlan plan = helpPlan("select a, b from (select distinct count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
                 metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
@@ -268,7 +268,7 @@
     
     @Test public void testAliasPreservationWithInlineView() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
-        FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+        QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
         
         ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
                 metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS q1"}, true); //$NON-NLS-1$
@@ -283,7 +283,7 @@
      */
     @Test public void testCrossSourceInlineView() throws Exception {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
-        FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+        QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
         
         ProcessorPlan plan = helpPlan("select * from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a, bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey = q2.intkey where q1.a = 1", //$NON-NLS-1$
                 metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -34,6 +34,7 @@
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.query.QueryParserException;
 import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
@@ -146,7 +147,7 @@
         capFinder.addCapabilities(BQT1, caps); 
         capFinder.addCapabilities(BQT2, caps); 
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         // Plan query
         ProcessorPlan plan = TestOptimizer.helpPlan(sql, 
@@ -510,7 +511,7 @@
     }
     
     @Test public void testRulePushNonJoinCriteriaPreservesOuterJoin() throws Exception {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         String sql = "select b.intkey from (select intkey from bqt1.smalla) a left outer join (select intkey from bqt1.smallb) b on (1 = 1)"; //$NON-NLS-1$
         
         ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, 
@@ -520,7 +521,7 @@
     }
     
     @Test public void testOuterToInnerJoinConversion() {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+    	QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smallb.intnum = 1"; //$NON-NLS-1$
         
         TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla, bqt1.smallb WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smallb.intnum = 1)"}); //$NON-NLS-1$
@@ -528,21 +529,21 @@
     
     //same as above, but with a right outer join
     @Test public void testOuterToInnerJoinConversion1() {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+    	QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         String sql = "select bqt1.smalla.intkey from bqt1.smalla right outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1"; //$NON-NLS-1$
         
         TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smallb, bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = 1)"}); //$NON-NLS-1$
     }
     
     @Test public void testOuterToInnerJoinConversion2() {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+    	QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smallb.intnum = 1"; //$NON-NLS-1$
         
         TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smallb LEFT OUTER JOIN bqt1.smalla ON bqt1.smalla.intkey = bqt1.smallb.intkey WHERE bqt1.smallb.intnum = 1"}); //$NON-NLS-1$
     }    
     
     @Test public void testOuterToInnerJoinConversion3() {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+    	QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1"; //$NON-NLS-1$
         
         TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla LEFT OUTER JOIN bqt1.smallb ON bqt1.smalla.intkey = bqt1.smallb.intkey WHERE bqt1.smalla.intnum = 1"}); //$NON-NLS-1$
@@ -552,7 +553,7 @@
      * non-depenent criteria on each side of a full outer creates an inner join  
      */
     @Test public void testOuterToInnerJoinConversion4() {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+    	QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = bqt1.smallb.intnum"; //$NON-NLS-1$
         
         TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla, bqt1.smallb WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = bqt1.smallb.intnum)"}); //$NON-NLS-1$
@@ -571,7 +572,7 @@
         caps.setFunctionSupport("concat2", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where concat2(bqt1.smallb.intnum, '1') = 1"; //$NON-NLS-1$
         
         TestOptimizer.helpPlan(sql, metadata, null, capFinder, new String[]{"SELECT bqt1.smallb.intnum, bqt1.smalla.intkey FROM bqt1.smalla LEFT OUTER JOIN bqt1.smallb ON bqt1.smalla.intkey = bqt1.smallb.intkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -44,6 +44,10 @@
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.function.FunctionLibrary;
+import com.metamatrix.query.function.FunctionTree;
+import com.metamatrix.query.function.SystemFunctionManager;
+import com.metamatrix.query.function.UDFSource;
 import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
@@ -164,7 +168,7 @@
 	}
 	
 	public static ProcessorPlan helpPlan(String sql,
-			FakeMetadataFacade md, String[] expected,
+			QueryMetadataInterface md, String[] expected,
 			CapabilitiesFinder capFinder,
 			ComparisonMode mode) throws QueryParserException, QueryResolverException, QueryValidatorException, MetaMatrixComponentException {
 		return helpPlan(sql, md, null, capFinder, expected, mode);
@@ -2722,7 +2726,7 @@
         caps.setFunctionSupport("convert", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
          
         ProcessorPlan plan = helpPlan(
             "SELECT StringCol AS E " +  //$NON-NLS-1$
@@ -2753,7 +2757,7 @@
     }    
 
     @Test public void testDefect9827() { 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan("SELECT intkey, c FROM (SELECT DISTINCT b.intkey, b.intnum, a.stringkey AS c FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.INTKEY = b.INTKEY) AS x ORDER BY x.intkey", metadata, //$NON-NLS-1$
             new String[] {"SELECT DISTINCT b.intkey, b.intnum, a.stringkey FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.INTKEY = b.INTKEY"} ); //$NON-NLS-1$
@@ -3432,7 +3436,7 @@
         caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     
         ProcessorPlan plan = helpPlan(sql, metadata,  
             null, capFinder,
@@ -3617,46 +3621,6 @@
         });                                    
     }   
 
-    @Test public void testDefect12298() throws Exception {      
-        FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
-        BasicSourceCapabilities caps = new BasicSourceCapabilities();
-        caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
-        caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
-        caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
-        caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
-        caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
-        caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
-        caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
-        capFinder.addCapabilities("SystemPhysical", caps); //$NON-NLS-1$
-
-        ProcessorPlan plan = helpPlan(
-            "SELECT VDBName PKVDB, PKGroupFullName, PKElementName, VDBName FKVDB,FKGroupFullName, FKElementName, convert(FKPosition, short) As FKPosition, FKKeyName, PKKeyName " + //$NON-NLS-1$
-            "FROM System.ReferenceKeyElements WHERE PKKeyType = 'Primary' AND FKKeyType = 'Foreign' AND FKGroupFullName = 'PartsOracle.SUPPLIER_PARTS'",           //$NON-NLS-1$
-            FakeMetadataFactory.exampleSystemPhysical(), 
-            null, capFinder,
-            new String[] { 
-                            "SELECT g_2.VDB_NM, g_1.PATH_1, g_8.ELMNT_NM, g_10.PATH_1, g_17.ELMNT_NM, g_16.POSITION, g_9.KEY_NM, g_0.KEY_NM FROM ((((SystemPhysical.RT_KY_IDXES AS g_0 INNER JOIN ((SystemPhysical.RT_GRPS AS g_1 INNER JOIN ((SystemPhysical.RT_VIRTUAL_DBS AS g_2 INNER JOIN SystemPhysical.RT_VDB_MDLS AS g_3 ON g_2.VDB_UID = g_3.VDB_UID) INNER JOIN SystemPhysical.RT_MDLS AS g_4 ON g_3.MDL_UID = g_4.MDL_UID) ON g_1.MDL_UID = g_4.MDL_UID) INNER JOIN SystemPhysical.RT_TABLE_TYPES AS g_5 ON g_1.TABLE_TYPE = g_5.TABLE_TYPE_CODE) ON g_0.GRP_UID = g_1.GRP_UID) INNER JOIN SystemPhysical.RT_KEY_TYPES AS g_6 ON g_0.KEY_TYPE = g_6.KEY_TYPE_CODE) LEFT OUTER JOIN SystemPhysical.RT_KY_IDX_ELMNTS AS g_7 ON g_7.KEY_UID = g_0.KEY_UID) INNER JOIN SystemPhysical.RT_ELMNTS AS g_8 ON g_7.ELMNT_UID = g_8.ELMNT_UID) INNER JOIN ((((SystemPhysical.RT_KY_IDXES AS g_9 INNER JOIN ((SystemPhysical.RT_GRPS AS g_10 INNER JOIN ((SystemPhysical.RT_VIRTUAL_DBS AS g_11 INNER JOIN SystemPhysical.RT!
 _VDB_MDLS AS g_12 ON g_11.VDB_UID = g_12.VDB_UID) INNER JOIN SystemPhysical.RT_MDLS AS g_13 ON g_12.MDL_UID = g_13.MDL_UID) ON g_10.MDL_UID = g_13.MDL_UID) INNER JOIN SystemPhysical.RT_TABLE_TYPES AS g_14 ON g_10.TABLE_TYPE = g_14.TABLE_TYPE_CODE) ON g_9.GRP_UID = g_10.GRP_UID) INNER JOIN SystemPhysical.RT_KEY_TYPES AS g_15 ON g_9.KEY_TYPE = g_15.KEY_TYPE_CODE) LEFT OUTER JOIN SystemPhysical.RT_KY_IDX_ELMNTS AS g_16 ON g_16.KEY_UID = g_9.KEY_UID) INNER JOIN SystemPhysical.RT_ELMNTS AS g_17 ON g_16.ELMNT_UID = g_17.ELMNT_UID) ON g_0.KEY_UID = g_9.REF_KEY_UID AND g_7.POSITION = g_16.POSITION WHERE (g_1.TABLE_TYPE <> 5) AND (g_3.VISIBILITY = 0) AND (g_5.TABLE_TYPE_CODE <> 5) AND (g_6.KEY_TYPE_NM = 'Primary') AND (g_10.TABLE_TYPE <> 5) AND (g_10.PATH_1 = 'PartsOracle.SUPPLIER_PARTS') AND (g_12.VISIBILITY = 0) AND (g_14.TABLE_TYPE_CODE <> 5) AND (g_15.KEY_TYPE_NM = 'Foreign')" //$NON-NLS-1$
-                      },
-                      ComparisonMode.EXACT_COMMAND_STRING);
-                  checkNodeTypes(plan, new int[] {
-                      1,      // Access
-                      0,      // DependentAccess
-                      0,      // DependentSelect
-                      0,      // DependentProject
-                      0,      // DupRemove
-                      0,      // Grouping
-                      0,      // NestedLoopJoinStrategy
-                      0,      // MergeJoinStrategy
-                      0,      // Null
-                      0,      // PlanExecution
-                      1,      // Project
-                      0,      // Select
-                      0,      // Sort
-                      0       // UnionAll
-            
-        });         
-    }
-    
     // SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0
     @Test public void testCase1727_1() {
         ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
@@ -3793,7 +3757,7 @@
             expectedSql = new String[] { "SELECT IntKey FROM BQT1.SmallA", "SELECT IntKey FROM BQT1.SmallB" };  //$NON-NLS-1$//$NON-NLS-2$
         }
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan(sql, metadata, 
                                       null, capFinder, expectedSql, SHOULD_SUCCEED);  
@@ -4099,7 +4063,7 @@
         caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         ProcessorPlan plan = helpPlan("SELECT DISTINCT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB", metadata,  //$NON-NLS-1$
                                       null, capFinder, 
@@ -4242,7 +4206,7 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
         ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT intnum, 10 FROM bqt1.smalla) AS x",  //$NON-NLS-1$
-                                      FakeMetadataFactory.exampleBQT(),  
+                                      FakeMetadataFactory.exampleBQTCached(),  
                                       null, capFinder, 
                                       new String[] {"SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT IntNum, 10 FROM bqt1.smalla"},  //$NON-NLS-1$ 
                                       SHOULD_SUCCEED);   
@@ -4360,7 +4324,6 @@
     }
 
     @Test public void testPushdownFunctionNotEvaluated() {
-        FakeFunctionMetadataSource.setupFunctionLibrary();
         
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4370,7 +4333,9 @@
         caps.setFunctionSupport("xyz", true);         //$NON-NLS-1$
         capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+        FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
+        
          
         ProcessorPlan plan = helpPlan(
             "SELECT e1 FROM pm1.g1 WHERE xyz() > 0",  //$NON-NLS-1$
@@ -4406,7 +4371,7 @@
     }
     
     /** defect 14510 */
-    @Test public void testDefect14510LookupFunction() {
+    @Test public void testDefect14510LookupFunction() throws Exception {
 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4417,11 +4382,9 @@
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
-        FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
-        FakeMetadataObject g2 = metadata.getStore().findObject("BQT1.SmallB", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+        FakeMetadataFactory.setCardinality("bqt1.smallb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+        FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
          
         ProcessorPlan plan = helpPlan(
             "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.IntKey = lookup('BQT1.SmallB', 'IntKey', 'StringKey', BQT1.SmallB.StringKey)) AND (BQT1.SmallA.IntKey = 1)",  //$NON-NLS-1$
@@ -4449,7 +4412,7 @@
     }    
 
     /** defect 14510 */
-    @Test public void testDefect14510LookupFunction2() {
+    @Test public void testDefect14510LookupFunction2() throws Exception {
 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4461,11 +4424,9 @@
         caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
-        FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
-        FakeMetadataObject g2 = metadata.getStore().findObject("BQT1.MediumB", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+        FakeMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+        FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
          
         ProcessorPlan plan = helpPlan(
             "SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT1.MediumB ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey', BQT1.MediumB.StringKey)",  //$NON-NLS-1$
@@ -4493,7 +4454,7 @@
     }
 
     /** defect 14510 */
-    @Test public void testDefect14510LookupFunction3() {
+    @Test public void testDefect14510LookupFunction3() throws Exception {
 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4505,11 +4466,9 @@
         caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
-        FakeMetadataObject g1 = metadata.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
-        FakeMetadataObject g2 = metadata.getStore().findObject("BQT1.MediumB", FakeMetadataObject.GROUP); //$NON-NLS-1$
-        g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+        FakeMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+        FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
          
         ProcessorPlan plan = helpPlan(
             "SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.MediumB RIGHT OUTER JOIN BQT1.SmallA ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey',BQT1.MediumB.StringKey)",  //$NON-NLS-1$          
@@ -4756,7 +4715,7 @@
         caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);        
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         String sql = "SELECT t.intkey FROM (SELECT a.IntKey FROM bqt1.smalla a left outer join bqt1.smallb b on a.intkey=b.intkey, bqt1.smalla x) as t full outer JOIN bqt1.smallb c on t.intkey = c.intkey"; //$NON-NLS-1$
 
@@ -4957,7 +4916,7 @@
         
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan(sql,           
                                       metadata,
@@ -5000,7 +4959,7 @@
         
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan(sql,           
                                       metadata,
@@ -5283,7 +5242,7 @@
         
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan(sql,           
                                       metadata,
@@ -5334,7 +5293,7 @@
         
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan(sql,           
                                       metadata,
@@ -5394,7 +5353,7 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan(sql,           
                                       metadata,
@@ -5507,7 +5466,7 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan(sql,           
                                       metadata,
@@ -5567,7 +5526,7 @@
         caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);  
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         String sql = "SELECT intkey, x FROM (select intkey, intkey x from bqt1.smalla) z ORDER BY x, intkey"; //$NON-NLS-1$
 
@@ -5598,7 +5557,7 @@
         caps.setFunctionSupport("concat", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         String sql = "SELECT vqt.smallb.a12345 FROM vqt.smallb ORDER BY vqt.smallb.a12345"; //$NON-NLS-1$
 
@@ -5627,7 +5586,7 @@
         caps.setFunctionSupport("concat", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as EXPR, bqt1.smalla.stringKey as EXPR_1 FROM bqt1.smalla  ORDER BY EXPR, EXPR_1"; //$NON-NLS-1$
 
@@ -5656,7 +5615,7 @@
         caps.setFunctionSupport("concat", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum), bqt1.smalla.stringKey as EXPR_1 FROM bqt1.smalla ORDER BY EXPR_1"; //$NON-NLS-1$
 
@@ -5686,7 +5645,7 @@
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         String sql = "SELECT b1.intkey from (bqt1.SmallA a1 cross join bqt1.smalla a2 cross join bqt1.mediuma b1) " +    //$NON-NLS-1$ 
             " left outer join bqt1.mediumb b2 on b1.intkey = b2.intkey"; //$NON-NLS-1$         
@@ -5715,7 +5674,7 @@
         caps.setFunctionSupport("concat", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         String sql = "SELECT bqt1.SmallA.intkey from (bqt1.SmallA inner join (" //$NON-NLS-1$         
             + "SELECT BAD.intkey from bqt1.SmallB as BAD left outer join bqt1.MediumB on BAD.intkey = bqt1.MediumB.intkey) as X on bqt1.SmallA.intkey = X.intkey) inner join bqt1.MediumA on X.intkey = bqt1.MediumA.intkey"; //$NON-NLS-1$
@@ -5785,7 +5744,7 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$ 
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$ 
          
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
          
         String sql = "select bqt1.smalla.intkey from bqt1.smalla, bqt2.smalla, bqt2.smallb where bqt1.smalla.intkey = bqt2.smalla.intkey and bqt1.smalla.intkey = bqt2.smallb.intkey and bqt2.smalla.stringkey = bqt2.smallb.stringkey"; //$NON-NLS-1$ 
          
@@ -5833,7 +5792,7 @@
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true); 
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$ 
          
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached(); 
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached(); 
          
         String sql = "SELECT * from (select '1' as test, intkey from bqt2.smalla) foo, (select '2' as test, intkey from bqt2.smalla) foo2 where foo.intkey = foo2.intkey"; //$NON-NLS-1$ 
          
@@ -6143,7 +6102,7 @@
         caps.setFunctionSupport("concat", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = TestOptimizer.helpPlan(sql,         
                                       metadata,
@@ -6174,7 +6133,7 @@
         caps.setFunctionSupport("+", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         ProcessorPlan plan = TestOptimizer.helpPlan(sql,        
                                       metadata,
@@ -6233,7 +6192,7 @@
         caps.setFunctionSupport("concat", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         ProcessorPlan plan = TestOptimizer.helpPlan(sql,         
                                       metadata,
@@ -6301,7 +6260,7 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan(
             "SELECT A.IntKey, B.IntKey FROM BQT1.SmallA A LEFT OUTER JOIN BQT2.MediumB B ON A.IntKey = B.IntKey",  //$NON-NLS-1$
@@ -6332,7 +6291,7 @@
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan(
               "SELECT 'a' as A FROM BQT1.SmallA A UNION select 'b' as B from BQT1.MediumB B",  //$NON-NLS-1$
@@ -6350,7 +6309,7 @@
         caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         String sql = "select b from (select distinct booleanvalue b, intkey from bqt1.smalla) as x"; //$NON-NLS-1$
         
@@ -6386,7 +6345,7 @@
         caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         String sql = "SELECT a.intkey as stringkey, b.stringkey as key2 from bqt1.smalla a, bqt1.smallb b where a.intkey = b.intkey order by stringkey"; //$NON-NLS-1$ 
          
@@ -6404,7 +6363,7 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
         // Add join capability to pm1
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
          
         ProcessorPlan plan = helpPlan(
             "SELECT intkey from bqt1.smalla WHERE stringkey = convert(objectvalue, string)",  //$NON-NLS-1$
@@ -6439,7 +6398,7 @@
         capFinder.addCapabilities("LOB", caps); //$NON-NLS-1$
 
         // Add join capability to pm1
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
          
         ProcessorPlan plan = helpPlan(
             "SELECT ClobValue from LOB.LobTbl WHERE convert(ClobValue, string) = ?",  //$NON-NLS-1$
@@ -6529,7 +6488,7 @@
         
         String sql = "select count(*) from (select intkey from bqt1.smalla union all select intkey from bqt1.smallb) as a"; //$NON-NLS-1$
         
-        ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQT(), null, capFinder, 
+        ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder, 
                                       new String[] {"SELECT COUNT(*) FROM (SELECT intkey FROM bqt1.smalla UNION ALL SELECT intkey FROM bqt1.smallb) AS a"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ 
         
         checkNodeTypes(plan, FULL_PUSHDOWN); 
@@ -6649,7 +6608,7 @@
     @Test public void testCopyCriteriaWithIsNull() {
     	String sql = "select * from (select a.intnum, a.intkey y, b.intkey from bqt1.smalla a, bqt2.smalla b where a.intkey = b.intkey) x where intkey is null"; //$NON-NLS-1$
     	
-    	helpPlan(sql, FakeMetadataFactory.exampleBQT(), new String[] {});
+    	helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {});
     }
     
     /**

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,6 +26,7 @@
 
 import org.junit.Test;
 
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
@@ -281,7 +282,7 @@
         caps.setFunctionSupport("convert", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         // Plan query
         ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, 

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,13 +26,13 @@
 
 import junit.framework.TestCase;
 
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
 import com.metamatrix.query.processor.ProcessorPlan;
 import com.metamatrix.query.processor.relational.RelationalPlan;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
 import com.metamatrix.query.unittest.FakeMetadataFactory;
 
 
@@ -67,7 +67,7 @@
 
         String sql = "select * from ( select intkey as cola, null as colb, intnum as colc from bqt1.smalla union all select null, intkey, intnum from bqt2.smalla) as X where X.cola = 1";  //$NON-NLS-1$
         
-        ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQT(),
+        ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
                                       new String[] {"SELECT intkey, null, intnum FROM bqt1.smalla WHERE intkey = 1"} ); //$NON-NLS-1$
         
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);          
@@ -263,7 +263,7 @@
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 

Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,141 +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 static com.metamatrix.query.optimizer.TestOptimizer.*;
-import static org.junit.Assert.*;
-
-import java.util.Collection;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.analysis.QueryAnnotation;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestMaterialization {
-	
-    @Test public void testMaterializedTransformation() throws Exception {
-        String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-        
-        Command command = helpGetCommand(userSql, metadata, null);
-        
-        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
-        Collection annotations = analysis.getAnnotations();
-        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
-        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
-        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
-    }
-
-    @Ignore("we no longer auto detect this case, if we need this logic it will have to be added to the rewriter since it changes select into to an insert")
-    @Test public void testMaterializedTransformationLoading() throws Exception {
-        String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-
-        Command command = helpGetCommand(userSql, metadata, null);
-        
-        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
-        Collection annotations = analysis.getAnnotations();
-        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
-        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
-        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
-    }    
-    
-    @Test public void testMaterializedTransformationNoCache() throws Exception {
-        String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-        
-        Command command = helpGetCommand(userSql, metadata, null);
-        
-        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-        
-        Collection annotations = analysis.getAnnotations();
-        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
-        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
-        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
-    }
-    
-    //related to defect 14423
-    @Test public void testMaterializedTransformationNoCache2() throws Exception {
-        String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-        
-        Command command = helpGetCommand(userSql, metadata, null);
-        
-        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-        
-        Collection annotations = analysis.getAnnotations();
-        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
-        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
-        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
-    }
-    
-    @Test public void testNoCacheInTransformation() throws Exception {
-        String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-        
-        Command command = helpGetCommand(userSql, metadata, null);
-        
-        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-    }
-    
-    @Test public void testTableNoCacheDoesntCascade() throws Exception {
-        String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache matview.matview1"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-        
-        Command command = helpGetCommand(userSql, metadata, null);
-        
-        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-    }
-    
-    @Test public void testNoCacheCascade() throws Exception {
-        String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
-        
-        Command command = helpGetCommand(userSql, metadata, null);
-        
-        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0 WHERE g_0.x = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-    }
-
-}

Copied: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java	                        (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,141 @@
+/*
+ * 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 static com.metamatrix.query.optimizer.TestOptimizer.*;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.analysis.QueryAnnotation;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.optimizer.TestOptimizer;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+public class TestMaterialization {
+	
+    @Test public void testMaterializedTransformation() throws Exception {
+        String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+        
+        Command command = helpGetCommand(userSql, metadata, null);
+        
+        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+        Collection annotations = analysis.getAnnotations();
+        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+    }
+
+    @Ignore("we no longer auto detect this case, if we need this logic it will have to be added to the rewriter since it changes select into to an insert")
+    @Test public void testMaterializedTransformationLoading() throws Exception {
+        String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+        Command command = helpGetCommand(userSql, metadata, null);
+        
+        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+        Collection annotations = analysis.getAnnotations();
+        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+    }    
+    
+    @Test public void testMaterializedTransformationNoCache() throws Exception {
+        String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+        
+        Command command = helpGetCommand(userSql, metadata, null);
+        
+        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+        
+        Collection annotations = analysis.getAnnotations();
+        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+    }
+    
+    //related to defect 14423
+    @Test public void testMaterializedTransformationNoCache2() throws Exception {
+        String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+        
+        Command command = helpGetCommand(userSql, metadata, null);
+        
+        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+        
+        Collection annotations = analysis.getAnnotations();
+        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+    }
+    
+    @Test public void testNoCacheInTransformation() throws Exception {
+        String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+        
+        Command command = helpGetCommand(userSql, metadata, null);
+        
+        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+    }
+    
+    @Test public void testTableNoCacheDoesntCascade() throws Exception {
+        String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache matview.matview1"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+        
+        Command command = helpGetCommand(userSql, metadata, null);
+        
+        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+    }
+    
+    @Test public void testNoCacheCascade() throws Exception {
+        String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+        AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+        
+        Command command = helpGetCommand(userSql, metadata, null);
+        
+        TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0 WHERE g_0.x = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+    }
+
+}

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -59,7 +59,7 @@
 
         Criteria result = QueryParser.getQueryParser().parseCriteria(critString);
         QueryResolver.resolveCriteria(result, metadata);
-        result = QueryRewriter.rewriteCriteria(result, null, new CommandContext(), null);
+        result = QueryRewriter.rewriteCriteria(result, null, new CommandContext(), metadata);
 
         return result;
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCapabilitiesUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCapabilitiesUtil.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCapabilitiesUtil.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,6 +25,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import junit.framework.TestCase;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -34,7 +36,6 @@
 import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.JoinType;
 import com.metamatrix.query.sql.lang.SetQuery.Operation;
 import com.metamatrix.query.sql.symbol.AggregateSymbol;
@@ -190,7 +191,7 @@
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -202,7 +203,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -214,7 +215,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -226,7 +227,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -238,7 +239,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -250,7 +251,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -261,7 +262,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -272,7 +273,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -283,7 +284,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -294,7 +295,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -305,7 +306,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -316,7 +317,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -327,7 +328,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -338,7 +339,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -350,7 +351,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -362,7 +363,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", ReservedWords.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol("expr", SQLReservedWords.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestGroupRecontext.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestGroupRecontext.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestGroupRecontext.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -119,7 +119,7 @@
         SubqueryCompareCriteria crit = new SubqueryCompareCriteria(e1, query, SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
         SubqueryCompareCriteria expected = new SubqueryCompareCriteria(x1, query, SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
 
-        FrameUtil.convertCriteria(crit, symbolMap);  
+        FrameUtil.convertCriteria(crit, symbolMap, null);  
         
         assertEquals(crit, expected);
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestCallableStatementParsing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestCallableStatementParsing.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestCallableStatementParsing.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,10 +22,14 @@
 
 package com.metamatrix.query.parser;
 
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
 import com.metamatrix.api.exception.query.QueryParserException;
 import com.metamatrix.query.sql.lang.StoredProcedure;
 
-public class TestCallableStatementParsing extends junit.framework.TestCase {
+public class TestCallableStatementParsing {
     
     private void helpTestIllegalCall(String call) {
         try {
@@ -44,14 +48,14 @@
         assertEquals("EXEC procedure_name(?, ?, ?)", sp.toString()); //$NON-NLS-1$
     }
             
-    public void testCallNoParams() throws QueryParserException {
+    @Test public void testCallNoParams() throws QueryParserException {
         StoredProcedure sp = (StoredProcedure)QueryParser.getQueryParser().parseCommand("{call procedure_name}"); //$NON-NLS-1$
         assertFalse(sp.returnsScalarValue());
         assertEquals("procedure_name", sp.getProcedureName()); //$NON-NLS-1$
         assertEquals(0, sp.getParameters().size());
     }
     
-    public void testCallWithReturnParam() throws QueryParserException {
+    @Test public void testCallWithReturnParam() throws QueryParserException {
         helpTestGetExec("{?=call procedure_name(?, ?, ?)}", true); //$NON-NLS-1$
         helpTestGetExec(" {?=call procedure_name(?, ?, ?)}", true); //$NON-NLS-1$
         helpTestGetExec("{ ?=call procedure_name(?, ?, ?)}", true); //$NON-NLS-1$
@@ -60,7 +64,7 @@
         helpTestGetExec("{?=\ncall procedure_name(?, ?, ?)}", true); //$NON-NLS-1$
     }
     
-    public void testIllegalCalls() {
+    @Test public void testIllegalCalls() {
         helpTestIllegalCall("{call procedure_name"); //$NON-NLS-1$
         helpTestIllegalCall("call procedure_name}"); //$NON-NLS-1$
         helpTestIllegalCall("{call procedure_name(}"); //$NON-NLS-1$
@@ -73,7 +77,7 @@
         helpTestIllegalCall("{?=cal procedure_name}"); //$NON-NLS-1$
     }
     
-    public void testGetExec() throws QueryParserException {
+    @Test public void testGetExec() throws QueryParserException {
         helpTestGetExec("{call procedure_name(?, ?, ?)}", false); //$NON-NLS-1$
         helpTestGetExec(" {call procedure_name(?, ?, ?)}", false); //$NON-NLS-1$
         helpTestGetExec("{ call procedure_name(?, ?, ?)}", false); //$NON-NLS-1$
@@ -83,13 +87,8 @@
         helpTestGetExec("{CALL procedure_name(?, ?, ?)} ", false); //$NON-NLS-1$
     }
     
-    public void testBadCallKeyword() {
-        try {
-            QueryParser.getQueryParser().parseCommand("{calli procedure_name}"); //$NON-NLS-1$
-            fail("expected exception"); //$NON-NLS-1$
-        } catch (QueryParserException qpe) {
-            assertEquals("Parsing error: Call keyword expected in callable statement", qpe.getMessage()); //$NON-NLS-1$
-        }
+    @Test(expected=QueryParserException.class) public void testBadCallKeyword() throws Exception {
+        QueryParser.getQueryParser().parseCommand("{calli procedure_name}"); //$NON-NLS-1$
     }
 
 }

Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -300,7 +300,7 @@
         ElementSymbol x = new ElementSymbol("a.x", true); //$NON-NLS-1$
         ElementSymbol y = new ElementSymbol("b.y", true); //$NON-NLS-1$
         
-        Criteria criteria = new CompareCriteria(x, CompareCriteria.EQ, new Function("function", new Expression[] {y})); //$NON-NLS-1$
+        Criteria criteria = new CompareCriteria(x, CompareCriteria.EQ, new Function("func", new Expression[] {y})); //$NON-NLS-1$
         JoinPredicate predicate = new JoinPredicate(new UnaryFromClause(a), new UnaryFromClause(b), JoinType.JOIN_INNER, Arrays.asList(new Object[] {criteria}));
         From from = new From(Arrays.asList(new Object[] {predicate}));
         predicate.getLeftClause().setMakeNotDep(true);
@@ -308,8 +308,8 @@
         Select select = new Select(Arrays.asList(new Object[] {x, y}));
         
         Query query = new Query(select, from, null, null, null, null, null);
-        TestParser.helpTest("Select a.x, b.y From a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = function(b.y)",  //$NON-NLS-1$
-                 "SELECT a.x, b.y FROM a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = function(b.y)",  //$NON-NLS-1$
+        TestParser.helpTest("Select a.x, b.y From a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = func(b.y)",  //$NON-NLS-1$
+                 "SELECT a.x, b.y FROM a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = func(b.y)",  //$NON-NLS-1$
                  query);
     }
 

Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -681,9 +681,9 @@
 				 query);
 	}
 
-    /** SELECT left(fullname, 3) as x FROM system.groups */
+    /** SELECT left(fullname, 3) as x FROM sys.groups */
     @Test public void testLeftFunction() {
-        GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+        GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
         From from = new From();
         from.addGroup(g);
 
@@ -696,14 +696,14 @@
         Query query = new Query();
         query.setSelect(select);
         query.setFrom(from);
-        helpTest("SELECT left(fullname, 3) as x FROM system.groups",  //$NON-NLS-1$
-                 "SELECT left(fullname, 3) AS x FROM system.groups",  //$NON-NLS-1$
+        helpTest("SELECT left(fullname, 3) as x FROM sys.groups",  //$NON-NLS-1$
+                 "SELECT left(fullname, 3) AS x FROM sys.groups",  //$NON-NLS-1$
                  query);
     }
 
-    /** SELECT right(fullname, 3) as x FROM system.groups */
+    /** SELECT right(fullname, 3) as x FROM sys.groups */
     @Test public void testRightFunction() {
-        GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+        GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
         From from = new From();
         from.addGroup(g);
 
@@ -716,14 +716,14 @@
         Query query = new Query();
         query.setSelect(select);
         query.setFrom(from);
-        helpTest("SELECT right(fullname, 3) as x FROM system.groups",  //$NON-NLS-1$
-                 "SELECT right(fullname, 3) AS x FROM system.groups",  //$NON-NLS-1$
+        helpTest("SELECT right(fullname, 3) as x FROM sys.groups",  //$NON-NLS-1$
+                 "SELECT right(fullname, 3) AS x FROM sys.groups",  //$NON-NLS-1$
                  query);
     }
 
-    /** SELECT char('x') AS x FROM system.groups */
+    /** SELECT char('x') AS x FROM sys.groups */
     @Test public void testCharFunction() {
-        GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+        GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
         From from = new From();
         from.addGroup(g);
 
@@ -736,14 +736,14 @@
         Query query = new Query();
         query.setSelect(select);
         query.setFrom(from);
-        helpTest("SELECT char('x') AS x FROM system.groups",  //$NON-NLS-1$
-                 "SELECT char('x') AS x FROM system.groups",  //$NON-NLS-1$
+        helpTest("SELECT char('x') AS x FROM sys.groups",  //$NON-NLS-1$
+                 "SELECT char('x') AS x FROM sys.groups",  //$NON-NLS-1$
                  query);
     }
 
-    /** SELECT insert('x', 1, 'a') as x FROM system.groups */
+    /** SELECT insert('x', 1, 'a') as x FROM sys.groups */
     @Test public void testInsertFunction() {
-        GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+        GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
         From from = new From();
         from.addGroup(g);
 
@@ -756,15 +756,15 @@
         Query query = new Query();
         query.setSelect(select);
         query.setFrom(from);
-        helpTest("SELECT insert('x', 1, 'a') AS x FROM system.groups",  //$NON-NLS-1$
-                 "SELECT insert('x', 1, 'a') AS x FROM system.groups",  //$NON-NLS-1$
+        helpTest("SELECT insert('x', 1, 'a') AS x FROM sys.groups",  //$NON-NLS-1$
+                 "SELECT insert('x', 1, 'a') AS x FROM sys.groups",  //$NON-NLS-1$
                  query);
     }
 
 
     
     @Test public void testInsertIntoSelect() {
-        GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+        GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
         From from = new From();
         from.addGroup(g);
 
@@ -786,9 +786,9 @@
                  insert);
     }
 
-    /** SELECT translate('x', 'x', 'y') FROM system.groups */
+    /** SELECT translate('x', 'x', 'y') FROM sys.groups */
     @Test public void testTranslateFunction() {
-        GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
+        GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$
         From from = new From();
         from.addGroup(g);
 
@@ -800,8 +800,8 @@
         Query query = new Query();
         query.setSelect(select);
         query.setFrom(from);
-        helpTest("SELECT translate('x', 'x', 'y') FROM system.groups",  //$NON-NLS-1$
-                 "SELECT translate('x', 'x', 'y') FROM system.groups",  //$NON-NLS-1$
+        helpTest("SELECT translate('x', 'x', 'y') FROM sys.groups",  //$NON-NLS-1$
+                 "SELECT translate('x', 'x', 'y') FROM sys.groups",  //$NON-NLS-1$
                  query);
     }
 
@@ -2030,7 +2030,7 @@
 		query.setFrom(from);
 		query.setCriteria(crit);
 		helpTest("SELECT a from db.g where a <> \"value\"",  //$NON-NLS-1$
-				 "SELECT a FROM db.g WHERE a <> value",  //$NON-NLS-1$
+				 "SELECT a FROM db.g WHERE a <> \"value\"",  //$NON-NLS-1$
 				 query);
 	}
 
@@ -2225,8 +2225,8 @@
         query.setSelect(select);
         query.setFrom(from);
 
-        helpTest("SELECT g.x AS year FROM g",  //$NON-NLS-1$
-                 "SELECT g.x AS year FROM g",  //$NON-NLS-1$
+        helpTest("SELECT g.x AS \"year\" FROM g",  //$NON-NLS-1$
+                 "SELECT g.x AS \"year\" FROM g",  //$NON-NLS-1$
                  query);
     }
 
@@ -6167,7 +6167,7 @@
     }
 
     @Test public void testNationCharString2() throws Exception {
-        Query query = (Query) QueryParser.getQueryParser().parseCommand("SELECT DISTINCT TABLE_QUALIFIER, NULL AS TABLE_OWNER, NULL AS TABLE_NAME, NULL AS TABLE_TYPE, NULL AS REMARKS FROM ATIODBCSystem.OA_TABLES  WHERE TABLE_QUALIFIER LIKE N'%'  ESCAPE '\\'  ORDER BY TABLE_QUALIFIER  "); //$NON-NLS-1$
+        Query query = (Query) QueryParser.getQueryParser().parseCommand("SELECT DISTINCT TABLE_QUALIFIER, NULL AS TABLE_OWNER, NULL AS TABLE_NAME, NULL AS TABLE_TYPE, NULL AS REMARKS FROM ATIODBCSYSTEM.OA_TABLES  WHERE TABLE_QUALIFIER LIKE N'%'  ESCAPE '\\'  ORDER BY TABLE_QUALIFIER  "); //$NON-NLS-1$
         MatchCriteria matchCrit = (MatchCriteria) query.getCriteria();
         Constant c = (Constant) matchCrit.getRightExpression();
         assertEquals(c, new Constant("%")); //$NON-NLS-1$
@@ -6568,11 +6568,7 @@
     @Test public void testCreateTempTable5() {
         helpException("Create  local TEMPORARY table tempTable (c1 boolean primary, c2 byte)"); //$NON-NLS-1$ 
     }
-    
-    @Test public void testCreateTempTable6() {
-        helpException("Create  local TEMPORARY table tempTable (c1 varchar, c2 byte)"); //$NON-NLS-1$ 
-    }
-    
+        
     @Test public void testCreateTempTable7() {
         helpException("Create local TEMPORARY table tempTable (c1.x boolean, c2 byte)" ,"Parsing error: Invalid simple identifier format: [c1.x]"); //$NON-NLS-1$ //$NON-NLS-2$ 
     }
@@ -6687,5 +6683,28 @@
                  "INSERT INTO m.g VALUES ('a', 'b')",  //$NON-NLS-1$
                  insert);
     }
-    
+
+    @Test public void testTypeAliases() {
+        Create create = new Create();
+        create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$
+        List columns = new ArrayList();
+        ElementSymbol column = new ElementSymbol("c1");//$NON-NLS-1$
+        column.setType(DataTypeManager.DefaultDataClasses.STRING);
+        columns.add(column);
+        column = new ElementSymbol("c2");//$NON-NLS-1$
+        column.setType(DataTypeManager.DefaultDataClasses.BYTE);
+        columns.add(column);
+        column = new ElementSymbol("c3");//$NON-NLS-1$
+        column.setType(DataTypeManager.DefaultDataClasses.SHORT);
+        columns.add(column);
+        column = new ElementSymbol("c4");//$NON-NLS-1$
+        column.setType(DataTypeManager.DefaultDataClasses.FLOAT);
+        columns.add(column);
+        column = new ElementSymbol("c5");//$NON-NLS-1$
+        column.setType(DataTypeManager.DefaultDataClasses.BIG_DECIMAL);
+        columns.add(column);
+        create.setColumns(columns);
+        helpTest("Create local TEMPORARY table tempTable (c1 varchar, c2 tinyint, c3 smallint, c4 real, c5 decimal)", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 string, c2 byte, c3 short, c4 float, c5 bigdecimal)", create); //$NON-NLS-1$ 
+    }
+
 }

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,11 +31,14 @@
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.CriteriaEvaluationException;
+import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.common.buffer.BlockedException;
 import com.metamatrix.common.buffer.TupleSource;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.query.eval.Evaluator;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.metadata.TempMetadataID;
+import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Delete;
@@ -387,5 +390,12 @@
 		this.recordingCommands = shouldRecord;
 	}
 
+	public void registerTuples(QueryMetadataInterface metadata, String groupName, List[] tuples) throws QueryResolverException, MetaMatrixComponentException {
+	    GroupSymbol group = new GroupSymbol(groupName);
+	    ResolverUtil.resolveGroup(group, metadata);
+	    List<ElementSymbol> elementSymbols = ResolverUtil.resolveElementsInGroup(group, metadata);
+		this.registerTuples(group.getMetadataID(), elementSymbols, tuples);
+	}
 
+
 }
\ No newline at end of file

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,25 +31,20 @@
 
 import org.junit.Test;
 
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.TestAggregatePushdown;
 import com.metamatrix.query.optimizer.TestOptimizer;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
 import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
 import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
 
 public class TestAggregateProcessing {
 
 	static void sampleDataBQT3(FakeDataManager dataMgr) throws Exception {
-		FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+		QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
 		// Group bqt1.smalla
-		FakeMetadataObject groupID = (FakeMetadataObject) metadata
-				.getGroupID("bqt1.smalla"); //$NON-NLS-1$
-		List elementIDs = metadata.getElementIDsInGroupID(groupID);
-		List elementSymbols = FakeDataStore.createElements(elementIDs);
 
 		List[] tuples = new List[20];
 		for (int i = 0; i < tuples.length; i++) {
@@ -62,13 +57,8 @@
 			}
 		}
 
-		dataMgr.registerTuples(groupID, elementSymbols, tuples);
+		dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
 
-		// Group bqt2.mediumb
-		groupID = (FakeMetadataObject) metadata.getGroupID("bqt2.mediumb"); //$NON-NLS-1$
-		elementIDs = metadata.getElementIDsInGroupID(groupID);
-		elementSymbols = FakeDataStore.createElements(elementIDs);
-
 		tuples = new List[20];
 		for (int i = 0; i < tuples.length; i++) {
 			tuples[i] = new ArrayList(17);
@@ -78,18 +68,12 @@
 			}
 		}
 
-		dataMgr.registerTuples(groupID, elementSymbols, tuples);
+		dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples); //$NON-NLS-1$
 	}
 
 	private void sampleDataBQT_defect9842(FakeDataManager dataMgr) throws Exception {
-		FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+		QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
-		// Group bqt1.smalla
-		FakeMetadataObject groupID = (FakeMetadataObject) metadata
-				.getGroupID("bqt1.smalla"); //$NON-NLS-1$
-		List elementIDs = metadata.getElementIDsInGroupID(groupID);
-		List elementSymbols = FakeDataStore.createElements(elementIDs);
-
 		List[] tuples = new List[5];
 		for (int i = 0; i < tuples.length; i++) {
 			int k = i + 10;
@@ -112,7 +96,7 @@
 			tuples[i].add(null);
 		}
 
-		dataMgr.registerTuples(groupID, elementSymbols, tuples);
+		dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
 	}
 
 	@Test public void testAggregateOnBQT() throws Exception {

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -42,6 +42,7 @@
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.SPParameter;
 import com.metamatrix.query.sql.lang.StoredProcedure;
+import com.metamatrix.query.sql.symbol.Constant;
 import com.metamatrix.query.unittest.FakeMetadataFacade;
 import com.metamatrix.query.unittest.FakeMetadataFactory;
 import com.metamatrix.query.unittest.FakeMetadataObject;
@@ -724,7 +725,7 @@
         			StoredProcedure proc = (StoredProcedure)command;
         			List<SPParameter> params = proc.getInputParameters();
         			assertEquals(1, params.size());
-        			int value = (Integer)params.get(0).getValue();
+        			int value = (Integer)((Constant)params.get(0).getExpression()).getValue();
         			return new FakeTupleSource(command.getProjectedSymbols(), new List[] {
         				Arrays.asList(value+2), Arrays.asList(value+5)
         			});

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -45,7 +45,6 @@
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.common.buffer.BufferManager;
 import com.metamatrix.common.buffer.BufferManagerFactory;
 import com.metamatrix.common.buffer.TupleBuffer;
@@ -57,6 +56,10 @@
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.dqp.message.ParameterInfo;
 import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.function.FunctionLibrary;
+import com.metamatrix.query.function.FunctionTree;
+import com.metamatrix.query.function.SystemFunctionManager;
+import com.metamatrix.query.function.UDFSource;
 import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.FakeFunctionMetadataSource;
@@ -131,14 +134,14 @@
     static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata) {
         return helpGetPlan(command, metadata, new DefaultCapabilitiesFinder());
     }
-
+    
 	static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) {
         CommandContext context = new CommandContext();
         context.setProcessorBatchSize(2000);
         context.setConnectorBatchSize(2000);
 	    return helpGetPlan(command, metadata, capFinder, context);
     }
-    
+	
     static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context) {
 		if(DEBUG) System.out.println("\n####################################\n" + command); //$NON-NLS-1$
 		AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
@@ -205,7 +208,7 @@
     	BufferManager bufferMgr = null;
         try {   
             bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
-            CommandContext context = new CommandContext("0", "test", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+            CommandContext context = new CommandContext("0", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
             QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
             processor.setNonBlocking(true);
             BatchCollector collector = processor.createBatchCollector();
@@ -295,7 +298,7 @@
 		Properties props = new Properties();
 		props.setProperty("soap_host", "my.host.com"); //$NON-NLS-1$ //$NON-NLS-2$
 		props.setProperty("soap_port", "12345"); //$NON-NLS-1$ //$NON-NLS-2$
-		CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", "1", props, DEBUG, DEBUG); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+		CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", 1, props, DEBUG, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
         context.setProcessorBatchSize(2000);
         context.setConnectorBatchSize(2000);
 		return context;
@@ -538,13 +541,10 @@
     }     
     
     private void sampleDataBQT1(FakeDataManager dataMgr) {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     
         try { 
             // Group bqt1.smalla
-            FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("bqt1.smalla"); //$NON-NLS-1$
-            List elementIDs = metadata.getElementIDsInGroupID(groupID);
-            List elementSymbols = FakeDataStore.createElements(elementIDs);
         
             List[] tuples = new List[20];
             for(int i=0; i<tuples.length; i++) {
@@ -555,13 +555,9 @@
                 }    
             }
         
-            dataMgr.registerTuples(groupID, elementSymbols, tuples);
+            dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
 
             // Group bqt2.mediumb
-            groupID = (FakeMetadataObject) metadata.getGroupID("bqt2.mediumb"); //$NON-NLS-1$
-            elementIDs = metadata.getElementIDsInGroupID(groupID);
-            elementSymbols = FakeDataStore.createElements(elementIDs);
-        
             tuples = new List[20];
             for(int i=0; i<tuples.length; i++) {
                 tuples[i] = new ArrayList(17);
@@ -571,16 +567,14 @@
                 }    
             }
         
-            dataMgr.registerTuples(groupID, elementSymbols, tuples);
-
+            dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples); //$NON-NLS-1$
         } catch(MetaMatrixException e) { 
         	throw new RuntimeException(e);
         }
     }
 
-
-    private void sampleDataBQT2(FakeDataManager dataMgr) {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+	private void sampleDataBQT2(FakeDataManager dataMgr) {
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     
         String[] groups = new String[] {"bqt1.smalla", "bqt2.smalla", "bqt3.smalla" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     
@@ -588,10 +582,6 @@
             for(int i=0; i<groups.length; i++) {
                 String groupName = groups[i];
     
-                FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID(groupName);
-                List elementIDs = metadata.getElementIDsInGroupID(groupID);
-                List elementSymbols = FakeDataStore.createElements(elementIDs);
-            
                 List[] tuples = new List[30];
                 for(int row=0; row<tuples.length; row++) {
                     tuples[row] = new ArrayList(17);
@@ -601,7 +591,7 @@
                     }    
                 }
         
-                dataMgr.registerTuples(groupID, elementSymbols, tuples);
+                dataMgr.registerTuples(metadata, groupName, tuples);
             }
 
         } catch(MetaMatrixException e) { 
@@ -615,14 +605,9 @@
      * @since 4.2
      */
     private void sampleDataBQT_defect11682(FakeDataManager dataMgr) {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     
         try { 
-            // Group bqt1.smalla
-            FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("bqt1.smalla"); //$NON-NLS-1$
-            List elementIDs = metadata.getElementIDsInGroupID(groupID);
-            List elementSymbols = FakeDataStore.createElements(elementIDs);
-        
             List[] tuples = new List[2];
             for(int i=1; i<=tuples.length; i++) {
                 int index=i-1;
@@ -645,23 +630,18 @@
                 tuples[index].add(new BigDecimal(i+".0")); //$NON-NLS-1$
                 tuples[index].add(null);
             }
-        
-            dataMgr.registerTuples(groupID, elementSymbols, tuples);
-
+            
+            dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$ 
+            
         } catch(MetaMatrixException e) { 
         	throw new RuntimeException(e);
         }
     }    
 
     private void sampleDataBQTSmall(FakeDataManager dataMgr) {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     
         try { 
-            // Group bqt1.smalla
-            FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("bqt1.smalla"); //$NON-NLS-1$
-            List elementIDs = metadata.getElementIDsInGroupID(groupID);
-            List elementSymbols = FakeDataStore.createElements(elementIDs);
-        
             List[] tuples = new List[1];
             for(int i=0; i<tuples.length; i++) {
                 tuples[i] = new ArrayList(17);
@@ -671,7 +651,7 @@
                 }    
             }
         
-            dataMgr.registerTuples(groupID, elementSymbols, tuples);
+            dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$ 
 
         } catch(MetaMatrixException e) { 
         	throw new RuntimeException(e);
@@ -687,17 +667,9 @@
     }
             
     private void sampleDataBQT_case1566(FakeDataManager dataMgr) throws Exception {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     
-        FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("bqt1.smalla"); //$NON-NLS-1$
-        List elementIDs = metadata.getElementIDsInGroupID(groupID);
-        List elementSymbols = FakeDataStore.createElements(elementIDs);
-    
-        dataMgr.registerTuples(
-            groupID,
-            elementSymbols,
-            
-            new List[] { 
+        dataMgr.registerTuples(metadata, "bqt1.smalla", new List[] { //$NON-NLS-1$ 
                 createRowWithTimestamp("2002-01-01 10:00:00"), //$NON-NLS-1$
                 createRowWithTimestamp("2002-01-01 14:00:00"), //$NON-NLS-1$
                 createRowWithTimestamp("2002-01-02 10:00:00"), //$NON-NLS-1$
@@ -1198,6 +1170,7 @@
         CommandContext context = createCommandContext();
         context.setProcessorBatchSize(2);
         context.setConnectorBatchSize(2);
+        context.setMetadata(FakeMetadataFactory.example1Cached());
         
         // Plan query
         ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), context);
@@ -2342,113 +2315,6 @@
         helpProcess(plan, dataManager, expected);
     }    
 
-    private static FakeMetadataFacade virtualBQT() {
-        // Create models
-        FakeMetadataObject bqt1 = FakeMetadataFactory.createPhysicalModel("BQT1"); //$NON-NLS-1$
-        FakeMetadataObject bqt2 = FakeMetadataFactory.createPhysicalModel("BQT2"); //$NON-NLS-1$
-        FakeMetadataObject bqt3 = FakeMetadataFactory.createPhysicalModel("BQT3"); //$NON-NLS-1$
-        FakeMetadataObject vqt = FakeMetadataFactory.createVirtualModel("BQT_V"); //$NON-NLS-1$
-        FakeMetadataObject vqt2 = FakeMetadataFactory.createVirtualModel("BQT2_V"); //$NON-NLS-1$
-        
-        // Create physical groups
-        FakeMetadataObject bqt1SmallA = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", bqt1); //$NON-NLS-1$
-        FakeMetadataObject bqt1SmallB = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallB", bqt1); //$NON-NLS-1$
-        FakeMetadataObject bqt1MediumA = FakeMetadataFactory.createPhysicalGroup("BQT1.MediumA", bqt1); //$NON-NLS-1$
-        FakeMetadataObject bqt1MediumB = FakeMetadataFactory.createPhysicalGroup("BQT1.MediumB", bqt1); //$NON-NLS-1$
-        FakeMetadataObject bqt2SmallA = FakeMetadataFactory.createPhysicalGroup("BQT2.SmallA", bqt2); //$NON-NLS-1$
-        FakeMetadataObject bqt2SmallB = FakeMetadataFactory.createPhysicalGroup("BQT2.SmallB", bqt2); //$NON-NLS-1$
-        FakeMetadataObject bqt2MediumA = FakeMetadataFactory.createPhysicalGroup("BQT2.MediumA", bqt2); //$NON-NLS-1$
-        FakeMetadataObject bqt2MediumB = FakeMetadataFactory.createPhysicalGroup("BQT2.MediumB", bqt2); //$NON-NLS-1$
-        FakeMetadataObject bqt3SmallA = FakeMetadataFactory.createPhysicalGroup("BQT3.SmallA", bqt3); //$NON-NLS-1$
-        FakeMetadataObject bqt3SmallB = FakeMetadataFactory.createPhysicalGroup("BQT3.SmallB", bqt3); //$NON-NLS-1$
-        FakeMetadataObject bqt3MediumA = FakeMetadataFactory.createPhysicalGroup("BQT3.MediumA", bqt3); //$NON-NLS-1$
-        FakeMetadataObject bqt3MediumB = FakeMetadataFactory.createPhysicalGroup("BQT3.MediumB", bqt3); //$NON-NLS-1$
-
-        // Create virtual groups
-        QueryNode vqtn1 = new QueryNode("BQT_V.BQT_V", "SELECT a.* FROM BQT1.SMALLA AS a WHERE a.INTNUM = (SELECT MIN(b.INTNUM) FROM BQT1.SMALLA AS b WHERE b.INTKEY = a.IntKey ) OPTION MAKEDEP a"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg1 = FakeMetadataFactory.createUpdatableVirtualGroup("BQT_V.BQT_V", vqt, vqtn1); //$NON-NLS-1$
-        QueryNode vqt2n1 = new QueryNode("BQT2_V.BQT2_V", "SELECT BQT2.SmallA.* FROM BQT2.SmallA, BQT_V.BQT_V WHERE BQT2.SmallA.IntKey = BQT_V.BQT_V.IntKey"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqt2g1 = FakeMetadataFactory.createUpdatableVirtualGroup("BQT2_V.BQT2_V", vqt2, vqt2n1); //$NON-NLS-1$
-
-                
-        // Create physical elements
-        String[] elemNames = new String[] { 
-             "IntKey", "StringKey",  //$NON-NLS-1$ //$NON-NLS-2$
-             "IntNum", "StringNum",  //$NON-NLS-1$ //$NON-NLS-2$
-             "FloatNum", "LongNum",  //$NON-NLS-1$ //$NON-NLS-2$
-             "DoubleNum", "ByteNum",  //$NON-NLS-1$ //$NON-NLS-2$
-             "DateValue", "TimeValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "TimestampValue", "BooleanValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "CharValue", "ShortValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "BigIntegerValue", "BigDecimalValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "ObjectValue" }; //$NON-NLS-1$
-         String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, 
-                             DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, 
-                             DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG, 
-                             DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE, 
-                             DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME, 
-                             DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN, 
-                             DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT, 
-                             DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, 
-                             DataTypeManager.DefaultDataTypes.OBJECT };
-        
-        List bqt1SmallAe = FakeMetadataFactory.createElements(bqt1SmallA, elemNames, elemTypes);
-        List bqt1SmallBe = FakeMetadataFactory.createElements(bqt1SmallB, elemNames, elemTypes);
-        List bqt1MediumAe = FakeMetadataFactory.createElements(bqt1MediumA, elemNames, elemTypes);
-        List bqt1MediumBe = FakeMetadataFactory.createElements(bqt1MediumB, elemNames, elemTypes);
-        List bqt2SmallAe = FakeMetadataFactory.createElements(bqt2SmallA, elemNames, elemTypes);
-        List bqt2SmallBe = FakeMetadataFactory.createElements(bqt2SmallB, elemNames, elemTypes);
-        List bqt2MediumAe = FakeMetadataFactory.createElements(bqt2MediumA, elemNames, elemTypes);
-        List bqt2MediumBe = FakeMetadataFactory.createElements(bqt2MediumB, elemNames, elemTypes);                
-        List bqt3SmallAe = FakeMetadataFactory.createElements(bqt3SmallA, elemNames, elemTypes);
-        List bqt3SmallBe = FakeMetadataFactory.createElements(bqt3SmallB, elemNames, elemTypes);
-        List bqt3MediumAe = FakeMetadataFactory.createElements(bqt3MediumA, elemNames, elemTypes);
-        List bqt3MediumBe = FakeMetadataFactory.createElements(bqt3MediumB, elemNames, elemTypes);                
-        // Create virtual elements
-        List vqtg1e = FakeMetadataFactory.createElements(vqtg1, elemNames, elemTypes);        
-        List vqt2g1e = FakeMetadataFactory.createElements(vqt2g1, elemNames, elemTypes);        
-
-        // Add all objects to the store
-        FakeMetadataStore store = new FakeMetadataStore();
-        store.addObject(bqt1);
-        store.addObject(bqt1SmallA);     
-        store.addObjects(bqt1SmallAe);
-        store.addObject(bqt1SmallB);     
-        store.addObjects(bqt1SmallBe);
-        store.addObject(bqt1MediumA);     
-        store.addObjects(bqt1MediumAe);
-        store.addObject(bqt1MediumB);     
-        store.addObjects(bqt1MediumBe);
-
-        store.addObject(bqt2);
-        store.addObject(bqt2SmallA);     
-        store.addObjects(bqt2SmallAe);
-        store.addObject(bqt2SmallB);     
-        store.addObjects(bqt2SmallBe);
-        store.addObject(bqt2MediumA);     
-        store.addObjects(bqt2MediumAe);
-        store.addObject(bqt2MediumB);     
-        store.addObjects(bqt2MediumBe);
-
-        store.addObject(bqt3);
-        store.addObject(bqt3SmallA);     
-        store.addObjects(bqt3SmallAe);
-        store.addObject(bqt3SmallB);     
-        store.addObjects(bqt3SmallBe);
-        store.addObject(bqt3MediumA);     
-        store.addObjects(bqt3MediumAe);
-        store.addObject(bqt3MediumB);     
-        store.addObjects(bqt3MediumBe);
-
-        store.addObject(vqtg1);     
-        store.addObjects(vqtg1e);
-        store.addObject(vqt2g1);     
-        store.addObjects(vqt2g1e);
-
-        // Create the facade from the store
-        return new FakeMetadataFacade(store);
-
-    }
     @Test public void testCorrelatedSubquery_CASE2022() {
         String sql = "select * from BQT2_V WHERE BQT2_V.IntKey < 50"; //$NON-NLS-1$
 
@@ -2476,8 +2342,7 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         // Plan query
-        ProcessorPlan plan = helpGetPlan(helpParse(sql), virtualBQT(), capFinder);
-        //ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
+        ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.exampleBQTCached(), capFinder);
 
         // Run query
         helpProcess(plan, dataManager, expected);
@@ -5200,7 +5065,9 @@
         g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
         
         Command command = helpParse(sql);   
-        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+        CommandContext context = createCommandContext();
+        context.setMetadata(metadata);
+        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder,context);
         
         //Verify a dependent join (not merge join) was used
         assertTrue(plan instanceof RelationalPlan);
@@ -5210,7 +5077,7 @@
         assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
 
         // Run query
-        helpProcess(plan, dataManager, expected);        
+        helpProcess(plan, context, dataManager, expected);        
     }     
 
     /** RLM Case 2077 */
@@ -5244,7 +5111,9 @@
         g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
         
         Command command = helpParse(sql);   
-        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+        CommandContext context = createCommandContext();
+        context.setMetadata(metadata);
+        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
         
         //Verify a dependent join (not merge join) was used
         assertTrue(plan instanceof RelationalPlan);
@@ -5254,7 +5123,7 @@
         assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
 
         // Run query
-        helpProcess(plan, dataManager, expected);        
+        helpProcess(plan, context, dataManager, expected);        
     }      
     
     @Test public void testPushingCriteriaUnderJoinButNotToSource() {
@@ -5312,7 +5181,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5348,7 +5217,7 @@
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5359,7 +5228,6 @@
     
     /** defect 15348*/
     @Test public void testPreparedStatementDefect15348(){
-        FakeFunctionMetadataSource.setupFunctionLibrary();
         String sql = "SELECT e1 from pm1.g1 where myrtrim(?)=e1"; //$NON-NLS-1$
 
         // Create expected results
@@ -5378,16 +5246,19 @@
         caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
         capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+        FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
         
+        
         Command command = helpParse(sql);   
-        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+        CommandContext context = createCommandContext();
+        context.setMetadata(metadata);        
+        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
         
         // Collect reference, set value
         Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
         VariableContext vc = new VariableContext();
         vc.setGlobalValue(ref.getContextSymbol(),  "a    "); //$NON-NLS-1$
-        CommandContext context = createCommandContext();
         context.setVariableContext(vc);
         // Run query
         helpProcess(plan, context, dataManager, expected);        
@@ -5396,8 +5267,6 @@
 
     /** defect 15348*/
     @Test public void testPreparedStatementDefect15348b(){
-        FakeFunctionMetadataSource.setupFunctionLibrary();  
-        
         String sql = "SELECT e1 from pm4.g1 where myrtrim(concat(?, 'a  '))=e1"; //$NON-NLS-1$
 
         // Create expected results
@@ -5417,16 +5286,19 @@
         caps.setFunctionSupport("concat", true); //$NON-NLS-1$
         capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+        FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
         
+        
         Command command = helpParse(sql);   
-        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+        CommandContext context = createCommandContext();
+        context.setMetadata(metadata);        
+        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
         
         // Collect reference, set value
         Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
         VariableContext vc = new VariableContext();
         vc.setGlobalValue(ref.getContextSymbol(), "a"); //$NON-NLS-1$
-        CommandContext context = createCommandContext();
         context.setVariableContext(vc);
         
         // Run query
@@ -5446,7 +5318,7 @@
         caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5477,7 +5349,7 @@
         caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5525,7 +5397,7 @@
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5572,7 +5444,7 @@
         caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5608,7 +5480,7 @@
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5646,7 +5518,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5685,7 +5557,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5718,7 +5590,7 @@
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5757,7 +5629,7 @@
         caps.setCapabilitySupport(Capability.QUERY_UNION, true);
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
 
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -5854,7 +5726,7 @@
         caps.setFunctionSupport("concat", true); //$NON-NLS-1$
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
 
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = TestOptimizer.helpPlan(sql,         
                                       metadata,
@@ -5916,9 +5788,8 @@
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
-       
         ProcessorPlan plan = TestOptimizer.helpPlan(sql,         
                           metadata,
                           null, capFinder,
@@ -6453,18 +6324,14 @@
         helpProcess(plan, dataManager, expected);  
     }
         
-    private void sampleDataBQT2a(FakeDataManager dataMgr) throws QueryMetadataException, MetaMatrixComponentException {
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+    private void sampleDataBQT2a(FakeDataManager dataMgr) throws Exception {
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     
         String[] groups = new String[] {"bqt1.smalla", "bqt2.smalla", "bqt3.smalla" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     
         for(int groupIndex=0; groupIndex<groups.length; groupIndex++) {
             String groupName = groups[groupIndex];
 
-            FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID(groupName);
-            List elementIDs = metadata.getElementIDsInGroupID(groupID);
-            List elementSymbols = FakeDataStore.createElements(elementIDs);
-        
             List[] tuples = new List[3];
             for(int row=0; row<tuples.length; row++) {
                 tuples[row] = new ArrayList(17);
@@ -6479,7 +6346,7 @@
                 tuples[row].add(new BigDecimal(row)); //BigDecimalValue
                 tuples[row].add(null);    //ObjectValue
             }
-            dataMgr.registerTuples(groupID, elementSymbols, tuples);
+            dataMgr.registerTuples(metadata, groupName, tuples);
         }
     }    
     
@@ -6549,7 +6416,7 @@
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6579,7 +6446,7 @@
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6609,7 +6476,7 @@
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6639,7 +6506,7 @@
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6669,7 +6536,7 @@
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6699,7 +6566,7 @@
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6729,7 +6596,7 @@
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6759,7 +6626,7 @@
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6789,7 +6656,7 @@
         capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
         capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
         
-        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQT();
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         
         Command command = helpParse(sql);   
         ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
@@ -6842,8 +6709,11 @@
 
         // Plan query
         String sql = "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 1) = e1";//$NON-NLS-1$
+        QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         Command command = TestProcessor.helpParse(sql);   
-        ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+        CommandContext context = createCommandContext();
+        context.setMetadata(metadata);
+        ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
         
         // Run query
         List[] expected = new List[] {
@@ -6857,7 +6727,7 @@
         dataManager.defineCodeTable("pm1.g1", "e2", "e1", valueMap); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         dataManager.setThrowBlocked(true);
         
-        helpProcess(plan, dataManager, expected);
+        helpProcess(plan, context, dataManager, expected);
     } 
     
     @Test public void testRaiseNullWithSelectInto() {

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -55,7 +55,7 @@
         BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
         FakeDataManager dataManager = new FakeDataManager();
 
-        CommandContext context = new CommandContext("pid", "group", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "group", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
         QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
         BatchCollector collector = processor.createBatchCollector();
         TupleBuffer tsID = null;
@@ -136,5 +136,4 @@
         FakeProcessorPlan plan = new FakeProcessorPlan(elements, batches);
         helpTestProcessor(plan, 1000, expectedResults);                    
     }
-    
 }

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -78,9 +78,7 @@
         
         CommandContext context = new CommandContext();
         context.setSecurityFunctionEvaluator(new SecurityFunctionEvaluator() {
-
-            public boolean hasRole(String connectionID,
-                                   String roleType,
+            public boolean hasRole(String roleType,
                                    String roleName) throws MetaMatrixComponentException {
                 return false;
             }});

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -491,10 +491,9 @@
 
     private BufferManager createCustomBufferMgr(int batchSize) throws MetaMatrixComponentException {
         BufferManagerImpl bufferMgr = new BufferManagerImpl();
-        Properties props = new Properties();
         bufferMgr.setConnectorBatchSize(batchSize);
         bufferMgr.setProcessorBatchSize(batchSize);
-        bufferMgr.initialize(props);
+        bufferMgr.initialize();
 
         // Add unmanaged memory storage manager
         bufferMgr.setStorageManager(new MemoryStorageManager());

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -39,7 +39,7 @@
 import com.metamatrix.common.buffer.BlockedException;
 import com.metamatrix.query.eval.Evaluator;
 import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
 import com.metamatrix.query.processor.FakeDataManager;
 import com.metamatrix.query.processor.ProcessorDataManager;
 import com.metamatrix.query.sql.lang.CollectionValueIterator;
@@ -198,7 +198,7 @@
         e2.setType(String.class);
         
         Function func = new Function("concat", new Expression[] { e1, e2 }); //$NON-NLS-1$
-        FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
+        FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
         func.setFunctionDescriptor(desc);
 
         SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -220,7 +220,7 @@
         e2.setType(String.class);
         
         Function func = new Function("concat", new Expression[] { e2, e1 }); //$NON-NLS-1$
-        FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
+        FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
         func.setFunctionDescriptor(desc);
 
         SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -241,7 +241,7 @@
         e1.setType(Integer.class);        
         
         Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), e1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
+        FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
         func.setFunctionDescriptor(desc);
 
         SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -313,11 +313,11 @@
 
     public void testUser() throws Exception {
         Function func = new Function("user", new Expression[] {}); //$NON-NLS-1$
-        FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("user", new Class[] {} );         //$NON-NLS-1$
+        FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("user", new Class[] {} );         //$NON-NLS-1$
         func.setFunctionDescriptor(desc);
 
         FakeDataManager dataMgr = new FakeDataManager();
-        CommandContext context = new CommandContext(new Long(1), null, null, null, null);
+        CommandContext context = new CommandContext(new Long(1), null, null, null, 0);
         context.setUserName("logon");  //$NON-NLS-1$
         assertEquals(context.getUserName(), new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList()) );       
     } 
@@ -330,7 +330,7 @@
      */
     public void testEnv() throws Exception {
         Function func = new Function("env", new Expression[] {}); //$NON-NLS-1$
-        FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("env", new Class[] {String.class} );         //$NON-NLS-1$
+        FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("env", new Class[] {String.class} );         //$NON-NLS-1$
         func.setFunctionDescriptor(desc);
         
         FakeDataManager dataMgr = new FakeDataManager();
@@ -338,7 +338,7 @@
         Properties props = new Properties();
         props.setProperty("http_host", "testHostName"); //$NON-NLS-1$ //$NON-NLS-2$
         props.setProperty("http_port", "8000"); //$NON-NLS-1$ //$NON-NLS-2$
-        CommandContext context = new CommandContext(new Long(1), null, null, null, null, null, props, false, false);
+        CommandContext context = new CommandContext(new Long(1), null, null, null, null, 0, props, false, false);
         
         func.setArgs(new Expression[] {new Constant("http_host")}); //$NON-NLS-1$
         assertEquals("testHostName", new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList())); //$NON-NLS-1$
@@ -356,11 +356,11 @@
         } else {
             parameterSignature = new Class[] { String.class };
         }        
-        FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("commandpayload", parameterSignature );         //$NON-NLS-1$
+        FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("commandpayload", parameterSignature );         //$NON-NLS-1$
         func.setFunctionDescriptor(desc);
         
         FakeDataManager dataMgr = new FakeDataManager();       
-        CommandContext context = new CommandContext(new Long(-1), null, "user", payload, "vdb", "1", null, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        CommandContext context = new CommandContext(new Long(-1), null, "user", payload, "vdb", 1, null, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
 
         if(property != null) {
             func.setArgs(new Expression[] {new Constant(property)}); 

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -45,10 +45,10 @@
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.common.types.XMLType;
 import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.StringUtilities;
 import com.metamatrix.dqp.message.ParameterInfo;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.mapping.relational.QueryNode;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.QueryOptimizer;
 import com.metamatrix.query.optimizer.TestOptimizer;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
@@ -110,13 +110,17 @@
         }
     }
     
-    static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
+    static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr, QueryMetadataInterface metadata) throws SQLException, MetaMatrixCoreException {
         // Process twice, testing reset and clone method of Processor plan
         for (int i=1; i<=2; i++) {
-	        BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
-            CommandContext context = new CommandContext("pID", null, null, null, null); //$NON-NLS-1$
+        	
+            CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
             context.getNextRand(0);
             context.setProcessDebug(DEBUG);
+            context.setMetadata(metadata);        	
+        	
+	        BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
+
             QueryProcessor processor = new QueryProcessor(procPlan, context, bufferMgr, dataMgr);
             processor.setNonBlocking(true);
             BatchCollector collector = processor.createBatchCollector();  
@@ -173,7 +177,7 @@
             //reset and clone after 1st run
             if (i==1) {
                 procPlan.reset();
-                procPlan = (ProcessorPlan)procPlan.clone();
+                procPlan = procPlan.clone();
             }
         }
     }
@@ -192,12 +196,12 @@
     }
     
     private void helpTestProcess(ProcessorPlan procPlan, int expectedRows, FakeDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
-        helpTestProcess(procPlan, expectedRows, null, false, dataMgr);
+        helpTestProcess(procPlan, expectedRows, null, false, dataMgr, null);
     }
     
     static void helpTestProcess(boolean optimistic, ProcessorPlan procPlan, List[] expectedResults, 
     		ProcessorDataManager dataMgr, boolean shouldFail) throws SQLException, MetaMatrixCoreException {
-        helpTestProcess(procPlan, 0, expectedResults, shouldFail, dataMgr);
+        helpTestProcess(procPlan, 0, expectedResults, shouldFail, dataMgr, null);
     }
 
     // Helper to create a list of elements - used in creating sample data
@@ -2257,9 +2261,10 @@
 
         ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
         
-        helpTestProcess(plan, new List[] {
+        
+        helpTestProcess(plan, 0, new List[] {
             Arrays.asList(new Object[] {new Integer(240)}),
-            Arrays.asList(new Object[] {new Integer(637)})}, dataMgr);
+            Arrays.asList(new Object[] {new Integer(637)})}, false, dataMgr, metadata);
     }
 
     private FakeMetadataFacade createProcedureMetadata(String procedure) {
@@ -2326,7 +2331,7 @@
         FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2);  //$NON-NLS-1$
         FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("input", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null);  //$NON-NLS-1$
         QueryNode sq2n1 = new QueryNode("xqttest.proc", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
-                                        + "declare integer VARIABLES.x = input; SELECT * FROM xmltest.doc9 WHERE context(SupplierID, OrderID)=x OR OrderID='2'; END"); //$NON-NLS-1$ 
+                                        + "declare integer VARIABLES.x = xqttest.proc.input; SELECT * FROM xmltest.doc9 WHERE context(SupplierID, OrderID)=x OR OrderID='2'; END"); //$NON-NLS-1$ 
         FakeMetadataObject sq2 = FakeMetadataFactory.createVirtualProcedure("xqttest.proc", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1);  //$NON-NLS-1$
 
         metadata.getStore().addObject(rs2);
@@ -2348,14 +2353,14 @@
         FakeDataManager dataMgr = TestXMLProcessor.exampleDataManagerNested(metadata);
         String resultFile = "TestXMLProcessor-testNested2WithContextCriteria5d.xml"; //$NON-NLS-1$
         String expectedDoc = TestXMLProcessor.readFile(resultFile);
-        expectedDoc = StringUtilities.removeChars(expectedDoc, new char[] {'\r'});        
+        expectedDoc = expectedDoc.replaceAll("\\r", ""); //$NON-NLS-1$ //$NON-NLS-2$        
         FakeMetadataObject pm1 = metadata.getStore().findObject("xqttest",FakeMetadataObject.MODEL); //$NON-NLS-1$
         
         FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("pm1.rs2", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.XML }); //$NON-NLS-1$ //$NON-NLS-2$
         FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2);  //$NON-NLS-1$
         FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("input", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null);  //$NON-NLS-1$
         QueryNode sq2n1 = new QueryNode("xqttest.proc", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
-                                        + "declare integer VARIABLES.x = input; declare xml y = SELECT * FROM xmltest.doc9 WHERE context(SupplierID, OrderID)=x OR OrderID='2'; select convert(y, string); END"); //$NON-NLS-1$ 
+                                        + "declare integer VARIABLES.x = xqttest.proc.input; declare xml y = SELECT * FROM xmltest.doc9 WHERE context(SupplierID, OrderID)=x OR OrderID='2'; select convert(y, string); END"); //$NON-NLS-1$ 
         FakeMetadataObject sq2 = FakeMetadataFactory.createVirtualProcedure("xqttest.proc", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1);  //$NON-NLS-1$
 
         metadata.getStore().addObject(rs2);
@@ -2422,7 +2427,7 @@
         FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2);  //$NON-NLS-1$
         FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("input", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null);  //$NON-NLS-1$
         QueryNode sq2n1 = new QueryNode("xmltest.proc", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
-                                        + "declare integer VARIABLES.x = input; SELECT * FROM xmltest.doc9 WHERE context(SupplierID, SupplierID)=x; END"); //$NON-NLS-1$ 
+                                        + "declare integer VARIABLES.x = xmltest.proc.input; SELECT * FROM xmltest.doc9 WHERE context(SupplierID, SupplierID)=x; END"); //$NON-NLS-1$ 
         FakeMetadataObject sq2 = FakeMetadataFactory.createVirtualProcedure("xmltest.proc", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1);  //$NON-NLS-1$
 
         metadata.getStore().addObject(rs2);

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -41,21 +41,19 @@
     	bufferManager.setProcessorBatchSize(procBatchSize);
     	bufferManager.setConnectorBatchSize(connectorBatchSize);
         // Get the properties for BufferManager
-        Properties bmProps = new Properties();                        
-        return createBufferManager(bufferManager, bmProps);
+        return createBufferManager(bufferManager);
     }
     
     static BufferManager getTestBufferManager(long bytesAvailable, int procBatchSize) {
     	BufferManagerImpl bufferManager = new BufferManagerImpl();
     	bufferManager.setProcessorBatchSize(procBatchSize);
         // Get the properties for BufferManager
-        Properties bmProps = new Properties();                        
-        return createBufferManager(bufferManager, bmProps);
+        return createBufferManager(bufferManager);
     }
     
-    static BufferManager createBufferManager(BufferManagerImpl bufferManager, Properties bmProps) {
+    static BufferManager createBufferManager(BufferManagerImpl bufferManager) {
         try {
-			bufferManager.initialize(bmProps);
+			bufferManager.initialize();
 		} catch (MetaMatrixComponentException e) {
 			throw new RuntimeException(e);
 		}

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -61,6 +61,7 @@
         BatchedUpdateNode node = new BatchedUpdateNode(1, commands, Collections.EMPTY_LIST, shouldEvaluate, "myModelName"); //$NON-NLS-1$
         CommandContext context = new CommandContext();
         context.setProcessorID("myProcessorID"); //$NON-NLS-1$
+        context.setMetadata(md);
         node.initialize(context, Mockito.mock(BufferManager.class), pdm); 
         return node;
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -43,7 +43,7 @@
 import com.metamatrix.common.buffer.impl.BufferManagerImpl;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
 import com.metamatrix.query.function.aggregate.AggregateFunction;
 import com.metamatrix.query.function.aggregate.NullFilter;
 import com.metamatrix.query.processor.FakeDataManager;
@@ -156,7 +156,7 @@
 		List groupingElements = new ArrayList();
 		groupingElements.add(col1);
 		node.setGroupingElements(groupingElements);	  
-        CommandContext context = new CommandContext("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         List[] expected = new List[] {
             Arrays.asList(new Object[] { null, new Integer(2), new Integer(1), new Integer(1), new Long(3), new Long(3), new Double(3.0), new Double(3.0), new Integer(3), new Integer(3), new Integer(3), new Integer(3) }),
@@ -182,7 +182,7 @@
         BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
 
         GroupingNode node = getExampleGroupingNode();         
-        CommandContext context = new CommandContext("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         List[] expected = new List[] {
             Arrays.asList(new Object[] { null, new Integer(1) }),
@@ -204,7 +204,7 @@
         ((BufferManagerImpl)mgr).setProcessorBatchSize(5);
 
         GroupingNode node = getExampleGroupingNode();         
-        CommandContext context = new CommandContext("pid", "test", null, null,  null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null,  1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         List[] expected = new List[] {
             Arrays.asList(new Object[] { null, new Integer(1) }),
@@ -235,7 +235,7 @@
         
         // Set grouping elements to null 
         node.setGroupingElements(null);         
-        CommandContext context = new CommandContext("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         List[] data = new List[] {
             Arrays.asList(new Object[] { new BigDecimal("0.0") }),     //$NON-NLS-1$
@@ -275,7 +275,7 @@
         List groupingElements = new ArrayList();
         groupingElements.add(col1); //$NON-NLS-1$
         node.setGroupingElements(groupingElements);         
-        CommandContext context = new CommandContext("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         List[] data = new List[] {
             Arrays.asList(new Object[] { new Integer(1), new BigDecimal("0.0") }),     //$NON-NLS-1$
@@ -310,7 +310,7 @@
         col2.setType(Integer.class);
         
         Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), col2 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
+        FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
         func.setFunctionDescriptor(desc);
         func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
         
@@ -323,7 +323,7 @@
         List groupingElements = new ArrayList();
         groupingElements.add(col1); //$NON-NLS-1$
         node.setGroupingElements(groupingElements);   
-        CommandContext context = new CommandContext("pid", "test", null, null, null);    //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);    //$NON-NLS-1$ //$NON-NLS-2$
         
         FakeDataManager dataMgr = new FakeDataManager();
         dataMgr.setThrowBlocked(true);
@@ -370,7 +370,7 @@
             groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
             node.setGroupingElements(groupingElements);
         }
-        CommandContext context = new CommandContext("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         List[] data = new List[] {
         };
@@ -407,7 +407,7 @@
 
         GroupingNode node = getExampleGroupingNode();     
         node.setRemoveDuplicates(true);
-        CommandContext context = new CommandContext("pid", "test", null, null,  null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null,  1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         List[] expected = new List[] {
             Arrays.asList(new Object[] { null, new Integer(1) }),

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,7 +22,7 @@
 
 package com.metamatrix.query.processor.relational;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -40,7 +40,7 @@
 import com.metamatrix.common.buffer.TupleBatch;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
 import com.metamatrix.query.processor.FakeDataManager;
 import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
 import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -203,7 +203,7 @@
 
             case FUNCTION_CRITERIA :
                 Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-                FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class }); //$NON-NLS-1$
+                FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class }); //$NON-NLS-1$
                 func.setFunctionDescriptor(desc);
                 func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
                 CompareCriteria joinCriteria = new CompareCriteria(es2, CompareCriteria.EQ, func);
@@ -232,7 +232,7 @@
     
     public void helpTestJoinDirect(List[] expectedResults, int batchSize) throws MetaMatrixComponentException, MetaMatrixProcessingException {
         BufferManager mgr = NodeTestUtil.getTestBufferManager(1, batchSize);
-        CommandContext context = new CommandContext("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         join.addChild(leftNode);
         join.addChild(rightNode);

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -39,7 +39,7 @@
 import com.metamatrix.common.buffer.TupleBatch;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
 import com.metamatrix.query.processor.FakeDataManager;
 import com.metamatrix.query.processor.ProcessorDataManager;
 import com.metamatrix.query.sql.symbol.Constant;
@@ -63,7 +63,7 @@
     
     public ProjectNode helpSetupProject(List elements, List[] data, List childElements, ProcessorDataManager dataMgr) throws MetaMatrixComponentException {
         BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
-        CommandContext context = new CommandContext("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         FakeRelationalNode dataNode = new FakeRelationalNode(2, data);
         dataNode.setElements(childElements);
@@ -211,7 +211,7 @@
         elements.add(es1);
         
         Function func = new Function("concat", new Expression[] { es1, new Constant("abc")}); //$NON-NLS-1$ //$NON-NLS-2$
-        FunctionDescriptor fd = FunctionLibraryManager.getFunctionLibrary().findFunction("concat", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
+        FunctionDescriptor fd = SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
         func.setFunctionDescriptor(fd);
         func.setType(DataTypeManager.DefaultDataClasses.STRING);
         ExpressionSymbol expr = new ExpressionSymbol("expr", func); //$NON-NLS-1$
@@ -235,7 +235,7 @@
         elements.add(es1);
         
         Function func = new Function("convert", new Expression[] { es1, new Constant("integer")}); //$NON-NLS-1$ //$NON-NLS-2$
-        FunctionDescriptor fd = FunctionLibraryManager.getFunctionLibrary().findFunction("convert", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
+        FunctionDescriptor fd = SystemFunctionManager.getSystemFunctionLibrary().findFunction("convert", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
         func.setFunctionDescriptor(fd);
         func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
         ExpressionSymbol expr = new ExpressionSymbol("expr", func); //$NON-NLS-1$
@@ -258,7 +258,7 @@
         elements.add(es1);
 
         Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
+        FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
         func.setFunctionDescriptor(desc);
         func.setType(DataTypeManager.DefaultDataClasses.STRING);
         

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -116,7 +116,7 @@
         
         FakeRelationalNode fakeNode = new FakeRelationalNode(1, data, 100);
         fakeNode.setElements(elements);
-        CommandContext context = new CommandContext("pid", "group", null, null, null, null, null, false, true); //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "group", null, null, null, 1, null, false, true); //$NON-NLS-1$ //$NON-NLS-2$
         fakeNode.initialize(context, BufferManagerFactory.getStandaloneBufferManager(), null);
         return fakeNode;
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -38,8 +38,9 @@
 import com.metamatrix.common.buffer.TupleBatch;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
 import com.metamatrix.query.processor.BatchIterator;
+import com.metamatrix.query.processor.BatchIterator;
 import com.metamatrix.query.processor.FakeDataManager;
 import com.metamatrix.query.processor.ProcessorDataManager;
 import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -68,7 +69,7 @@
     
     public void helpTestSelect(List elements, Criteria criteria, List childElements, ProcessorDataManager dataMgr, List[] expected, RelationalNode child) throws MetaMatrixComponentException, MetaMatrixProcessingException {
         BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
-        CommandContext context = new CommandContext("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         child.setElements(childElements);
         child.initialize(context, mgr, dataMgr);    
@@ -203,7 +204,7 @@
         elements.add(es1);
 
         Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        FunctionDescriptor desc = FunctionLibraryManager.getFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
+        FunctionDescriptor desc = SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
         func.setFunctionDescriptor(desc);
         func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
         CompareCriteria crit = new CompareCriteria(func, CompareCriteria.EQ, new Constant(new Integer(1))); 

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -52,7 +52,7 @@
     
     private void helpTestSort(List elements, List[] data, List sortElements, List sortTypes, List[] expected, Mode mode) throws MetaMatrixComponentException, MetaMatrixProcessingException {
         BufferManager mgr = NodeTestUtil.getTestBufferManager(100, BATCH_SIZE, BATCH_SIZE);
-        CommandContext context = new CommandContext ("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext ("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         BlockingFakeRelationalNode dataNode = new BlockingFakeRelationalNode(2, data);
         dataNode.setReturnPeriod(3);

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -51,7 +51,7 @@
     
     public void helpTestUnion(RelationalNode[] children, RelationalNode union, List[] expected) throws MetaMatrixComponentException, MetaMatrixProcessingException {
         BufferManager mgr = NodeTestUtil.getTestBufferManager(1, 2);
-        CommandContext context = new CommandContext("pid", "test", null, null, null);               //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
         
         for(int i=0; i<children.length; i++) {
             union.addChild(children[i]);

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -348,7 +348,7 @@
         
         BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
         XMLPlan temp = new XMLPlan(env);
-        CommandContext context = new CommandContext("pid", null, null, null, null); //$NON-NLS-1$
+        CommandContext context = new CommandContext("pid", null, null, null, 1); //$NON-NLS-1$
         temp.initialize(context,null,bufferMgr);
 
         List schema = new ArrayList();
@@ -404,7 +404,7 @@
                 
         BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
         XMLPlan temp = new XMLPlan(env);
-        CommandContext context = new CommandContext("pid", null, null, null, null); //$NON-NLS-1$
+        CommandContext context = new CommandContext("pid", null, null, null, 1); //$NON-NLS-1$
         temp.initialize(context,null,bufferMgr);
         env.addData(resultSetName, command.getProjectedSymbols(), new List[] { 
                     Arrays.asList( new Object[] { "001", "Lamp", new Integer(5) } ),         //$NON-NLS-1$ //$NON-NLS-2$

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -2962,7 +2962,7 @@
             // Process twice, to test reset and clone methods
             for (int i=1; i<=2; i++) {
                 BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();                
-                CommandContext context = new CommandContext("pID", "TestConn", "testUser", null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                CommandContext context = new CommandContext("pID", "TestConn", "testUser", null, 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                 context.setProcessDebug(DEBUG);
                 QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
                 processor.setNonBlocking(true);
@@ -2999,7 +2999,7 @@
             XMLPlan plan = (XMLPlan)QueryOptimizer.optimizePlan(command, metadata, null, new DefaultCapabilitiesFinder(), analysisRecord, null);
     
             BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
-            CommandContext context = new CommandContext("pID", null, null, null, null);                                                                 //$NON-NLS-1$
+            CommandContext context = new CommandContext("pID", null, null, null, 1);                                                                 //$NON-NLS-1$
             QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
             processor.setNonBlocking(true);
             BatchCollector collector = processor.createBatchCollector();
@@ -3045,7 +3045,7 @@
         }
         
         BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
-        CommandContext context = new CommandContext("pID", null, null, null, null);                                 //$NON-NLS-1$
+        CommandContext context = new CommandContext("pID", null, null, null, 1);                                 //$NON-NLS-1$
         QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
         processor.setNonBlocking(true);
         BatchCollector collector = processor.createBatchCollector();
@@ -6053,7 +6053,7 @@
         XMLPlan plan = TestXMLPlanner.preparePlan(command, metadata, new DefaultCapabilitiesFinder(), null);
 
         BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
-        CommandContext context = new CommandContext("pID", null, null, null, null);                                 //$NON-NLS-1$
+        CommandContext context = new CommandContext("pID", null, null, null, 1);                                 //$NON-NLS-1$
         QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
         processor.setNonBlocking(true);
         BatchCollector collector = processor.createBatchCollector();

Deleted: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,1639 +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 static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-
-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.dqp.message.ParameterInfo;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.parser.QueryParser;
-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.Insert;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.LoopStatement;
-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.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-
-public class TestProcedureResolving {
-
- 	private QueryMetadataInterface exampleStoredProcedure(String procedure) {
-		FakeMetadataFacade metadata = FakeMetadataFactory.example1();
-        
-        FakeMetadataObject pm1 = metadata.getStore().findObject("pm1",FakeMetadataObject.MODEL); //$NON-NLS-1$
-        FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("pm1.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2);  //$NON-NLS-1$
-        FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null);  //$NON-NLS-1$
-        QueryNode sq2n1 = new QueryNode("pm1.sq1", procedure); //$NON-NLS-1$ 
-        FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("pm1.sq1", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1);  //$NON-NLS-1$
-
-        metadata.getStore().addObject(rs2);
-        metadata.getStore().addObject(sq1);
-        
-        return metadata;
-	}
- 	
-    private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType) {
-        helpFailUpdateProcedure(procedure, userUpdateStr, procedureType, null);
-    }
-    
-	private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType, String msg) {
-        // resolve
-        try {
-    		helpResolveUpdateProcedure(procedure, userUpdateStr, procedureType);
-            fail("Expected a QueryResolverException but got none."); //$NON-NLS-1$
-        } catch(QueryResolverException ex) {
-        	if (msg != null) {
-                assertEquals(msg, ex.getMessage());
-            }
-        } catch (MetaMatrixComponentException e) {
-        	throw new RuntimeException(e);
-		} catch (QueryParserException e) {
-			throw new RuntimeException(e);
-		} 
-	}	
-	
-    public static Map getProcedureExternalMetadata(GroupSymbol virtualGroup, QueryMetadataInterface metadata)
-    throws QueryMetadataException, MetaMatrixComponentException {
-        Map externalMetadata = new HashMap();
-
-        // Look up elements for the virtual group
-        List elements = ResolverUtil.resolveElementsInGroup(virtualGroup, metadata);
-        // virtual group metadata info
-        externalMetadata.put(virtualGroup, elements);
-
-        // INPUT group metadata info
-        GroupSymbol inputGroup = new GroupSymbol(ProcedureReservedWords.INPUT);
-        List inputElments = new ArrayList(elements.size());
-        List elementIds = new ArrayList();
-        for(int i=0; i<elements.size(); i++) {
-            ElementSymbol virtualElmnt = (ElementSymbol)elements.get(i);
-            ElementSymbol inputElement = (ElementSymbol)virtualElmnt.clone();
-            inputElments.add(inputElement);
-            elementIds.add(new TempMetadataID(ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + virtualElmnt.getShortName(), virtualElmnt.getType()));
-        }
-        inputGroup.setMetadataID(new TempMetadataID(ProcedureReservedWords.INPUT, elementIds));
-        externalMetadata.put(inputGroup, inputElments);
-
-        // CHANGING group metadata info
-        // Switch type to be boolean for all CHANGING variables
-        GroupSymbol changeGroup = new GroupSymbol(ProcedureReservedWords.CHANGING);
-        List changingElments = new ArrayList(elements.size());
-        elementIds = new ArrayList();
-        for(int i=0; i<elements.size(); i++) {
-            ElementSymbol changeElement = (ElementSymbol)((ElementSymbol)elements.get(i)).clone();
-            changeElement.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
-            changingElments.add(changeElement);
-            elementIds.add(new TempMetadataID(ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + changeElement.getShortName(), changeElement.getType()));
-        }
-        changeGroup.setMetadataID(new TempMetadataID(ProcedureReservedWords.CHANGING, elementIds));
-        externalMetadata.put(changeGroup, changingElments);
-
-        return externalMetadata;
-    }
-	
-    @Test public void testDefect13029_CorrectlySetUpdateProcedureTempGroupIDs() throws Exception {
-        StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
-            .append("\nBEGIN") //$NON-NLS-1$
-            .append("\nDECLARE string var1;") //$NON-NLS-1$
-            .append("\nvar1 = '';") //$NON-NLS-1$
-            .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
-            .append("\n  BEGIN") //$NON-NLS-1$
-            .append("\n    LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor2") //$NON-NLS-1$
-            .append("\n    BEGIN") //$NON-NLS-1$
-            .append("\n      var1 = CONCAT(var1, CONCAT(' ', loopCursor2.e1));") //$NON-NLS-1$
-            .append("\n    END") //$NON-NLS-1$
-            .append("\n  END") //$NON-NLS-1$
-            .append("\nEND"); //$NON-NLS-1$
-            
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        Command command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
-        Map tempIDs = command.getTemporaryMetadata();
-        assertNotNull(tempIDs);
-        assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
-        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
-        
-        Command subCommand = command.getSubCommands().get(0);
-        tempIDs = subCommand.getTemporaryMetadata();
-        assertNotNull(tempIDs);
-        assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
-        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
-
-        subCommand = command.getSubCommands().get(1);
-        tempIDs = subCommand.getTemporaryMetadata();
-        assertNotNull(tempIDs);
-        assertNotNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
-        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
-    }
-    
-	private CreateUpdateProcedureCommand helpResolveUpdateProcedure(String procedure, String userUpdateStr, String procedureType) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
-		return resolveProcedure(userUpdateStr, metadata);
-	}
-
-	private CreateUpdateProcedureCommand resolveProcedure(String userUpdateStr,
-			QueryMetadataInterface metadata) throws QueryParserException,
-			QueryResolverException, MetaMatrixComponentException,
-			QueryMetadataException {
-		ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr); 
-        QueryResolver.resolveCommand(userCommand, metadata);
-        metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(userCommand.getTemporaryMetadata()));
-        return (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, null);
-	}
-
-	private void helpResolveException(String userUpdateStr, QueryMetadataInterface metadata, String msg) throws QueryParserException, MetaMatrixComponentException {
-		try {
-			helpResolve(userUpdateStr, metadata);
-		} catch (QueryResolverException e) {
-			assertEquals(msg, e.getMessage());
-		}
-	}
-
-	private CreateUpdateProcedureCommand helpResolve(String userUpdateStr, QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
-		return resolveProcedure(userUpdateStr, metadata);
-	}
-    
-    /**
-     *  Constants will now auto resolve if they are consistently representable in the target type
-     */
-    @Test public void testDefect23257() throws Exception{
-    	CreateUpdateProcedureCommand command = helpResolve("EXEC pm5.vsp59()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
-        
-        CommandStatement cs = (CommandStatement)command.getBlock().getStatements().get(1);
-        
-        Insert insert = (Insert)cs.getCommand();
-        
-        assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression)insert.getValues().get(1)).getType());
-    } 
-    
-    @Test public void testProcedureScoping() throws Exception {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        //note that this declare takes presedense over the proc INPUT.e1 and CHANGING.e1 variables
-        .append("\n  declare integer e1 = 1;") //$NON-NLS-1$
-        .append("\n  e1 = e1;") //$NON-NLS-1$
-        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
-        .append("\n  BEGIN") //$NON-NLS-1$
-        //inside the scope of the loop, an unqualified e1 should resolve to the loop variable group
-        .append("\n    variables.e1 = convert(e1, integer);") //$NON-NLS-1$
-        .append("\n  END") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        CreateUpdateProcedureCommand command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
-        
-        Block block = command.getBlock();
-        
-        AssignmentStatement assStmt = (AssignmentStatement)block.getStatements().get(1);
-        assertEquals(ProcedureReservedWords.VARIABLES, assStmt.getVariable().getGroupSymbol().getCanonicalName());
-        assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)assStmt.getValue()).getGroupSymbol().getCanonicalName());
-        
-        Block inner = ((LoopStatement)block.getStatements().get(2)).getBlock();
-        
-        assStmt = (AssignmentStatement)inner.getStatements().get(0);
-        
-        ElementSymbol value = ElementCollectorVisitor.getElements(assStmt.getValue(), false).iterator().next();
-        
-        assertEquals("LOOPCURSOR", value.getGroupSymbol().getCanonicalName()); //$NON-NLS-1$
-    }
-    
-	// variable resolution, variable used in if statement, variable compared against
-	// different datatype element
-    @Test public void testCreateUpdateProcedure4() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1);\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// variable resolution, variable used in if statement, invalid operation on variable
-    @Test public void testCreateUpdateProcedure5() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = var1 + var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 whwre var1 = var1+var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }    
-    
-	// variable resolution, variables declared in different blocks local variables
-	// should not override
-    @Test public void testCreateUpdateProcedure6() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable var1 was previously declared."); //$NON-NLS-1$
-    }
-    
-	// variable resolution, variables declared in different blocks local variables
-	// inner block using outer block variables
-    @Test public void testCreateUpdateProcedure7() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var2;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// variable resolution, variables declared in different blocks local variables
-	// outer block cannot use inner block variables
-    @Test public void testCreateUpdateProcedure8() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var2;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-        procedure = procedure + "var2 = 1\n";                 //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }     
-    
-	// variable resolution, variables declared in different blocks local variables
-	// should override, outer block variables still valid afetr inner block is declared
-    @Test public void testCreateUpdateProcedure9() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = var1 +1;\n";                 //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }    
-    
-	// special variable ROWS_UPDATED resolution
-    @Test public void testCreateUpdateProcedure10() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable ROWS_UPDATED used with declared variable
-    @Test public void testCreateUpdateProcedure11() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable INPUT used with declared variable
-    @Test public void testCreateUpdateProcedure12() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable CHANGING used with declared variable
-    @Test public void testCreateUpdateProcedure14() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(CHANGING.e1 = 'true')\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable CHANGING and INPUT used in compound criteria
-    @Test public void testCreateUpdateProcedure15() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(CHANGING.e1='false' and INPUT.e1=1)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable CHANGING and INPUT used in compound criteria, with declared variables
-    @Test public void testCreateUpdateProcedure16() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(CHANGING.e4 ='true' and INPUT.e2=1 or var1 < 30)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable CHANGING compared against integer no implicit conversion available
-    @Test public void testCreateUpdateProcedure17() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "if(CHANGING.e4 = {d'2000-01-01'})\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0027 Message:The expressions in this criteria are being compared but are of differing types (boolean and date) and no implicit conversion is available:  CHANGING.e4 = {d'2000-01-01'}"); //$NON-NLS-1$
-    }       
-    
-	// virtual group elements used in procedure(HAS CRITERIA)
-    @Test public void testCreateUpdateProcedure18() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// virtual group elements used in procedure in if statement(HAS CRITERIA)
-    @Test public void testCreateUpdateProcedure19() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1))\n";                 //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }    
-    
-	// virtual group elements used in procedure(TRANSLATE CRITERIA)
-    @Test public void testCreateUpdateProcedure20() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// virtual group elements used in procedure(TRANSLATE CRITERIA)
-    @Test public void testCreateUpdateProcedure21() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using undefined variable should fail
-    @Test public void testCreateUpdateProcedure22() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-//        procedure = procedure + "DECLARE integer var1;\n";
-        procedure = procedure + "var3 = var2+var1;\n";         //$NON-NLS-1$
-        procedure = procedure + "var2 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using undefined variable declared is of invalid datatype
-    @Test public void testCreateUpdateProcedure23() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE struct var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using declare variable that has parts
-    @Test public void testCreateUpdateProcedure24() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var2.var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using declare variable is qualified
-    @Test public void testCreateUpdateProcedure26() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer VARIABLES.var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using declare variable is qualified but has more parts
-    @Test public void testCreateUpdateProcedure27() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer VARIABLES.var1.var2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using a variable that has not been declared in an assignment stmt
-    @Test public void testCreateUpdateProcedure28() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using a variable that has not been declared in an assignment stmt
-    @Test public void testCreateUpdateProcedure29() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = 1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using invalid function in assignment expr
-    @Test public void testCreateUpdateProcedure30() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Declare integer var1;\n";         //$NON-NLS-1$
-        procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }    
-    
-	// using invalid function in assignment expr
-    @Test public void testCreateUpdateProcedure31() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Declare integer var1;\n";         //$NON-NLS-1$
-        procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using a variable being used inside a subcomand
-    @Test public void testCreateUpdateProcedure32() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select var1 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// variable resolution, variables declared in different blocks local variables
-	// should override, outer block variables still valid afetr inner block is declared
-	// fails as variable being compared against incorrect type
-    @Test public void testCreateUpdateProcedure33() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE timestamp var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = var1 +1;\n";                 //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// physical elements used on criteria of the if statement
-    @Test public void testCreateUpdateProcedure34() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol pm1.g1.e2 is specified with an unknown group context"); //$NON-NLS-1$
-    }
-    
-	// virtual elements used on criteria of the if statement
-    @Test public void testCreateUpdateProcedure35() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1) and var1=1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// physical elements used on criteria of the if statement
-    @Test public void testCreateUpdateProcedure36() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }          
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure37() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(TRANSLATE CRITERIA ON (vm1.g1.e1) WITH (vm1.g1.e1 = 1))\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// validating Translate CRITERIA, elements on it should be virtual group elements
-	// but can use variables
-    @Test public void testCreateUpdateProcedure38() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (pm1.g1.e2 = var1);\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// physical elements used on criteria of the if statement
-    @Test public void testCreateUpdateProcedure39() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure40() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1))\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure41() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure42() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure43() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n";         //$NON-NLS-1$
-//        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n";
-//        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n";
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);
-
-        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
-		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
-		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
-		Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
-        QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
-    }
-    
-	// special variable CHANGING compared against integer no implicit conversion available
-    @Test public void testCreateUpdateProcedure44() throws Exception {
-        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "if(INPUT.e1 = 10)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.INSERT_PROCEDURE);
-    }
-    
-	// special variable CHANGING compared against integer no implicit conversion available
-    @Test public void testCreateUpdateProcedure45() throws Exception {
-        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "if(INPUT.e1 = 10)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.INSERT_PROCEDURE, procedure);        
-        
-		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
-		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
-		
-    	Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
-        QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
-    }
-    
-	// special variable CHANGING compared against integer no implicit conversion available
-    @Test public void testCreateUpdateProcedure46() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);        
-        
-		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
-		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
-
-		Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
-        QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
-    }
-
-	// TranslateCriteria on criteria of the if statement
-	@Test public void testCreateUpdateProcedure47() throws Exception {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (vm1.g1.e1 = pm1.g1.e1);\n"; //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// validating Translate CRITERIA, elements(left elements on  on it should be virtual group elements
-	@Test public void testCreateUpdateProcedure48() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, INPUT.e2 = 2);\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving Translate CRITERIA, right element should be present on the command
-	@Test public void testCreateUpdateProcedure49() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = pm1.g2.e1);\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving criteria selector(on HAS CRITERIA), elements on it should be virtual group elements
-	@Test public void testCreateUpdateProcedure50() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.E1, vm1.g1.e1, INPUT.e1))\n";                 //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving Translate CRITERIA, right side expression in the translate criteria should be elements on the command
-	@Test public void testCreateUpdateProcedure51() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "var1=1;\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e2 = var1+vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// validating Translate CRITERIA, elements on it should be virtual group elements
-	// but can use variables, gut left exprs should always be virtual elements
-	@Test public void testCreateUpdateProcedure52() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (var1 = vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving AssignmentStatement, variable type and assigned type 
-	// do not match and no implicit conversion available
-	@Test public void testCreateUpdateProcedure53() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "var1 = INPUT.e4;"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving AssignmentStatement, variable type and assigned type 
-	// do not match, but implicit conversion available
-	@Test public void testCreateUpdateProcedure54() throws Exception {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "var1 = 1+1;"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-    
-	// resolving AssignmentStatement, variable type and assigned type 
-	// do not match, but implicit conversion available
-	@Test public void testCreateUpdateProcedure55() throws Exception {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}	
-
-    // no user command provided - should throw resolver exception
-    @Test public void testCreateUpdateProcedure56() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        TestResolver.helpResolveException(procedure, FakeMetadataFactory.example1Cached(), "Error Code:ERR.015.008.0012 Message:Unable to resolve update procedure as the virtual group context is ambiguous."); //$NON-NLS-1$
-    }
-    
-    @Test public void testDefect14912_CreateUpdateProcedure57_FunctionWithElementParamInAssignmentStatement() {
-        // Tests that the function params are resolved before the function for assignment statements
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = badFunction(badElement);"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"badElement\" is not defined by any relevant group."); //$NON-NLS-1$
-    }
-    
-	// addresses Cases 4624.  Before change to UpdateProcedureResolver,
-    // this case failed with assertion exception.
-    @Test public void testCase4624() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "VARIABLES.ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = {b'false'};\n"; //$NON-NLS-1$
-        procedure = procedure + "IF(var1 = {b 'true'})\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "SELECT Rack_ID, RACK_MDT_TYPE INTO #racks FROM Bert_MAP.BERT3.RACK;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: Bert_MAP.BERT3.RACK"); //$NON-NLS-1$
-    }
-
-	// addresses Cases 5474.  
-    @Test public void testCase5474() throws Exception {
-        String procedure = "CREATE VIRTUAL PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer VARIABLES.NLEVELS;\n"; //$NON-NLS-1$
-        procedure = procedure + "VARIABLES.NLEVELS = SELECT COUNT(*) FROM (SELECT oi.e1 AS Col1, oi.e2 AS Col2, oi.e3 FROM pm1.g2 AS oi) AS TOBJ, pm2.g2 AS TModel WHERE TModel.e3 = TOBJ.e3;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
-    }
-    
-    @Test public void testIssue174102() throws Exception {
-        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE string crit = 'WHERE pm1.sq2.in = \"test\"';\n"; //$NON-NLS-1$
-        procedure = procedure + "CREATE LOCAL TEMPORARY TABLE #TTable (e1 string);"; //$NON-NLS-1$
-        procedure = procedure + "EXECUTE STRING ('SELECT e1 FROM pm1.sq2 ' || crit ) AS e1 string INTO #TTable;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
-    }
-    
-    // Address Issue 174519.
-    // Expected result is resolver failure, but with different error.
-    @Test public void testIssue174519() throws Exception {
-        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE string VARIABLES.l_in = pm1.sq1.in;\n"; //$NON-NLS-1$
-        procedure = procedure + "INSERT INTO #temp \n"; //$NON-NLS-1$
-        procedure = procedure + "SELECT pm1.sq3.e1 FROM pm1.sq3 WHERE pm1.sq3.in = VARIABLES.l_in;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
-        helpResolveException("EXEC pm1.sq1(1)", metadata, "Error Code:ERR.015.008.0010 Message:INSERT statement must have the same number of elements and values specified.  This statement has 0 elements and 0 values."); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-	/*@Test public void testCommandUpdatingCountFromLastStatement() throws Exception {
-        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "declare integer x = convert(pm1.sq1.in, integer) + 5;\n"; //$NON-NLS-1$
-        procedure = procedure + "insert into pm1.g1 values (null, null, null, null);"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
-        Command command = helpResolve(helpParse("exec pm1.sq1(1)"), metadata, null); //$NON-NLS-1$
-        
-        assertEquals(1, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
-	}*/
-
-    //baseline test to ensure that a declare assignment cannot contain the declared variable
-    @Test public void testDeclareStatement() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer VARIABLES.var1 = VARIABLES.var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    @Test public void testDynamicIntoInProc() throws Exception {
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2' as e1 string, e2 string, e3 string, e4 string INTO #myTempTable;\n") //$NON-NLS-1$
-                                .append("select e1 from #myTempTable;\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    @Test public void testDynamicStatement() throws Exception {
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2';\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    @Test public void testDynamicStatementType() {
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("DECLARE object VARIABLES.X = null;\n") //$NON-NLS-1$
-                                .append("execute string VARIABLES.X;\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpFailUpdateProcedure(procedure.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-
-	// variable resolution
-    @Test public void testCreateUpdateProcedure1() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// variable resolution, variable used in if statement
-    @Test public void testCreateUpdateProcedure3() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-
-    @Test public void testSelectIntoInProc() throws Exception {
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                            .append("BEGIN\n") //$NON-NLS-1$
-                                            .append("SELECT e1, e2, e3, e4 INTO pm1.g1 FROM pm1.g2;\n") //$NON-NLS-1$
-                                            .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                            .append("END\n"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
-        
-        procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g2;\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-
-    @Test public void testSelectIntoInProcNoFrom() throws Exception {
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                            .append("BEGIN\n") //$NON-NLS-1$
-                                            .append("SELECT 'a', 19, {b'true'}, 13.999 INTO pm1.g1;\n") //$NON-NLS-1$
-                                            .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                            .append("END\n"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
-        
-        procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("SELECT 'a', 19, {b'true'}, 13.999 INTO #myTempTable;\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    /*@Test public void testCommandUpdating3() throws Exception{
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-        .append("BEGIN\n") //$NON-NLS-1$
-        .append("INSERT INTO pm1.g1 (e1) VALUES (input.e1);\n") //$NON-NLS-1$
-        .append("ROWS_UPDATED = INSERT INTO pm1.g2 (e1) VALUES (input.e1);\n") //$NON-NLS-1$
-        .append("END\n"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        Command command = helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-        assertEquals(2, command.updatingModelCount(metadata));
-    }*/
-
-    /*@Test public void testCommandUpdatingCount6() throws Exception{
-        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "if(INPUT.e1 = 10)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "INSERT INTO pm1.g1 (e2) VALUES (Input.e2);\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
-        
-        Command command = helpResolveUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.INSERT_PROCEDURE);
-        assertEquals(2, command.updatingModelCount(metadata));
-    }*/
-    
-    // variable declared is of special type ROWS_RETURNED
-    @Test public void testDeclareRowsUpdated() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer rows_updated;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable rows_updated was previously declared."); //$NON-NLS-1$
-    }
-    
-    // validating INPUT element assigned
-    @Test public void testAssignInput() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "INPUT.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"INPUT.e1\" cannot be assigned a value.  Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
-    }
-    
-    // validating CHANGING element assigned
-    @Test public void testAssignChanging() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "CHANGING.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"CHANGING.e1\" cannot be assigned a value.  Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
-    }
-    
-    // variables cannot be used among insert elements
-    @Test public void testVariableInInsert() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, var1) values (1, 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userQuery, 
-                FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'var1': Element \"var1\" is not defined by any relevant group.]"); //$NON-NLS-1$
-    }
-    
-    // variables cannot be used among insert elements
-    @Test public void testVariableInInsert2() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, INPUT.x) values (1, 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userQuery, 
-                FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'INPUT.x': Symbol INPUT.x is specified with an unknown group context]"); //$NON-NLS-1$
-    }
-    
-    //should resolve first to the table's column
-    @Test public void testVariableInInsert3() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "Insert into pm1.g1 (e2) values (1);\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
-
-        helpResolveUpdateProcedure(procedure, userQuery, 
-                FakeMetadataObject.Props.UPDATE_PROCEDURE); 
-    }
-    
-    @Test public void testAmbigousInput() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "select e1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"e1\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
-    }
-    
-    @Test public void testLoopRedefinition() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  declare string var1;") //$NON-NLS-1$
-        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
-        .append("\n  BEGIN") //$NON-NLS-1$
-        .append("\n    LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor") //$NON-NLS-1$
-        .append("\n    BEGIN") //$NON-NLS-1$
-        .append("\n      var1 = CONCAT(var1, CONCAT(' ', loopCursor.e1));") //$NON-NLS-1$
-        .append("\n    END") //$NON-NLS-1$
-        .append("\n  END") //$NON-NLS-1$
-        .append("\n  END"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$
-    }
-    
-    @Test public void testTempGroupElementShouldNotBeResolable() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  select 1 as a into #temp;") //$NON-NLS-1$
-        .append("\n  select #temp.a from pm1.g1;") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
-    }
-    
-    @Test public void testTempGroupElementShouldNotBeResolable1() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  select 1 as a into #temp;") //$NON-NLS-1$
-        .append("\n  insert into #temp (a) values (#temp.a);") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
-    }
-    
-    @Test public void testProcedureCreate() throws Exception {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
-        .append("\n  select e1 from t1;") //$NON-NLS-1$
-        .append("\n  create local temporary table t1 (e1 string, e2 integer);") //$NON-NLS-1$
-        .append("\n  select e2 from t1;") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
-    }
-    
-    /**
-     * it is not ok to redefine the loopCursor 
-     */
-    @Test public void testProcedureCreate1() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
-        .append("\n  BEGIN") //$NON-NLS-1$
-        .append("\n  create local temporary table loopCursor (e1 string);") //$NON-NLS-1$
-        .append("\nEND") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Cannot create temporary table \"loopCursor\". A table with the same name already exists."); //$NON-NLS-1$
-    }
-    
-    @Test public void testProcedureCreateDrop() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n drop table t1;") //$NON-NLS-1$
-        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: t1"); //$NON-NLS-1$
-    }
-    
-    @Test public void testProcedureCreateDrop1() throws Exception {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
-        .append("\n  drop table t1;") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    @Test public void testCreateAfterImplicitTempTable() throws Exception {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  select e1 into #temp from pm1.g1;") //$NON-NLS-1$
-        .append("\n  create local temporary table #temp (e1 string);") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
-    }
-    
-    @Test public void testInsertAfterCreate() throws Exception {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  create local temporary table #temp (e1 string, e2 string);") //$NON-NLS-1$
-        .append("\n  insert into #temp (e1) values ('a');") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
-    }
-    
-	/**
-	 * delete procedures should not reference input or changing vars.
-	 */
-	@Test public void testDefect16451() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure += "BEGIN\n"; //$NON-NLS-1$
-        procedure += "Select pm1.g1.e2 from pm1.g1 where e1 = input.e1;\n"; //$NON-NLS-1$
-        procedure += "ROWS_UPDATED = 0;"; //$NON-NLS-1$
-        procedure += "END\n"; //$NON-NLS-1$
-        
-        String userUpdateStr = "delete from vm1.g1 where e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.DELETE_PROCEDURE, "Symbol input.e1 is specified with an unknown group context"); //$NON-NLS-1$
-	}
-	
-    @Test public void testInvalidVirtualProcedure3() throws Exception {
-    	helpResolveException("EXEC pm1.vsp18()", FakeMetadataFactory.example1Cached(), "Group does not exist: temptable"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    // variable resolution, variable compared against
-    // different datatype element for which there is no implicit transformation)
-    @Test public void testCreateUpdateProcedure2() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure += "BEGIN\n"; //$NON-NLS-1$
-        procedure += "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e4 = convert(var1, string), pm1.g1.e1 = var1;\n"; //$NON-NLS-1$
-        procedure += "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-				 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e4' with expected type double to expression 'convert(var1, string)'"); //$NON-NLS-1$
-    }
-    
-    // special variable INPUT compared against invalid type
-    @Test public void testInvalidInputInUpdate() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure += "BEGIN\n"; //$NON-NLS-1$
-        procedure += "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure += "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e1;\n"; //$NON-NLS-1$
-        procedure += "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-				 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e2' with expected type integer to expression 'INPUT.e1'"); //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedure() throws Exception {
-        helpResolve("EXEC pm1.vsp1()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedure2() throws Exception {
-        helpResolve("EXEC pm1.vsp14()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedurePartialParameterReference() throws Exception {
-        helpResolve("EXEC pm1.vsp58(5)", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
-    }
-    
-    //cursor starts with "#" Defect14924
-    @Test public void testVirtualProcedureInvalid1() throws Exception {
-    	helpResolveException("EXEC pm1.vsp32()",FakeMetadataFactory.example1Cached(), "Cursor names cannot begin with \"#\" as that indicates the name of a temporary table: #mycursor.");   //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    @Test public void testVirtualProcedureWithOrderBy() throws Exception {
-        helpResolve("EXEC pm1.vsp29()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedureWithTempTableAndOrderBy() throws Exception {
-        helpResolve("EXEC pm1.vsp33()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedureWithConstAndOrderBy() throws Exception {
-        helpResolve("EXEC pm1.vsp34()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedureWithNoFromAndOrderBy() throws Exception {
-        helpResolve("EXEC pm1.vsp28()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
-    }
-    
-    @Test public void testInvalidVirtualProcedure2() throws Exception {
-        helpResolveException("EXEC pm1.vsp12()", FakeMetadataFactory.example1Cached(), "Symbol mycursor.e2 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    @Test public void testLoopRedefinition2() throws Exception {
-        helpResolveException("EXEC pm1.vsp11()", FakeMetadataFactory.example1Cached(), "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-        
-    @Test public void testVariableResolutionWithIntervening() throws Exception {
-        StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  declare string x;") //$NON-NLS-1$
-        .append("\n  x = '1';") //$NON-NLS-1$
-        .append("\n  declare string y;") //$NON-NLS-1$
-        .append("\n  y = '1';") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        TestResolver.helpResolve(proc.toString(), FakeMetadataFactory.example1Cached(), null); 
-    }
-    
-}

Copied: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java	                        (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,1620 @@
+/*
+ * 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 static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+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.dqp.message.ParameterInfo;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.mapping.relational.QueryNode;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+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.Insert;
+import com.metamatrix.query.sql.lang.ProcedureContainer;
+import com.metamatrix.query.sql.proc.AssignmentStatement;
+import com.metamatrix.query.sql.proc.Block;
+import com.metamatrix.query.sql.proc.CommandStatement;
+import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
+import com.metamatrix.query.sql.proc.LoopStatement;
+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.visitor.ElementCollectorVisitor;
+import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.unittest.FakeMetadataObject;
+
+public class TestProcedureResolving {
+
+ 	private QueryMetadataInterface exampleStoredProcedure(String procedure) {
+		FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+        
+        FakeMetadataObject pm1 = metadata.getStore().findObject("pm1",FakeMetadataObject.MODEL); //$NON-NLS-1$
+        FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("pm1.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+        FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2);  //$NON-NLS-1$
+        FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null);  //$NON-NLS-1$
+        QueryNode sq2n1 = new QueryNode("pm1.sq1", procedure); //$NON-NLS-1$ 
+        FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("pm1.sq1", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1);  //$NON-NLS-1$
+
+        metadata.getStore().addObject(rs2);
+        metadata.getStore().addObject(sq1);
+        
+        return metadata;
+	}
+ 	
+    private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType) {
+        helpFailUpdateProcedure(procedure, userUpdateStr, procedureType, null);
+    }
+    
+	private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType, String msg) {
+        // resolve
+        try {
+    		helpResolveUpdateProcedure(procedure, userUpdateStr, procedureType);
+            fail("Expected a QueryResolverException but got none."); //$NON-NLS-1$
+        } catch(QueryResolverException ex) {
+        	if (msg != null) {
+                assertEquals(msg, ex.getMessage());
+            }
+        } catch (MetaMatrixComponentException e) {
+        	throw new RuntimeException(e);
+		} catch (QueryParserException e) {
+			throw new RuntimeException(e);
+		} 
+	}	
+	
+    public static Map getProcedureExternalMetadata(GroupSymbol virtualGroup, QueryMetadataInterface metadata)
+    throws QueryMetadataException, MetaMatrixComponentException {
+        Map externalMetadata = new HashMap();
+        
+        //TODO: it doesn't seem like these should be in the 
+        List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(virtualGroup, metadata);
+        externalMetadata.put(virtualGroup, elements);
+        
+        TempMetadataStore tms = new TempMetadataStore();
+
+        TempMetadataAdapter tma = new TempMetadataAdapter(metadata, tms);
+        
+        GroupContext gc = ProcedureContainerResolver.createChildMetadata(tms, metadata, virtualGroup);
+        
+        for (GroupSymbol symbol : gc.getAllGroups()) {
+        	externalMetadata.put(symbol, ResolverUtil.resolveElementsInGroup(symbol, tma));
+        }
+        
+        return externalMetadata;
+    }
+	
+    @Test public void testDefect13029_CorrectlySetUpdateProcedureTempGroupIDs() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
+            .append("\nBEGIN") //$NON-NLS-1$
+            .append("\nDECLARE string var1;") //$NON-NLS-1$
+            .append("\nvar1 = '';") //$NON-NLS-1$
+            .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+            .append("\n  BEGIN") //$NON-NLS-1$
+            .append("\n    LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor2") //$NON-NLS-1$
+            .append("\n    BEGIN") //$NON-NLS-1$
+            .append("\n      var1 = CONCAT(var1, CONCAT(' ', loopCursor2.e1));") //$NON-NLS-1$
+            .append("\n    END") //$NON-NLS-1$
+            .append("\n  END") //$NON-NLS-1$
+            .append("\nEND"); //$NON-NLS-1$
+            
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        Command command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        Map tempIDs = command.getTemporaryMetadata();
+        assertNotNull(tempIDs);
+        assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
+        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
+        
+        Command subCommand = command.getSubCommands().get(0);
+        tempIDs = subCommand.getTemporaryMetadata();
+        assertNotNull(tempIDs);
+        assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
+        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
+
+        subCommand = command.getSubCommands().get(1);
+        tempIDs = subCommand.getTemporaryMetadata();
+        assertNotNull(tempIDs);
+        assertNotNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
+        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
+    }
+    
+	private CreateUpdateProcedureCommand helpResolveUpdateProcedure(String procedure, String userUpdateStr, String procedureType) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
+		return resolveProcedure(userUpdateStr, metadata);
+	}
+
+	private CreateUpdateProcedureCommand resolveProcedure(String userUpdateStr,
+			QueryMetadataInterface metadata) throws QueryParserException,
+			QueryResolverException, MetaMatrixComponentException,
+			QueryMetadataException {
+		ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr); 
+        QueryResolver.resolveCommand(userCommand, metadata);
+        metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(userCommand.getTemporaryMetadata()));
+        return (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, null);
+	}
+
+	private void helpResolveException(String userUpdateStr, QueryMetadataInterface metadata, String msg) throws QueryParserException, MetaMatrixComponentException {
+		try {
+			helpResolve(userUpdateStr, metadata);
+		} catch (QueryResolverException e) {
+			assertEquals(msg, e.getMessage());
+		}
+	}
+
+	private CreateUpdateProcedureCommand helpResolve(String userUpdateStr, QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+		return resolveProcedure(userUpdateStr, metadata);
+	}
+    
+    /**
+     *  Constants will now auto resolve if they are consistently representable in the target type
+     */
+    @Test public void testDefect23257() throws Exception{
+    	CreateUpdateProcedureCommand command = helpResolve("EXEC pm5.vsp59()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+        
+        CommandStatement cs = (CommandStatement)command.getBlock().getStatements().get(1);
+        
+        Insert insert = (Insert)cs.getCommand();
+        
+        assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression)insert.getValues().get(1)).getType());
+    } 
+    
+    @Test public void testProcedureScoping() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        //note that this declare takes presedense over the proc INPUTS.e1 and CHANGING.e1 variables
+        .append("\n  declare integer e1 = 1;") //$NON-NLS-1$
+        .append("\n  e1 = e1;") //$NON-NLS-1$
+        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+        .append("\n  BEGIN") //$NON-NLS-1$
+        //inside the scope of the loop, an unqualified e1 should resolve to the loop variable group
+        .append("\n    variables.e1 = convert(e1, integer);") //$NON-NLS-1$
+        .append("\n  END") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        CreateUpdateProcedureCommand command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        
+        Block block = command.getBlock();
+        
+        AssignmentStatement assStmt = (AssignmentStatement)block.getStatements().get(1);
+        assertEquals(ProcedureReservedWords.VARIABLES, assStmt.getVariable().getGroupSymbol().getCanonicalName());
+        assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)assStmt.getValue()).getGroupSymbol().getCanonicalName());
+        
+        Block inner = ((LoopStatement)block.getStatements().get(2)).getBlock();
+        
+        assStmt = (AssignmentStatement)inner.getStatements().get(0);
+        
+        ElementSymbol value = ElementCollectorVisitor.getElements(assStmt.getValue(), false).iterator().next();
+        
+        assertEquals("LOOPCURSOR", value.getGroupSymbol().getCanonicalName()); //$NON-NLS-1$
+    }
+    
+	// variable resolution, variable used in if statement, variable compared against
+	// different datatype element
+    @Test public void testCreateUpdateProcedure4() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1);\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// variable resolution, variable used in if statement, invalid operation on variable
+    @Test public void testCreateUpdateProcedure5() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = var1 + var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 whwre var1 = var1+var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }    
+    
+	// variable resolution, variables declared in different blocks local variables
+	// should not override
+    @Test public void testCreateUpdateProcedure6() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable var1 was previously declared."); //$NON-NLS-1$
+    }
+    
+	// variable resolution, variables declared in different blocks local variables
+	// inner block using outer block variables
+    @Test public void testCreateUpdateProcedure7() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var2;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// variable resolution, variables declared in different blocks local variables
+	// outer block cannot use inner block variables
+    @Test public void testCreateUpdateProcedure8() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var2;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+        procedure = procedure + "var2 = 1\n";                 //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }     
+    
+	// variable resolution, variables declared in different blocks local variables
+	// should override, outer block variables still valid afetr inner block is declared
+    @Test public void testCreateUpdateProcedure9() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = var1 +1;\n";                 //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }    
+    
+	// special variable ROWS_UPDATED resolution
+    @Test public void testCreateUpdateProcedure10() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable ROWS_UPDATED used with declared variable
+    @Test public void testCreateUpdateProcedure11() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable INPUT used with declared variable
+    @Test public void testCreateUpdateProcedure12() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable CHANGING used with declared variable
+    @Test public void testCreateUpdateProcedure14() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(CHANGING.e1 = 'true')\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable CHANGING and INPUT used in compound criteria
+    @Test public void testCreateUpdateProcedure15() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(CHANGING.e1='false' and INPUTS.e1=1)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable CHANGING and INPUT used in compound criteria, with declared variables
+    @Test public void testCreateUpdateProcedure16() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(CHANGING.e4 ='true' and INPUTS.e2=1 or var1 < 30)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable CHANGING compared against integer no implicit conversion available
+    @Test public void testCreateUpdateProcedure17() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "if(CHANGING.e4 = {d'2000-01-01'})\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0027 Message:The expressions in this criteria are being compared but are of differing types (boolean and date) and no implicit conversion is available:  CHANGING.e4 = {d'2000-01-01'}"); //$NON-NLS-1$
+    }       
+    
+	// virtual group elements used in procedure(HAS CRITERIA)
+    @Test public void testCreateUpdateProcedure18() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// virtual group elements used in procedure in if statement(HAS CRITERIA)
+    @Test public void testCreateUpdateProcedure19() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1))\n";                 //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }    
+    
+	// virtual group elements used in procedure(TRANSLATE CRITERIA)
+    @Test public void testCreateUpdateProcedure20() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// virtual group elements used in procedure(TRANSLATE CRITERIA)
+    @Test public void testCreateUpdateProcedure21() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using undefined variable should fail
+    @Test public void testCreateUpdateProcedure22() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+//        procedure = procedure + "DECLARE integer var1;\n";
+        procedure = procedure + "var3 = var2+var1;\n";         //$NON-NLS-1$
+        procedure = procedure + "var2 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using undefined variable declared is of invalid datatype
+    @Test public void testCreateUpdateProcedure23() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE struct var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUTS.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using declare variable that has parts
+    @Test public void testCreateUpdateProcedure24() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var2.var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using declare variable is qualified
+    @Test public void testCreateUpdateProcedure26() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer VARIABLES.var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using declare variable is qualified but has more parts
+    @Test public void testCreateUpdateProcedure27() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer VARIABLES.var1.var2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using a variable that has not been declared in an assignment stmt
+    @Test public void testCreateUpdateProcedure28() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using a variable that has not been declared in an assignment stmt
+    @Test public void testCreateUpdateProcedure29() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = 1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using invalid function in assignment expr
+    @Test public void testCreateUpdateProcedure30() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Declare integer var1;\n";         //$NON-NLS-1$
+        procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }    
+    
+	// using invalid function in assignment expr
+    @Test public void testCreateUpdateProcedure31() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Declare integer var1;\n";         //$NON-NLS-1$
+        procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using a variable being used inside a subcomand
+    @Test public void testCreateUpdateProcedure32() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select var1 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// variable resolution, variables declared in different blocks local variables
+	// should override, outer block variables still valid afetr inner block is declared
+	// fails as variable being compared against incorrect type
+    @Test public void testCreateUpdateProcedure33() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE timestamp var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = var1 +1;\n";                 //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// physical elements used on criteria of the if statement
+    @Test public void testCreateUpdateProcedure34() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol pm1.g1.e2 is specified with an unknown group context"); //$NON-NLS-1$
+    }
+    
+	// virtual elements used on criteria of the if statement
+    @Test public void testCreateUpdateProcedure35() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1) and var1=1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// physical elements used on criteria of the if statement
+    @Test public void testCreateUpdateProcedure36() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }          
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure37() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(TRANSLATE CRITERIA ON (vm1.g1.e1) WITH (vm1.g1.e1 = 1))\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// validating Translate CRITERIA, elements on it should be virtual group elements
+	// but can use variables
+    @Test public void testCreateUpdateProcedure38() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (pm1.g1.e2 = var1);\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// physical elements used on criteria of the if statement
+    @Test public void testCreateUpdateProcedure39() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure40() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1))\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure41() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure42() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure43() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n";         //$NON-NLS-1$
+//        procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n";
+//        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e2;\n";
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);
+
+        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
+		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
+		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
+		Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
+        QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
+    }
+    
+	// special variable CHANGING compared against integer no implicit conversion available
+    @Test public void testCreateUpdateProcedure44() throws Exception {
+        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "if(INPUTS.e1 = 10)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.INSERT_PROCEDURE);
+    }
+    
+	// special variable CHANGING compared against integer no implicit conversion available
+    @Test public void testCreateUpdateProcedure45() throws Exception {
+        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "if(INPUTS.e1 = 10)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.INSERT_PROCEDURE, procedure);        
+        
+		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
+		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
+		
+    	Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
+        QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
+    }
+    
+	// special variable CHANGING compared against integer no implicit conversion available
+    @Test public void testCreateUpdateProcedure46() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);        
+        
+		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
+		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
+
+		Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
+        QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
+    }
+
+	// TranslateCriteria on criteria of the if statement
+	@Test public void testCreateUpdateProcedure47() throws Exception {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (vm1.g1.e1 = pm1.g1.e1);\n"; //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// validating Translate CRITERIA, elements(left elements on  on it should be virtual group elements
+	@Test public void testCreateUpdateProcedure48() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, INPUTS.e2 = 2);\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving Translate CRITERIA, right element should be present on the command
+	@Test public void testCreateUpdateProcedure49() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = pm1.g2.e1);\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving criteria selector(on HAS CRITERIA), elements on it should be virtual group elements
+	@Test public void testCreateUpdateProcedure50() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.E1, vm1.g1.e1, INPUTS.e1))\n";                 //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving Translate CRITERIA, right side expression in the translate criteria should be elements on the command
+	@Test public void testCreateUpdateProcedure51() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "var1=1;\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e2 = var1+vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// validating Translate CRITERIA, elements on it should be virtual group elements
+	// but can use variables, gut left exprs should always be virtual elements
+	@Test public void testCreateUpdateProcedure52() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (var1 = vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving AssignmentStatement, variable type and assigned type 
+	// do not match and no implicit conversion available
+	@Test public void testCreateUpdateProcedure53() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "var1 = INPUTS.e4;"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving AssignmentStatement, variable type and assigned type 
+	// do not match, but implicit conversion available
+	@Test public void testCreateUpdateProcedure54() throws Exception {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "var1 = 1+1;"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+    
+	// resolving AssignmentStatement, variable type and assigned type 
+	// do not match, but implicit conversion available
+	@Test public void testCreateUpdateProcedure55() throws Exception {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}	
+
+    // no user command provided - should throw resolver exception
+    @Test public void testCreateUpdateProcedure56() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        TestResolver.helpResolveException(procedure, FakeMetadataFactory.example1Cached(), "Error Code:ERR.015.008.0012 Message:Unable to resolve update procedure as the virtual group context is ambiguous."); //$NON-NLS-1$
+    }
+    
+    @Test public void testDefect14912_CreateUpdateProcedure57_FunctionWithElementParamInAssignmentStatement() {
+        // Tests that the function params are resolved before the function for assignment statements
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = badFunction(badElement);"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"badElement\" is not defined by any relevant group."); //$NON-NLS-1$
+    }
+    
+	// addresses Cases 4624.  Before change to UpdateProcedureResolver,
+    // this case failed with assertion exception.
+    @Test public void testCase4624() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "VARIABLES.ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = {b'false'};\n"; //$NON-NLS-1$
+        procedure = procedure + "IF(var1 = {b 'true'})\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "SELECT Rack_ID, RACK_MDT_TYPE INTO #racks FROM Bert_MAP.BERT3.RACK;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: Bert_MAP.BERT3.RACK"); //$NON-NLS-1$
+    }
+
+	// addresses Cases 5474.  
+    @Test public void testCase5474() throws Exception {
+        String procedure = "CREATE VIRTUAL PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer VARIABLES.NLEVELS;\n"; //$NON-NLS-1$
+        procedure = procedure + "VARIABLES.NLEVELS = SELECT COUNT(*) FROM (SELECT oi.e1 AS Col1, oi.e2 AS Col2, oi.e3 FROM pm1.g2 AS oi) AS TOBJ, pm2.g2 AS TModel WHERE TModel.e3 = TOBJ.e3;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
+    }
+    
+    @Test public void testIssue174102() throws Exception {
+        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE string crit = 'WHERE pm1.sq2.in = \"test\"';\n"; //$NON-NLS-1$
+        procedure = procedure + "CREATE LOCAL TEMPORARY TABLE #TTable (e1 string);"; //$NON-NLS-1$
+        procedure = procedure + "EXECUTE STRING ('SELECT e1 FROM pm1.sq2 ' || crit ) AS e1 string INTO #TTable;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
+    }
+    
+    // Address Issue 174519.
+    // Expected result is resolver failure, but with different error.
+    @Test public void testIssue174519() throws Exception {
+        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE string VARIABLES.l_in = pm1.sq1.in;\n"; //$NON-NLS-1$
+        procedure = procedure + "INSERT INTO #temp \n"; //$NON-NLS-1$
+        procedure = procedure + "SELECT pm1.sq3.e1 FROM pm1.sq3 WHERE pm1.sq3.in = VARIABLES.l_in;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
+        helpResolveException("EXEC pm1.sq1(1)", metadata, "Error Code:ERR.015.008.0010 Message:INSERT statement must have the same number of elements and values specified.  This statement has 0 elements and 0 values."); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+    
+	/*@Test public void testCommandUpdatingCountFromLastStatement() throws Exception {
+        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "declare integer x = convert(pm1.sq1.in, integer) + 5;\n"; //$NON-NLS-1$
+        procedure = procedure + "insert into pm1.g1 values (null, null, null, null);"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
+        Command command = helpResolve(helpParse("exec pm1.sq1(1)"), metadata, null); //$NON-NLS-1$
+        
+        assertEquals(1, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
+	}*/
+
+    //baseline test to ensure that a declare assignment cannot contain the declared variable
+    @Test public void testDeclareStatement() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer VARIABLES.var1 = VARIABLES.var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    @Test public void testDynamicIntoInProc() throws Exception {
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2' as e1 string, e2 string, e3 string, e4 string INTO #myTempTable;\n") //$NON-NLS-1$
+                                .append("select e1 from #myTempTable;\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    @Test public void testDynamicStatement() throws Exception {
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2';\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    @Test public void testDynamicStatementType() {
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("DECLARE object VARIABLES.X = null;\n") //$NON-NLS-1$
+                                .append("execute string VARIABLES.X;\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpFailUpdateProcedure(procedure.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+
+	// variable resolution
+    @Test public void testCreateUpdateProcedure1() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// variable resolution, variable used in if statement
+    @Test public void testCreateUpdateProcedure3() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+
+    @Test public void testSelectIntoInProc() throws Exception {
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                            .append("BEGIN\n") //$NON-NLS-1$
+                                            .append("SELECT e1, e2, e3, e4 INTO pm1.g1 FROM pm1.g2;\n") //$NON-NLS-1$
+                                            .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                            .append("END\n"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        
+        procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g2;\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+
+    @Test public void testSelectIntoInProcNoFrom() throws Exception {
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                            .append("BEGIN\n") //$NON-NLS-1$
+                                            .append("SELECT 'a', 19, {b'true'}, 13.999 INTO pm1.g1;\n") //$NON-NLS-1$
+                                            .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                            .append("END\n"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        
+        procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("SELECT 'a', 19, {b'true'}, 13.999 INTO #myTempTable;\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    /*@Test public void testCommandUpdating3() throws Exception{
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+        .append("BEGIN\n") //$NON-NLS-1$
+        .append("INSERT INTO pm1.g1 (e1) VALUES (INPUTS.e1);\n") //$NON-NLS-1$
+        .append("ROWS_UPDATED = INSERT INTO pm1.g2 (e1) VALUES (INPUTS.e1);\n") //$NON-NLS-1$
+        .append("END\n"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        Command command = helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        assertEquals(2, command.updatingModelCount(metadata));
+    }*/
+
+    /*@Test public void testCommandUpdatingCount6() throws Exception{
+        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "if(INPUTS.e1 = 10)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "INSERT INTO pm1.g1 (e2) VALUES (INPUTS.e2);\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
+        
+        Command command = helpResolveUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.INSERT_PROCEDURE);
+        assertEquals(2, command.updatingModelCount(metadata));
+    }*/
+    
+    // variable declared is of special type ROWS_RETURNED
+    @Test public void testDeclareRowsUpdated() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer rows_updated;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable rows_updated was previously declared."); //$NON-NLS-1$
+    }
+    
+    // validating INPUT element assigned
+    @Test public void testAssignInput() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "INPUTS.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"INPUTS.e1\" cannot be assigned a value.  Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
+    }
+    
+    // validating CHANGING element assigned
+    @Test public void testAssignChanging() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "CHANGING.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"CHANGING.e1\" cannot be assigned a value.  Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
+    }
+    
+    // variables cannot be used among insert elements
+    @Test public void testVariableInInsert() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, var1) values (1, 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userQuery, 
+                FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'var1': Element \"var1\" is not defined by any relevant group.]"); //$NON-NLS-1$
+    }
+    
+    // variables cannot be used among insert elements
+    @Test public void testVariableInInsert2() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, INPUTS.x) values (1, 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userQuery, 
+                FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'INPUTS.x': Symbol INPUTS.x is specified with an unknown group context]"); //$NON-NLS-1$
+    }
+    
+    //should resolve first to the table's column
+    @Test public void testVariableInInsert3() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "Insert into pm1.g1 (e2) values (1);\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
+
+        helpResolveUpdateProcedure(procedure, userQuery, 
+                FakeMetadataObject.Props.UPDATE_PROCEDURE); 
+    }
+    
+    @Test public void testAmbigousInput() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "select e1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"e1\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
+    }
+    
+    @Test public void testLoopRedefinition() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  declare string var1;") //$NON-NLS-1$
+        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+        .append("\n  BEGIN") //$NON-NLS-1$
+        .append("\n    LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor") //$NON-NLS-1$
+        .append("\n    BEGIN") //$NON-NLS-1$
+        .append("\n      var1 = CONCAT(var1, CONCAT(' ', loopCursor.e1));") //$NON-NLS-1$
+        .append("\n    END") //$NON-NLS-1$
+        .append("\n  END") //$NON-NLS-1$
+        .append("\n  END"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$
+    }
+    
+    @Test public void testTempGroupElementShouldNotBeResolable() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  select 1 as a into #temp;") //$NON-NLS-1$
+        .append("\n  select #temp.a from pm1.g1;") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
+    }
+    
+    @Test public void testTempGroupElementShouldNotBeResolable1() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  select 1 as a into #temp;") //$NON-NLS-1$
+        .append("\n  insert into #temp (a) values (#temp.a);") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
+    }
+    
+    @Test public void testProcedureCreate() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
+        .append("\n  select e1 from t1;") //$NON-NLS-1$
+        .append("\n  create local temporary table t1 (e1 string, e2 integer);") //$NON-NLS-1$
+        .append("\n  select e2 from t1;") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
+    }
+    
+    /**
+     * it is not ok to redefine the loopCursor 
+     */
+    @Test public void testProcedureCreate1() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+        .append("\n  BEGIN") //$NON-NLS-1$
+        .append("\n  create local temporary table loopCursor (e1 string);") //$NON-NLS-1$
+        .append("\nEND") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Cannot create temporary table \"loopCursor\". A table with the same name already exists."); //$NON-NLS-1$
+    }
+    
+    @Test public void testProcedureCreateDrop() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n drop table t1;") //$NON-NLS-1$
+        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: t1"); //$NON-NLS-1$
+    }
+    
+    @Test public void testProcedureCreateDrop1() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
+        .append("\n  drop table t1;") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    @Test public void testCreateAfterImplicitTempTable() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  select e1 into #temp from pm1.g1;") //$NON-NLS-1$
+        .append("\n  create local temporary table #temp (e1 string);") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
+    }
+    
+    @Test public void testInsertAfterCreate() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  create local temporary table #temp (e1 string, e2 string);") //$NON-NLS-1$
+        .append("\n  insert into #temp (e1) values ('a');") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
+    }
+    
+	/**
+	 * delete procedures should not reference input or changing vars.
+	 */
+	@Test public void testDefect16451() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure += "BEGIN\n"; //$NON-NLS-1$
+        procedure += "Select pm1.g1.e2 from pm1.g1 where e1 = INPUTS.e1;\n"; //$NON-NLS-1$
+        procedure += "ROWS_UPDATED = 0;"; //$NON-NLS-1$
+        procedure += "END\n"; //$NON-NLS-1$
+        
+        String userUpdateStr = "delete from vm1.g1 where e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.DELETE_PROCEDURE, "Symbol INPUTS.e1 is specified with an unknown group context"); //$NON-NLS-1$
+	}
+	
+    @Test public void testInvalidVirtualProcedure3() throws Exception {
+    	helpResolveException("EXEC pm1.vsp18()", FakeMetadataFactory.example1Cached(), "Group does not exist: temptable"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+    
+    // variable resolution, variable compared against
+    // different datatype element for which there is no implicit transformation)
+    @Test public void testCreateUpdateProcedure2() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure += "BEGIN\n"; //$NON-NLS-1$
+        procedure += "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e4 = convert(var1, string), pm1.g1.e1 = var1;\n"; //$NON-NLS-1$
+        procedure += "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+				 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e4' with expected type double to expression 'convert(var1, string)'"); //$NON-NLS-1$
+    }
+    
+    // special variable INPUT compared against invalid type
+    @Test public void testInvalidInputInUpdate() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure += "BEGIN\n"; //$NON-NLS-1$
+        procedure += "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure += "Select pm1.g1.e2, INPUTS.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e1 = INPUTS.e1, pm1.g1.e2 = INPUTS.e1;\n"; //$NON-NLS-1$
+        procedure += "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+				 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e2' with expected type integer to expression 'INPUTS.e1'"); //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedure() throws Exception {
+        helpResolve("EXEC pm1.vsp1()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedure2() throws Exception {
+        helpResolve("EXEC pm1.vsp14()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedurePartialParameterReference() throws Exception {
+        helpResolve("EXEC pm1.vsp58(5)", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+    }
+    
+    //cursor starts with "#" Defect14924
+    @Test public void testVirtualProcedureInvalid1() throws Exception {
+    	helpResolveException("EXEC pm1.vsp32()",FakeMetadataFactory.example1Cached(), "Cursor names cannot begin with \"#\" as that indicates the name of a temporary table: #mycursor.");   //$NON-NLS-1$ //$NON-NLS-2$
+    }
+    
+    @Test public void testVirtualProcedureWithOrderBy() throws Exception {
+        helpResolve("EXEC pm1.vsp29()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedureWithTempTableAndOrderBy() throws Exception {
+        helpResolve("EXEC pm1.vsp33()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedureWithConstAndOrderBy() throws Exception {
+        helpResolve("EXEC pm1.vsp34()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedureWithNoFromAndOrderBy() throws Exception {
+        helpResolve("EXEC pm1.vsp28()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testInvalidVirtualProcedure2() throws Exception {
+        helpResolveException("EXEC pm1.vsp12()", FakeMetadataFactory.example1Cached(), "Symbol mycursor.e2 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+    
+    @Test public void testLoopRedefinition2() throws Exception {
+        helpResolveException("EXEC pm1.vsp11()", FakeMetadataFactory.example1Cached(), "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+        
+    @Test public void testVariableResolutionWithIntervening() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  declare string x;") //$NON-NLS-1$
+        .append("\n  x = '1';") //$NON-NLS-1$
+        .append("\n  declare string y;") //$NON-NLS-1$
+        .append("\n  y = '1';") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        TestResolver.helpResolve(proc.toString(), FakeMetadataFactory.example1Cached(), null); 
+    }
+    
+}

Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -49,7 +49,7 @@
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.function.FunctionDescriptor;
 import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.SystemFunctionManager;
 import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.metadata.TempMetadataAdapter;
@@ -1396,7 +1396,7 @@
         String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
         Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
         
-		FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();                          
+		FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();                         
 		FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] { srcType, DataTypeManager.DefaultDataClasses.STRING });
 
 		Function conversion = new Function(fd.getName(), new Expression[] { expression, new Constant(tgtTypeName) });
@@ -1432,7 +1432,7 @@
 		String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
 		Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
         
-		FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();                          
+		FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();                        
 		FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] { srcType, DataTypeManager.DefaultDataClasses.STRING });
 
 		Function conversion = new Function(fd.getName(), new Expression[] { expression, new Constant(tgtTypeName) });
@@ -1882,7 +1882,7 @@
         //String sql = "select intkey from SmallA where user() = 'bqt2'";
 
         // Expected left expression
-        FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();                          
+        FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();                          
         FunctionDescriptor fd = library.findFunction(FunctionLibrary.USER, new Class[] { });
         Function user = new Function(fd.getName(), new Expression[] {});
         user.setFunctionDescriptor(fd);
@@ -1938,7 +1938,7 @@
  
     @Test public void testDefect10809(){
         String sql = "select * from LOB_TESTING_ONE where CLOB_COLUMN LIKE '%fff%'"; //$NON-NLS-1$
-        helpResolve(helpParse(sql), FakeMetadataFactory.exampleLOB(), AnalysisRecord.createNonRecordingRecord());
+        helpResolve(helpParse(sql), FakeMetadataFactory.exampleBQTCached(), AnalysisRecord.createNonRecordingRecord());
     }
     
     @Test public void testNonAutoConversionOfLiteralIntegerToShort() throws Exception {       
@@ -2270,23 +2270,10 @@
     }
     
     
-    @Test public void testUnionInSubquery() {
+    @Test public void testUnionInSubquery() throws Exception {
         String sql = "SELECT StringKey FROM (SELECT BQT2.SmallB.StringKey FROM BQT2.SmallB union SELECT convert(BQT2.SmallB.FloatNum, string) FROM BQT2.SmallB) x";  //$NON-NLS-1$
-
-        // parse
-        Command command = null;
-        try {
-            command = QueryParser.getQueryParser().parseCommand(sql);
-        } catch(MetaMatrixException e) {
-            fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage());    //$NON-NLS-1$ //$NON-NLS-2$
-        }
-
-        // resolve
-        try {
-            QueryResolver.resolveCommand(command, FakeMetadataFactory.exampleBQT());
-        } catch(MetaMatrixException e) {
-            fail("Exception during resolution (" + e.getClass().getName() + "): " + e.getMessage());     //$NON-NLS-1$ //$NON-NLS-2$
-        }
+        Command command = QueryParser.getQueryParser().parseCommand(sql);
+        QueryResolver.resolveCommand(command, FakeMetadataFactory.exampleBQTCached());
     }
 
     @Test public void testCommandUpdatingCount1() throws Exception{

Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -118,7 +118,7 @@
         Criteria actual = null;
         // rewrite
         try { 
-            actual = QueryRewriter.rewriteCriteria(origCrit, null, null, null);
+            actual = QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
             assertEquals("Did not rewrite correctly: ", expectedCrit, actual); //$NON-NLS-1$
         } catch(QueryValidatorException e) { 
         	throw new RuntimeException(e);
@@ -1491,11 +1491,12 @@
         QueryParser parser = new QueryParser();
         Command command = parser.parseCommand("exec pm1.sp4(5)");             //$NON-NLS-1$
         
-        // resolve
-        QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
+        // resolve
+        QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+        QueryResolver.resolveCommand(command, metadata);
         
         // rewrite
-        Command rewriteCommand = QueryRewriter.rewrite(command, null, null);
+        Command rewriteCommand = QueryRewriter.rewrite(command, metadata, null);
         
         List<SPParameter> parameters = ((StoredProcedure)rewriteCommand).getParameters();
 
@@ -1512,7 +1513,7 @@
         
         // rewrite
         try { 
-            QueryRewriter.rewriteCriteria(origCrit, null, null, null);
+            QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
             fail("Expected QueryValidatorException due to divide by 0"); //$NON-NLS-1$
         } catch(QueryValidatorException e) {
         	// looks like message is being wrapped with another exception with same message
@@ -1526,7 +1527,7 @@
         
         // rewrite
         try { 
-            QueryRewriter.rewriteCriteria(origCrit, null, null, null);
+            QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
             fail("Expected QueryValidatorException due to invalid string"); //$NON-NLS-1$
         } catch(QueryValidatorException e) {
             assertEquals("Error Code:ERR.015.009.0004 Message:Unable to convert 'x' of type [string] to the expected type [integer].", e.getMessage()); //$NON-NLS-1$
@@ -1735,7 +1736,7 @@
         Properties props = new Properties();
         props.setProperty(ContextProperties.SESSION_ID, "1"); //$NON-NLS-1$
         context.setEnvironmentProperties(props);
-        Command rewriteCommand = QueryRewriter.rewrite(command, null, context);
+        Command rewriteCommand = QueryRewriter.rewrite(command, FakeMetadataFactory.example1Cached(), context);
         
         assertEquals("EXEC pm1.sq2('1')", rewriteCommand.toString()); //$NON-NLS-1$
     }
@@ -2232,20 +2233,19 @@
     
     @Test public void testRewriteParseDate() {
     	String original = "parsedate(BQT1.SmallA.stringkey, 'yymmdd') = {d'1970-01-01'}"; //$NON-NLS-1$
-    	FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+    	QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     	helpTestRewriteCriteria(original, parseCriteria("convert(parsetimestamp(BQT1.SmallA.stringkey, 'yymmdd'), date) = {d'1970-01-01'}", metadata), metadata); //$NON-NLS-1$
     }
 
     @Test public void testRewriteFormatTime() {
     	String original = "formattime(BQT1.SmallA.timevalue, 'hh:mm') = '08:02'"; //$NON-NLS-1$
-    	FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+    	QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     	helpTestRewriteCriteria(original, parseCriteria("formattimestamp(convert(BQT1.SmallA.timevalue, timestamp), 'hh:mm') = '08:02'", metadata), metadata); //$NON-NLS-1$
     }
     
     @Test public void testRewriteTimestampAdd() {
     	String original = "timestampadd(SQL_TSI_SECOND, 1, BQT1.SmallA.timevalue) = {t'08:02:00'}"; //$NON-NLS-1$
-    	FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+    	QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
     	helpTestRewriteCriteria(original, parseCriteria("convert(timestampadd(SQL_TSI_SECOND, 1, convert(BQT1.SmallA.timevalue, timestamp)), time) = {t'08:02:00'}", metadata), metadata); //$NON-NLS-1$
     }
-    
 }

Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,10 +22,11 @@
 
 package com.metamatrix.query.sql.symbol;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import junit.framework.TestCase;
 
 import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.ReservedWords;
 
 public class TestAggregateSymbol extends TestCase {
 
@@ -70,105 +71,105 @@
 	// ################################## ACTUAL TESTS ################################
 	
 	public void testParser1() {
-		AggregateSymbol as = new AggregateSymbol("count", ReservedWords.COUNT, false, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol("count", SQLReservedWords.COUNT, false, sampleElement()); //$NON-NLS-1$
 		helpParser(as, "COUNT(m.g.c)"); //$NON-NLS-1$
 	}
 
 	public void testParser2() {
-		AggregateSymbol as = new AggregateSymbol("count", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol("count", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
 		helpParser(as, "COUNT(DISTINCT m.g.c)"); //$NON-NLS-1$
 	}
 
 	public void testParser3() {
-		AggregateSymbol as = new AggregateSymbol("x", ReservedWords.MIN, false, sampleConstant()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol("x", SQLReservedWords.MIN, false, sampleConstant()); //$NON-NLS-1$
 		helpParser(as, "MIN(5)"); //$NON-NLS-1$
 	}
 
 	public void testParser4() {
-		AggregateSymbol as = new AggregateSymbol("x", ReservedWords.MAX, false, sampleFunction()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol("x", SQLReservedWords.MAX, false, sampleFunction()); //$NON-NLS-1$
 		helpParser(as, "MAX((m.g.c + 5))"); //$NON-NLS-1$
 	}
 
 	public void testParser5() {
-		AggregateSymbol as = new AggregateSymbol("x", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol("x", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
 		helpParser(as, "COUNT(*)"); //$NON-NLS-1$
 	}
 		
 	public void testEquals1() { 
-		AggregateSymbol as = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
 		helpEquals(as, as, true);		
 	}
 
 	public void testEquals2() { 
-		AggregateSymbol as1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
 		AggregateSymbol as2 = (AggregateSymbol) as1.clone();
 		helpEquals(as1, as2, true);		
 	}
 
     //just changing the name of an aggregatesymbol doesn't matter
 	public void testEquals3() { 
-		AggregateSymbol as1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
-		AggregateSymbol as2 = new AggregateSymbol("y", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as2 = new AggregateSymbol("y", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
 		helpEquals(as1, as2, true);		
 	}
 	
 	public void testEquals4() { 
-		AggregateSymbol as1 = new AggregateSymbol("count", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+		AggregateSymbol as1 = new AggregateSymbol("count", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
 		AggregateSymbol as2 = (AggregateSymbol) as1.clone();
 		helpEquals(as1, as2, true);		
 	}
 
 	public void testSelfEquivalence(){
-		AggregateSymbol test = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
 		int equals = 0;
 		UnitTestUtil.helpTestEquivalence(equals, test, test);
 	}
 
 	public void testEquivalence(){
-		AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
-		AggregateSymbol test2 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test2 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
 		int equals = 0;
 		UnitTestUtil.helpTestEquivalence(equals, test1, test2);
 	}
     
     public void testEquivalenceCountStar(){
-        AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, false, null); //$NON-NLS-1$
-        AggregateSymbol test2 = new AggregateSymbol("x", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol test2 = new AggregateSymbol("x", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
         int equals = 0;
         UnitTestUtil.helpTestEquivalence(equals, test1, test2);
     }
 
 	public void testEquivalenceCaseInsens(){
-		AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
-		AggregateSymbol test2 = new AggregateSymbol("X", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test2 = new AggregateSymbol("X", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
 		int equals = 0;
 		UnitTestUtil.helpTestEquivalence(equals, test1, test2);
 	}
     
     public void testNonEquivalenceUsingDiffElements(){ 
-        AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$ 
-        AggregateSymbol test2 = new AggregateSymbol("X", ReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$ 
+        AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$ 
+        AggregateSymbol test2 = new AggregateSymbol("X", SQLReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$ 
         int equals = -1; 
         UnitTestUtil.helpTestEquivalence(equals, test1, test2); 
     } 
 	
 	public void testNonEquivalence(){
-		AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
-		AggregateSymbol test2 = new AggregateSymbol("y", ReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
+		AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test2 = new AggregateSymbol("y", SQLReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
 		int equals = -1;
 		UnitTestUtil.helpTestEquivalence(equals, test1, test2);
 	}
     
     public void testNonEquivalence1(){
-        AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
-        AggregateSymbol test2 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
+        AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement()); //$NON-NLS-1$
+        AggregateSymbol test2 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
         int equals = -1;
         UnitTestUtil.helpTestEquivalence(equals, test1, test2);
     }
     
     public void testNonEquivalence2(){
-        AggregateSymbol test1 = new AggregateSymbol("x", ReservedWords.MAX, true, sampleElement()); //$NON-NLS-1$
-        AggregateSymbol test2 = new AggregateSymbol("x", ReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
+        AggregateSymbol test1 = new AggregateSymbol("x", SQLReservedWords.MAX, true, sampleElement()); //$NON-NLS-1$
+        AggregateSymbol test2 = new AggregateSymbol("x", SQLReservedWords.COUNT, true, sampleElement2()); //$NON-NLS-1$
         int equals = -1;
         UnitTestUtil.helpTestEquivalence(equals, test1, test2);
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -178,7 +178,7 @@
 			"vm1.g1", //$NON-NLS-1$
 			"select e1 as a, e2 from pm1.g1 where e4 > 5",              //$NON-NLS-1$
 		    TestUpdateProcedureGenerator.example1(),
-            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (INPUT.a, INPUT.e2);\nEND"); //$NON-NLS-1$
+            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (INPUTS.a, INPUTS.e2);\nEND"); //$NON-NLS-1$
 	}
 	
 	public void testCreateInsertCommand2(){ //put a constant in select statement
@@ -186,7 +186,7 @@
 			"vm1.g1", //$NON-NLS-1$
 			"select e1 as a, 5 from pm1.g1 where e4 > 5",              //$NON-NLS-1$
 		    TestUpdateProcedureGenerator.example1(),
-            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1) VALUES (INPUT.a);\nEND"); //$NON-NLS-1$
+            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1) VALUES (INPUTS.a);\nEND"); //$NON-NLS-1$
 	}
 	
 	public void testCreateInsertCommand3(){ 
@@ -194,7 +194,7 @@
 			"vm1.g2", //$NON-NLS-1$
 			"select * from pm1.g2 where e4 > 5",              //$NON-NLS-1$
 		    TestUpdateProcedureGenerator.example1(),
-            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUT.e1, INPUT.e2, INPUT.e3, INPUT.e4);\nEND"); //$NON-NLS-1$
+            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUTS.e1, INPUTS.e2, INPUTS.e3, INPUTS.e4);\nEND"); //$NON-NLS-1$
 	}
 	
 	public void testCreateInsertCommand4(){ //test group alias
@@ -202,7 +202,7 @@
 			"vm1.g2", //$NON-NLS-1$
 			"select * from pm1.g2 as g_alias",              //$NON-NLS-1$
 			TestUpdateProcedureGenerator.example1(),
-			"CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUT.e1, INPUT.e2, INPUT.e3, INPUT.e4);\nEND"); //$NON-NLS-1$
+			"CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUTS.e1, INPUTS.e2, INPUTS.e3, INPUTS.e4);\nEND"); //$NON-NLS-1$
 	}	
 
 	public void testCreateInsertCommand5(){
@@ -210,7 +210,7 @@
 			"vm1.g1", //$NON-NLS-1$
 			"select e1 as a, e2 from pm1.g1 as g_alias where e4 > 5",              //$NON-NLS-1$
 			TestUpdateProcedureGenerator.example1(),
-			"CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (INPUT.a, INPUT.e2);\nEND"); //$NON-NLS-1$
+			"CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (INPUTS.a, INPUTS.e2);\nEND"); //$NON-NLS-1$
 	}
 		
 	public void testCreateUpdateCommand(){
@@ -218,7 +218,7 @@
 			"vm1.g1", //$NON-NLS-1$
 			"select e1 as a, e2 from pm1.g1 where e4 > 5",              //$NON-NLS-1$
 		    TestUpdateProcedureGenerator.example1(),
-            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e1 = INPUT.a, e2 = INPUT.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
+            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e1 = INPUTS.a, e2 = INPUTS.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
 	}
 	
 	public void testCreateDeleteCommand(){
@@ -339,7 +339,7 @@
             "vm1.g3", //$NON-NLS-1$
             "SELECT e1, e2 FROM pm1.g3", //$NON-NLS-1$
             TestUpdateProcedureGenerator.example1(),
-            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e2) VALUES (INPUT.e1, INPUT.e2);\nEND"); //$NON-NLS-1$
+            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e2) VALUES (INPUTS.e1, INPUTS.e2);\nEND"); //$NON-NLS-1$
     }
 
     // Check that e2 is not required (it is auto-incremented)
@@ -348,7 +348,7 @@
             "vm1.g4", //$NON-NLS-1$
             "SELECT e1, e3 FROM pm1.g3", //$NON-NLS-1$
             TestUpdateProcedureGenerator.example1(),
-            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e3) VALUES (INPUT.e1, INPUT.e3);\nEND"); //$NON-NLS-1$
+            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e3) VALUES (INPUTS.e1, INPUTS.e3);\nEND"); //$NON-NLS-1$
     }
 
     // Check that e1 is required (it is not-nullable, not auto-incrementable, and has no default value)
@@ -366,7 +366,7 @@
                     "vm1.g1", //$NON-NLS-1$
                     "select e1 as a, e2 from pm1.g1 where e4 > 5",              //$NON-NLS-1$
                     TestUpdateProcedureGenerator.example1(false),
-                    "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e2 = INPUT.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
+                    "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e2 = INPUTS.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
 	}
 	
     // Verify that elements that are not updateable are exlcluded from update and delete procedures
@@ -375,7 +375,7 @@
             "vm1.g1", //$NON-NLS-1$
             "SELECT e1, e2 FROM pm1.g1", //$NON-NLS-1$
             TestUpdateProcedureGenerator.example1(false),
-            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e2) VALUES (INPUT.e2);\nEND"); //$NON-NLS-1$
+            "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e2) VALUES (INPUTS.e2);\nEND"); //$NON-NLS-1$
     }
 
 }

Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -32,9 +32,9 @@
 
 import org.junit.Test;
 import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.language.SQLReservedWords;
 
 import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.CompareCriteria;
 import com.metamatrix.query.sql.lang.Select;
 import com.metamatrix.query.sql.lang.SetCriteria;
@@ -196,10 +196,10 @@
      */
     @Test public void testRecursionDetection() {
     	ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
-    	AggregateSymbol a1 = new AggregateSymbol("x", ReservedWords.SUM, false, e1); //$NON-NLS-1$
+    	AggregateSymbol a1 = new AggregateSymbol("x", SQLReservedWords.SUM, false, e1); //$NON-NLS-1$
     	Function f = new Function(SourceSystemFunctions.ADD_OP, new Expression[] {a1, a1});
     	HashMap<AggregateSymbol, AggregateSymbol> map = new HashMap<AggregateSymbol, AggregateSymbol>();
-    	map.put(a1, new AggregateSymbol("x", ReservedWords.SUM, false, a1)); //$NON-NLS-1$
+    	map.put(a1, new AggregateSymbol("x", SQLReservedWords.SUM, false, a1)); //$NON-NLS-1$
     	ExpressionMappingVisitor.mapExpressions(f, map);
         assertEquals("(SUM(SUM(e1)) + SUM(SUM(e1)))", f.toString()); //$NON-NLS-1$
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,6 +27,8 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.teiid.connector.language.SQLReservedWords;
+
 import junit.framework.TestCase;
 
 import com.metamatrix.common.types.DataTypeManager;
@@ -34,7 +36,6 @@
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.QueryResolver;
 import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.BetweenCriteria;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -1051,37 +1052,37 @@
 	}
 	
 	public void testAggregateSymbol1() {
-		AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.COUNT, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.COUNT, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "COUNT('abc')"); //$NON-NLS-1$
 	}
 	
 	public void testAggregateSymbol2() {
-		AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.COUNT, true, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.COUNT, true, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "COUNT(DISTINCT 'abc')"); //$NON-NLS-1$
 	}
 	
 	public void testAggregateSymbol3() {
-		AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.COUNT, false, null); //$NON-NLS-1$
+		AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.COUNT, false, null); //$NON-NLS-1$
 		helpTest(agg, "COUNT(*)"); //$NON-NLS-1$
 	}
 	
 	public void testAggregateSymbol4() {
-		AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.AVG, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.AVG, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "AVG('abc')"); //$NON-NLS-1$
 	}
 	
 	public void testAggregateSymbol5() {
-		AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.SUM, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.SUM, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "SUM('abc')"); //$NON-NLS-1$
 	}
 	
 	public void testAggregateSymbol6() {
-		AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.MIN, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.MIN, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "MIN('abc')"); //$NON-NLS-1$
 	}
 	
 	public void testAggregateSymbol7() {
-		AggregateSymbol agg = new AggregateSymbol("abc", ReservedWords.MAX, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol("abc", SQLReservedWords.MAX, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "MAX('abc')"); //$NON-NLS-1$
 	}
 	

Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFacade.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFacade.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFacade.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -35,6 +35,8 @@
 import com.metamatrix.core.util.ArgCheck;
 import com.metamatrix.core.util.Assertion;
 import com.metamatrix.dqp.message.ParameterInfo;
+import com.metamatrix.query.function.FunctionLibrary;
+import com.metamatrix.query.function.SystemFunctionManager;
 import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.mapping.xml.MappingBaseNode;
 import com.metamatrix.query.mapping.xml.MappingDocument;
@@ -51,10 +53,17 @@
 public class FakeMetadataFacade extends BasicQueryMetadata {
 
 	private FakeMetadataStore store;
+	private FunctionLibrary functionLibrary;
 
 	public FakeMetadataFacade(FakeMetadataStore store) {
 		this.store = store;
+		this.functionLibrary = SystemFunctionManager.getSystemFunctionLibrary();
 	}
+	
+	public FakeMetadataFacade(FakeMetadataStore store, FunctionLibrary funcLibrary) {
+		this.store = store;
+		this.functionLibrary = funcLibrary;
+	}
 
 	public FakeMetadataStore getStore() {
 		return this.store;
@@ -759,4 +768,9 @@
         	return object.getProperty(key);
 		}
     }
+    
+    @Override
+    public FunctionLibrary getFunctionLibrary() {
+    	return this.functionLibrary;
+    }
 }

Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,13 +29,22 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.metadata.TransformationMetadata;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.core.vdb.ModelType;
 import com.metamatrix.dqp.message.ParameterInfo;
+import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.mapping.xml.MappingAttribute;
 import com.metamatrix.query.mapping.xml.MappingDocument;
 import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
 import com.metamatrix.query.mapping.xml.MappingSequenceNode;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -43,7 +52,6 @@
 public class FakeMetadataFactory {
 
     private static FakeMetadataFacade CACHED_EXAMPLE1 = example1();
-    private static FakeMetadataFacade CACHED_BQT = exampleBQT();
     private static FakeMetadataFacade CACHED_AGGREGATES = exampleAggregates();
         
 	private FakeMetadataFactory() { }
@@ -52,14 +60,38 @@
         return CACHED_EXAMPLE1;
     }
 
-    public static FakeMetadataFacade exampleBQTCached() {
-        return CACHED_BQT;
+    public static TransformationMetadata exampleBQTCached() {
+        return RealMetadataFactory.exampleBQTCached();
     }
     
+    public static void setCardinality(String group, int cardinality, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+    	if (metadata instanceof TransformationMetadata) {
+    		Table t = (Table)metadata.getGroupID(group);
+    		t.setCardinality(cardinality);
+    	} else if (metadata instanceof FakeMetadataFacade) {
+    		FakeMetadataObject fmo = (FakeMetadataObject)metadata.getGroupID(group);
+    		fmo.putProperty(FakeMetadataObject.Props.CARDINALITY, cardinality);
+    	} else {
+    		throw new RuntimeException("unknown metadata"); //$NON-NLS-1$
+    	}
+    	
+    }
+    
     public static FakeMetadataFacade exampleAggregatesCached() {
         return CACHED_AGGREGATES;
     }       
-
+    
+	public static DQPWorkContext buildWorkContext(QueryMetadataInterface metadata, VDBMetaData vdb) {
+		DQPWorkContext workContext = new DQPWorkContext();
+        workContext.setVdbName(vdb.getName()); 
+        workContext.setVdbVersion(vdb.getVersion()); 
+        workContext.setSessionToken(new SessionToken(5, "foo")); //$NON-NLS-1$
+        workContext.setVdb(vdb);
+        workContext.getVDB().addAttchment(QueryMetadataInterface.class, metadata);
+        DQPWorkContext.setWorkContext(workContext);
+		return workContext;
+	}
+    
     public static FakeMetadataFacade exampleBitwise() { 
         FakeMetadataObject phys = createPhysicalModel("phys"); //$NON-NLS-1$
         FakeMetadataObject t = createPhysicalGroup("phys.t", phys); //$NON-NLS-1$
@@ -99,6 +131,39 @@
         
     }
     
+    public static VDBMetaData example1VDB() {
+    	VDBMetaData vdb = new VDBMetaData();
+    	vdb.setName("example1");
+    	vdb.setVersion(1);
+    	vdb.addModel(createModel("pm1", true));
+    	vdb.addModel(createModel("pm2", true));
+    	vdb.addModel(createModel("pm3", true));
+    	vdb.addModel(createModel("pm4", true));
+    	vdb.addModel(createModel("pm5", true));
+    	vdb.addModel(createModel("pm6", true));
+    	vdb.addModel(createModel("vm1", false));
+    	vdb.addModel(createModel("vm2", false));
+    	vdb.addModel(createModel("tm1", false));
+    	
+    	return vdb;
+    }
+    
+    public static ModelMetaData createModel(String name, boolean source) {
+    	ModelMetaData model = new ModelMetaData();
+    	model.setName(name);
+    	if (source) {
+    		model.setModelType(ModelType.getString(ModelType.PHYSICAL));
+    	}
+    	else {
+    		model.setModelType(ModelType.getString(ModelType.VIRTUAL));
+    	}
+    	model.setVisible(true);
+    	model.setSupportsMultiSourceBindings(false);
+    	model.addSourceMapping(name, null);
+    	
+    	return model;
+    }
+    
 	public static FakeMetadataFacade example1() { 
 		// Create models
 		FakeMetadataObject pm1 = createPhysicalModel("pm1"); //$NON-NLS-1$
@@ -2049,673 +2114,27 @@
         return new FakeMetadataFacade(store);
     }
     
-    public static FakeMetadataFacade exampleBQT() { 
-        // Create models
-        FakeMetadataObject bqt1 = createPhysicalModel("BQT1"); //$NON-NLS-1$
-        FakeMetadataObject bqt2 = createPhysicalModel("BQT2"); //$NON-NLS-1$
-        FakeMetadataObject bqt3 = createPhysicalModel("BQT3"); //$NON-NLS-1$
-        FakeMetadataObject lob = createPhysicalModel("LOB"); //$NON-NLS-1$
-        FakeMetadataObject vqt = createVirtualModel("VQT"); //$NON-NLS-1$
-        
-        // Create physical groups
-        FakeMetadataObject bqt1SmallA = createPhysicalGroup("BQT1.SmallA", bqt1); //$NON-NLS-1$
-        FakeMetadataObject bqt1SmallB = createPhysicalGroup("BQT1.SmallB", bqt1); //$NON-NLS-1$
-        FakeMetadataObject bqt1MediumA = createPhysicalGroup("BQT1.MediumA", bqt1); //$NON-NLS-1$
-        FakeMetadataObject bqt1MediumB = createPhysicalGroup("BQT1.MediumB", bqt1); //$NON-NLS-1$
-        FakeMetadataObject bqt2SmallA = createPhysicalGroup("BQT2.SmallA", bqt2); //$NON-NLS-1$
-        FakeMetadataObject bqt2SmallB = createPhysicalGroup("BQT2.SmallB", bqt2); //$NON-NLS-1$
-        FakeMetadataObject bqt2MediumA = createPhysicalGroup("BQT2.MediumA", bqt2); //$NON-NLS-1$
-        FakeMetadataObject bqt2MediumB = createPhysicalGroup("BQT2.MediumB", bqt2); //$NON-NLS-1$
-        FakeMetadataObject bqt3SmallA = createPhysicalGroup("BQT3.SmallA", bqt3); //$NON-NLS-1$
-        FakeMetadataObject bqt3SmallB = createPhysicalGroup("BQT3.SmallB", bqt3); //$NON-NLS-1$
-        FakeMetadataObject bqt3MediumA = createPhysicalGroup("BQT3.MediumA", bqt3); //$NON-NLS-1$
-        FakeMetadataObject bqt3MediumB = createPhysicalGroup("BQT3.MediumB", bqt3); //$NON-NLS-1$
-        FakeMetadataObject lobTable = createPhysicalGroup("LOB.LobTbl", lob); //$NON-NLS-1$
-
-        // Create virtual groups
-        QueryNode vqtn1 = new QueryNode("VQT.SmallA", "SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg1 = createUpdatableVirtualGroup("VQT.SmallA", vqt, vqtn1); //$NON-NLS-1$
-        
-        QueryNode vqtn2 = new QueryNode("VQT.SmallB", "SELECT Concat(stringKey, stringNum) as a12345 FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2 = createUpdatableVirtualGroup("VQT.SmallB", vqt, vqtn2); //$NON-NLS-1$        
-
-        // Case 2589
-        QueryNode vqtn2589 = new QueryNode("VQT.SmallA_2589", "SELECT * FROM BQT1.SmallA WHERE StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2589 = createVirtualGroup("VQT.SmallA_2589", vqt, vqtn2589); //$NON-NLS-1$
-
-        QueryNode vqtn2589a = new QueryNode("VQT.SmallA_2589a", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.IntKey = SmallB.IntKey WHERE SmallA.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2589a = createVirtualGroup("VQT.SmallA_2589a", vqt, vqtn2589a); //$NON-NLS-1$
-
-        QueryNode vqtn2589b = new QueryNode("VQT.SmallA_2589b", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2589b = createVirtualGroup("VQT.SmallA_2589b", vqt, vqtn2589b); //$NON-NLS-1$
-
-        QueryNode vqtn2589c = new QueryNode("VQT.SmallA_2589c", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE concat(SmallA.StringNum, SmallB.StringNum) = '1010'"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2589c = createVirtualGroup("VQT.SmallA_2589c", vqt, vqtn2589c); //$NON-NLS-1$
-        
-        QueryNode vqtn2589d = new QueryNode("VQT.SmallA_2589d", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10' AND SmallA.IntNum = 10"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2589d = createVirtualGroup("VQT.SmallA_2589d", vqt, vqtn2589d); //$NON-NLS-1$
-
-        QueryNode vqtn2589f = new QueryNode("VQT.SmallA_2589f", "SELECT * FROM VQT.SmallA_2589"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2589f = createVirtualGroup("VQT.SmallA_2589f", vqt, vqtn2589f); //$NON-NLS-1$
-
-        QueryNode vqtn2589g = new QueryNode("VQT.SmallA_2589g", "SELECT * FROM VQT.SmallA_2589b"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2589g = createVirtualGroup("VQT.SmallA_2589g", vqt, vqtn2589g); //$NON-NLS-1$
-
-        QueryNode vqtn2589h = new QueryNode("VQT.SmallA_2589h", "SELECT VQT.SmallA_2589.* FROM VQT.SmallA_2589 INNER JOIN BQT1.SmallB ON VQT.SmallA_2589.StringKey = SmallB.StringKey"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2589h = createVirtualGroup("VQT.SmallA_2589h", vqt, vqtn2589h); //$NON-NLS-1$
-        
-        QueryNode vqtn2589i = new QueryNode("VQT.SmallA_2589i", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10' AND SmallB.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg2589i = createVirtualGroup("VQT.SmallA_2589i", vqt, vqtn2589i); //$NON-NLS-1$
-
-        // defect 15355
-        QueryNode vqtn15355  = new QueryNode("VQT.Defect15355", "SELECT convert(IntKey, string) as StringKey, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg15355  = createVirtualGroup("VQT.Defect15355", vqt, vqtn15355); //$NON-NLS-1$
-        QueryNode vqtn15355a  = new QueryNode("VQT.Defect15355a", "SELECT StringKey, StringNum, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, StringNum, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg15355a  = createVirtualGroup("VQT.Defect15355a", vqt, vqtn15355a); //$NON-NLS-1$
-        QueryNode vqtn15355b  = new QueryNode("VQT.Defect15355b", "SELECT convert(IntKey, string) as IntKey, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vqtg15355b  = createVirtualGroup("VQT.Defect15355b", vqt, vqtn15355b); //$NON-NLS-1$
-        
-        // Create physical elements
-        String[] elemNames = new String[] { 
-             "IntKey", "StringKey",  //$NON-NLS-1$ //$NON-NLS-2$
-             "IntNum", "StringNum",  //$NON-NLS-1$ //$NON-NLS-2$
-             "FloatNum", "LongNum",  //$NON-NLS-1$ //$NON-NLS-2$
-             "DoubleNum", "ByteNum",  //$NON-NLS-1$ //$NON-NLS-2$
-             "DateValue", "TimeValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "TimestampValue", "BooleanValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "CharValue", "ShortValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "BigIntegerValue", "BigDecimalValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "ObjectValue" }; //$NON-NLS-1$
-         String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, 
-                             DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, 
-                             DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG, 
-                             DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE, 
-                             DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME, 
-                             DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN, 
-                             DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT, 
-                             DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, 
-                             DataTypeManager.DefaultDataTypes.OBJECT };
-        
-        List<FakeMetadataObject> bqt1SmallAe = createElements(bqt1SmallA, elemNames, elemTypes);
-        bqt1SmallAe.get(1).putProperty(FakeMetadataObject.Props.NATIVE_TYPE, "char"); //$NON-NLS-1$
-        List bqt1SmallBe = createElements(bqt1SmallB, elemNames, elemTypes);
-        List bqt1MediumAe = createElements(bqt1MediumA, elemNames, elemTypes);
-        List bqt1MediumBe = createElements(bqt1MediumB, elemNames, elemTypes);
-        List bqt2SmallAe = createElements(bqt2SmallA, elemNames, elemTypes);
-        List bqt2SmallBe = createElements(bqt2SmallB, elemNames, elemTypes);
-        List bqt2MediumAe = createElements(bqt2MediumA, elemNames, elemTypes);
-        List bqt2MediumBe = createElements(bqt2MediumB, elemNames, elemTypes);                
-        List bqt3SmallAe = createElements(bqt3SmallA, elemNames, elemTypes);
-        List bqt3SmallBe = createElements(bqt3SmallB, elemNames, elemTypes);
-        List bqt3MediumAe = createElements(bqt3MediumA, elemNames, elemTypes);
-        List bqt3MediumBe = createElements(bqt3MediumB, elemNames, elemTypes);
-        List lobTable_elem = createElements(lobTable, new String[] {"ClobValue"}, new String[] {DataTypeManager.DefaultDataTypes.CLOB}); //$NON-NLS-1$
-        
-        // Create virtual elements
-        List vqtg1e = createElements(vqtg1, elemNames, elemTypes);        
-        List vqtg2e = createElements(vqtg2, new String[] {"a12345"}, new String[] {DataTypeManager.DefaultDataTypes.STRING});  //$NON-NLS-1$
-        List vqtg15355e = createElements(vqtg15355, new String[] {"StringKey", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER});         //$NON-NLS-1$ //$NON-NLS-2$
-        List vqtg15355ae = createElements(vqtg15355a, new String[] {"StringKey", "StringNum", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER});         //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        List vqtg15355be = createElements(vqtg15355b, new String[] {"IntKey", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER});         //$NON-NLS-1$ //$NON-NLS-2$
-        List vqtg2589e = createElements(vqtg2589, elemNames, elemTypes);        
-        List vqtg2589ae = createElements(vqtg2589a, elemNames, elemTypes);        
-        List vqtg2589be = createElements(vqtg2589b, elemNames, elemTypes);        
-        List vqtg2589ce = createElements(vqtg2589c, elemNames, elemTypes);        
-        List vqtg2589de = createElements(vqtg2589d, elemNames, elemTypes);        
-        List vqtg2589fe = createElements(vqtg2589f, elemNames, elemTypes);        
-        List vqtg2589ge = createElements(vqtg2589g, elemNames, elemTypes);        
-        List vqtg2589he = createElements(vqtg2589h, elemNames, elemTypes);        
-        List vqtg2589ie = createElements(vqtg2589i, elemNames, elemTypes);        
-
-        // Add stored procedure
-        FakeMetadataObject pm1 = createPhysicalModel("pm1"); //$NON-NLS-1$
-        FakeMetadataObject rs1p1 = createParameter("intkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null);         //$NON-NLS-1$
-        FakeMetadataObject rs1 = createResultSet("pm1.rs1", pm1, new String[] { "IntKey", "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        FakeMetadataObject rs1p2 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs1);  //$NON-NLS-1$
-        FakeMetadataObject spTest5 = createStoredProcedure("spTest5", pm1, Arrays.asList(new FakeMetadataObject[] { rs1p1, rs1p2}), "spTest5"); //$NON-NLS-1$ //$NON-NLS-2$
-
-        FakeMetadataObject pm2 = createPhysicalModel("pm2"); //$NON-NLS-1$
-        FakeMetadataObject rs2p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
-        FakeMetadataObject rs2p2 = createParameter("outkey", 3, ParameterInfo.OUT, DataTypeManager.DefaultDataTypes.INTEGER, null);                 //$NON-NLS-1$
-        FakeMetadataObject rs2 = createResultSet("pm2.rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        FakeMetadataObject rs2p3 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2);  //$NON-NLS-1$
-        FakeMetadataObject spTest8 = createStoredProcedure("pm2.spTest8", pm2, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2, rs2p3}), "spTest8"); //$NON-NLS-1$ //$NON-NLS-2$
-
-        FakeMetadataObject spTest8a = createStoredProcedure("pm2.spTest8a", pm2, Arrays.asList(new FakeMetadataObject[] { rs2p2, rs2p3}), "spTest8a"); //$NON-NLS-1$ //$NON-NLS-2$
-        
-        FakeMetadataObject pm4 = createPhysicalModel("pm4"); //$NON-NLS-1$
-        FakeMetadataObject rs4p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
-        FakeMetadataObject rs4p2 = createParameter("ret", 1, ParameterInfo.RETURN_VALUE, DataTypeManager.DefaultDataTypes.INTEGER, null);  //$NON-NLS-1$
-        FakeMetadataObject spTest9 = createStoredProcedure("pm4.spTest9", pm4, Arrays.asList(new FakeMetadataObject[] { rs4p1, rs4p2}), "spTest9"); //$NON-NLS-1$ //$NON-NLS-2$
-
-        FakeMetadataObject pm3 = createPhysicalModel("pm3"); //$NON-NLS-1$
-        FakeMetadataObject rs3p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
-        FakeMetadataObject rs3p2 = createParameter("outkey", 3, ParameterInfo.INOUT, DataTypeManager.DefaultDataTypes.INTEGER, null);                 //$NON-NLS-1$
-        FakeMetadataObject rs3 = createResultSet("pm3.rs3", pm3, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        FakeMetadataObject rs3p3 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs3);  //$NON-NLS-1$
-        FakeMetadataObject spTest11 = createStoredProcedure("spTest11", pm3, Arrays.asList(new FakeMetadataObject[] { rs3p1, rs3p2, rs3p3}), "spTest11"); //$NON-NLS-1$ //$NON-NLS-2$
-                   
-        //add virtual stored procedures 
-        FakeMetadataObject mmspTest1 = createVirtualModel("mmspTest1"); //$NON-NLS-1$
-        FakeMetadataObject vsprs1 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vspp1 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, vsprs1); //$NON-NLS-1$
-        QueryNode vspqn1 = new QueryNode("vsp1", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vsp1 = createVirtualProcedure("mmspTest1.MMSP1", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn1); //$NON-NLS-1$
-
-        QueryNode vspqn2 = new QueryNode("vsp2", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor1 BEGIN LOOP ON (SELECT intkey FROM bqt1.smallB) AS intKeyCursor2 BEGIN x= intKeyCursor1.intkey - intKeyCursor2.intkey; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vsp2 = createVirtualProcedure("mmspTest1.MMSP2", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn2); //$NON-NLS-1$
-
-        QueryNode vspqn3 = new QueryNode("vsp3", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vsp3 = createVirtualProcedure("mmspTest1.MMSP3", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn3); //$NON-NLS-1$
-
-        QueryNode vspqn4 = new QueryNode("vsp4", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; x=0; WHILE(x < 50) BEGIN x= x + 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vsp4 = createVirtualProcedure("mmspTest1.MMSP4", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn4); //$NON-NLS-1$
-
-        FakeMetadataObject vsp5p1 = createParameter("param1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
-        QueryNode vspqn5 = new QueryNode("vsp5", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 0; END"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vsp5 = createVirtualProcedure("mmspTest1.MMSP5", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1, vsp5p1 }), vspqn5); //$NON-NLS-1$
-
-        FakeMetadataObject vsp6p1 = createParameter("p1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
-        QueryNode vspqn6 = new QueryNode("vsp6", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 1; END"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject vsp6 = createVirtualProcedure("mmspTest1.MMSP6", mmspTest1, Arrays.asList(new FakeMetadataObject[] { vspp1, vsp6p1 }), vspqn6); //$NON-NLS-1$
-
-        // Add all objects to the store
-        FakeMetadataStore store = new FakeMetadataStore();
-        store.addObject(bqt1);
-        store.addObject(bqt1SmallA);     
-        store.addObjects(bqt1SmallAe);
-        store.addObject(bqt1SmallB);     
-        store.addObjects(bqt1SmallBe);
-        store.addObject(bqt1MediumA);     
-        store.addObjects(bqt1MediumAe);
-        store.addObject(bqt1MediumB);     
-        store.addObjects(bqt1MediumBe);
-
-        store.addObject(bqt2);
-        store.addObject(bqt2SmallA);     
-        store.addObjects(bqt2SmallAe);
-        store.addObject(bqt2SmallB);     
-        store.addObjects(bqt2SmallBe);
-        store.addObject(bqt2MediumA);     
-        store.addObjects(bqt2MediumAe);
-        store.addObject(bqt2MediumB);     
-        store.addObjects(bqt2MediumBe);
-
-        store.addObject(bqt3);
-        store.addObject(bqt3SmallA);     
-        store.addObjects(bqt3SmallAe);
-        store.addObject(bqt3SmallB);     
-        store.addObjects(bqt3SmallBe);
-        store.addObject(bqt3MediumA);     
-        store.addObjects(bqt3MediumAe);
-        store.addObject(bqt3MediumB);     
-        store.addObjects(bqt3MediumBe);
-
-        store.addObject(lob);
-        store.addObject(lobTable);     
-        store.addObjects(lobTable_elem);
-        
-        store.addObject(vqtg1);     
-        store.addObjects(vqtg1e);
-        
-        store.addObject(vqtg2);     
-        store.addObjects(vqtg2e);
-        
-        store.addObject(vqtg15355);     
-        store.addObjects(vqtg15355e);
-        store.addObject(vqtg15355a);     
-        store.addObjects(vqtg15355ae);
-        store.addObject(vqtg15355b);     
-        store.addObjects(vqtg15355be);
-
-        store.addObject(vqtg2589);     
-        store.addObjects(vqtg2589e);
-        store.addObject(vqtg2589a);     
-        store.addObjects(vqtg2589ae);
-        store.addObject(vqtg2589b);     
-        store.addObjects(vqtg2589be);
-        store.addObject(vqtg2589c);     
-        store.addObjects(vqtg2589ce);
-        store.addObject(vqtg2589d);     
-        store.addObjects(vqtg2589de);
-        store.addObject(vqtg2589f);     
-        store.addObjects(vqtg2589fe);
-        store.addObject(vqtg2589g);     
-        store.addObjects(vqtg2589ge);
-        store.addObject(vqtg2589h);     
-        store.addObjects(vqtg2589he);
-        store.addObject(vqtg2589i);     
-        store.addObjects(vqtg2589ie);
-
-        store.addObject(vqtg2);     
-        store.addObjects(vqtg2e);
-
-        store.addObject(pm1);
-        store.addObject(spTest5);
-        store.addObject(rs1);
-        
-        store.addObject(pm2);
-        store.addObject(spTest8);
-        store.addObject(spTest8a);
-        store.addObject(rs2);
-        
-        store.addObject(pm4);
-        store.addObject(spTest9);
-        
-        store.addObject(pm3);
-        store.addObject(spTest11);
-        store.addObject(rs3);
-        
-        store.addObject(vsp1);
-        store.addObject(vsp2);
-        store.addObject(vsp3);
-        store.addObject(vsp4);
-        store.addObject(vsp5);
-        store.addObject(vsp6);
-        
-        // Create the facade from the store
-        return new FakeMetadataFacade(store);
+    public static VDBMetaData exampleBQTVDB() {
+    	VDBMetaData vdb = new VDBMetaData();
+    	vdb.setName("example1");
+    	vdb.setVersion(1);
+    	vdb.addModel(createModel("BQT1", true));
+    	vdb.addModel(createModel("BQT2", true));
+    	vdb.addModel(createModel("BQT3", true));
+    	vdb.addModel(createModel("LOB", true));
+    	vdb.addModel(createModel("VQT", false));
+    	vdb.addModel(createModel("pm1", true));
+    	vdb.addModel(createModel("pm2", true));
+    	vdb.addModel(createModel("pm3", true));
+    	vdb.addModel(createModel("pm4", true));
+    	
+    	return vdb;
     }
-
-    public static FakeMetadataFacade exampleUQT() { 
-        // Create models
-        FakeMetadataObject uqt2 = createPhysicalModel("UQT2"); //$NON-NLS-1$
-
-        // Create physical groups
-        FakeMetadataObject uqt2UpdateA = createPhysicalGroup("UQT2.UpdateA", uqt2); //$NON-NLS-1$
-        FakeMetadataObject uqt2UpdateB = createPhysicalGroup("UQT2.UpdateB", uqt2); //$NON-NLS-1$
-        FakeMetadataObject uqt2BlobTable = createPhysicalGroup("UQT2.BlobTable", uqt2); //$NON-NLS-1$
-
-        // Create physical elements
-        String[] elemNames = new String[] { 
-             "IntKey", "StringKey",  //$NON-NLS-1$ //$NON-NLS-2$
-             "IntNum", "StringNum",  //$NON-NLS-1$ //$NON-NLS-2$
-             "FloatNum", "LongNum",  //$NON-NLS-1$ //$NON-NLS-2$
-             "DoubleNum", "ByteNum",  //$NON-NLS-1$ //$NON-NLS-2$
-             "DateValue", "TimeValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "TimestampValue", "BooleanValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "CharValue", "ShortValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "BigIntegerValue", "BigDecimalValue",  //$NON-NLS-1$ //$NON-NLS-2$
-             "ObjectValue" }; //$NON-NLS-1$
-         String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, 
-                             DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, 
-                             DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG, 
-                             DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE, 
-                             DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME, 
-                             DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN, 
-                             DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT, 
-                             DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, 
-                             DataTypeManager.DefaultDataTypes.OBJECT };
-        
-        String[] blobElemNames = new String[] {
-            "id", "BlobValue"     //$NON-NLS-1$ //$NON-NLS-2$
-        };
-        String[] blobElemTypes = new String[] {DataTypeManager.DefaultDataTypes.STRING, 
-                             DataTypeManager.DefaultDataTypes.BLOB
-        };
-        
-        List uqt2UpdateAe = createElements(uqt2UpdateA, elemNames, elemTypes);
-        List uqt2UpdateBe = createElements(uqt2UpdateB, elemNames, elemTypes);        
-        List uqt2BlobTablee = createElements(uqt2BlobTable, blobElemNames, blobElemTypes);         
-
-        // Add all objects to the store
-        FakeMetadataStore store = new FakeMetadataStore();
-        store.addObject(uqt2);
-        store.addObject(uqt2UpdateA);     
-        store.addObjects(uqt2UpdateAe);
-        store.addObject(uqt2UpdateB);     
-        store.addObjects(uqt2UpdateBe);
-        store.addObject(uqt2BlobTable);
-        store.addObjects(uqt2BlobTablee);
-        
-        // Create the facade from the store
-        return new FakeMetadataFacade(store);
-    }
-
-    public static FakeMetadataFacade exampleLOB() { 
-        // Create models
-        FakeMetadataObject lib = createPhysicalModel("Blob"); //$NON-NLS-1$
-
-        // Create physical groups
-        FakeMetadataObject library = createPhysicalGroup("LOB_TESTING_ONE", lib, true); //$NON-NLS-1$
-        
-        // Create physical elements
-        String[] elemNames = new String[] { 
-             "CLOB_COLUMN", "BLOB_COLUMN", "KEY_EMULATOR" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-             
-        String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.BLOB, 
-            DataTypeManager.DefaultDataTypes.INTEGER };
-               
-        List libe1 = createElements( library, elemNames, elemTypes, true);
-              
-       // Add all objects to the store
-        FakeMetadataStore store = new FakeMetadataStore();
-        store.addObject(lib);
-        store.addObject(library);     
-        store.addObjects(libe1);
-
-        // Create the facade from the store
-        return new FakeMetadataFacade(store);
-    }
-
-    public static FakeMetadataFacade exampleStream(boolean isStream) { 
-        // Create models
-        FakeMetadataObject lib = createPhysicalModel("Blob");  //$NON-NLS-1$
-
-        // Create physical groups
-        FakeMetadataObject library = null;
-        if (isStream) {
-            library = createPhysicalGroup("STREAMEXAMPLE", lib, true); //$NON-NLS-1$
-        } else {
-            library = createPhysicalGroup("READEREAMPLE", lib, true); //$NON-NLS-1$
-        }
-        // Create physical elements
-        String[] elemNames = new String[] { 
-            "KEY_EMULATOR", "DATA"};  //$NON-NLS-1$ //$NON-NLS-2$
-             
-        String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.OBJECT};
-               
-        List libe1 = createElements( library, elemNames, elemTypes, true);
-              
-       // Add all objects to the store
-        FakeMetadataStore store = new FakeMetadataStore();
-        store.addObject(lib);
-        store.addObject(library);     
-        store.addObjects(libe1);
-
-        // Create the facade from the store
-        return new FakeMetadataFacade(store);
-    }
-
-    public static FakeMetadataFacade exampleBytes() { 
-        // Create models
-        FakeMetadataObject lib = createPhysicalModel("Blob");  //$NON-NLS-1$
-
-        // Create physical groups
-        FakeMetadataObject library = createPhysicalGroup("BYTE_EXAMPLE", lib, true); //$NON-NLS-1$
- 
-        // Create physical elements
-        String[] elemNames = new String[] { 
-            "KEY_EMULATOR", "DATA"};  //$NON-NLS-1$ //$NON-NLS-2$
-             
-        String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.OBJECT};
-               
-        List libe1 = createElements( library, elemNames, elemTypes, true);
-              
-       // Add all objects to the store
-        FakeMetadataStore store = new FakeMetadataStore();
-        store.addObject(lib);
-        store.addObject(library);     
-        store.addObjects(libe1);
-
-        // Create the facade from the store
-        return new FakeMetadataFacade(store);
-    }
-               
-    public static FakeMetadataFacade exampleText() { 
-        // Create models
-        FakeMetadataObject lib = createPhysicalModel("Text"); //$NON-NLS-1$
-
-        // Create physical groups
-        FakeMetadataObject library = createPhysicalGroup("Text.Library", lib, true); //$NON-NLS-1$
-        
-        // Create physical elements
-        String[] elemNames = new String[] { 
-             "ID", "PDate", "Author" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-             
-        String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.DATE, 
-            DataTypeManager.DefaultDataTypes.STRING };
-               
-        List libe1 = createElements( library, elemNames, elemTypes, false);
-              
-       // Add all objects to the store
-        FakeMetadataStore store = new FakeMetadataStore();
-        store.addObject(lib);
-        store.addObject(library);     
-        store.addObjects(libe1);
-
-        // Create the facade from the store
-        return new FakeMetadataFacade(store);
-    }
     
-    public static FakeMetadataFacade exampleXQT() {
-        FakeMetadataStore store = new FakeMetadataStore();
-        FakeMetadataFacade facade = new FakeMetadataFacade(store);
-        
-        // Create models
-        FakeMetadataObject xqt = FakeMetadataFactory.createPhysicalModel("XQT"); //$NON-NLS-1$
-        FakeMetadataObject xqttest = FakeMetadataFactory.createVirtualModel("xqttest");     //$NON-NLS-1$
-
-        // Create physical groups
-        //FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("xqt.data", xqt);
-        FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", xqt); //$NON-NLS-1$
-        
-                
-        // Create physical elements
-        List xqtData = FakeMetadataFactory.createElements(xqtGroup, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        // Create virtual groups
-        QueryNode rsQuery = new QueryNode("xqttest.data", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey=13"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject rs = FakeMetadataFactory.createVirtualGroup("xqttest.data", xqttest, rsQuery); //$NON-NLS-1$
-
-        QueryNode rsQuery2 = new QueryNode("xqttest.data2", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
-        rsQuery2.addBinding("xqttest.data.intNum"); //$NON-NLS-1$
-        FakeMetadataObject rs2 = FakeMetadataFactory.createVirtualGroup("xqttest.data2", xqttest, rsQuery2); //$NON-NLS-1$
-
-        QueryNode rsQuery3 = new QueryNode("xqttest.data3", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
-        rsQuery3.addBinding("xqttest.data2.intNum"); //$NON-NLS-1$
-        FakeMetadataObject rs3 = FakeMetadataFactory.createVirtualGroup("xqttest.data3", xqttest, rsQuery3); //$NON-NLS-1$
-
-        QueryNode rsQuery4 = new QueryNode("xqttest.data4", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
-        rsQuery4.addBinding("xqttest.data.intNum"); //$NON-NLS-1$
-        FakeMetadataObject rs4 = FakeMetadataFactory.createVirtualGroup("xqttest.data4", xqttest, rsQuery4); //$NON-NLS-1$
-
-        QueryNode rsQuery5 = new QueryNode("xqttest.data5", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
-        rsQuery5.addBinding("xqttest.data4.intNum"); //$NON-NLS-1$
-        FakeMetadataObject rs5 = FakeMetadataFactory.createVirtualGroup("xqttest.data5", xqttest, rsQuery5); //$NON-NLS-1$
-
-        QueryNode rsQuery6 = new QueryNode("xqttest.data6", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
-        rsQuery6.addBinding("xqttest.data5.intNum"); //$NON-NLS-1$
-        FakeMetadataObject rs6 = FakeMetadataFactory.createVirtualGroup("xqttest.data6", xqttest, rsQuery6); //$NON-NLS-1$
-
-        
-        QueryNode rsQuery7 = new QueryNode("xqttest.data7", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject rs7 = FakeMetadataFactory.createVirtualGroup("xqttest.data7", xqttest, rsQuery7); //$NON-NLS-1$
-
-        QueryNode rsQuery8 = new QueryNode("xqttest.data8", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey < ?"); //$NON-NLS-1$ //$NON-NLS-2$
-        rsQuery8.addBinding("xqttest.data7.intNum"); //$NON-NLS-1$
-        FakeMetadataObject rs8 = FakeMetadataFactory.createVirtualGroup("xqttest.data8", xqttest, rsQuery8); //$NON-NLS-1$
-
-        // Create virtual elements
-        List rsElements = FakeMetadataFactory.createElements(rs, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        List rsElements2 = FakeMetadataFactory.createElements(rs2, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        List rsElements3 = FakeMetadataFactory.createElements(rs3, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        List rsElements4 = FakeMetadataFactory.createElements(rs4, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        List rsElements5 = FakeMetadataFactory.createElements(rs5, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        List rsElements6 = FakeMetadataFactory.createElements(rs6, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        List rsElements7 = FakeMetadataFactory.createElements(rs7, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        List rsElements8 = FakeMetadataFactory.createElements(rs8, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-
-        FakeMetadataObject doc1 = FakeMetadataFactory.createVirtualGroup("xqttest.doc1", xqttest,   createXQTPlanRecursive_5988()); //$NON-NLS-1$
-        FakeMetadataObject doc1a = FakeMetadataFactory.createVirtualGroup("xqttest.doc1a", xqttest, createXQTPlanRecursive1a_5988()); //$NON-NLS-1$
-//        FakeMetadataObject doc2 = FakeMetadataFactory.createVirtualGroup("xqttest.doc2", xqttest,   createXQTPlanRecursiveSiblings());
-//        FakeMetadataObject doc3 = FakeMetadataFactory.createVirtualGroup("xqttest.doc3", xqttest,   createXQTPlanRecursive3_5988());
-//        FakeMetadataObject doc4 = FakeMetadataFactory.createVirtualGroup("xqttest.doc4", xqttest,   createXQTPlanChoice_6796());
-
-        store.addObject(xqt);
-        store.addObject(xqtGroup);
-        store.addObjects(xqtData);
-
-        store.addObject(xqttest);
-        store.addObject(rs);
-        store.addObject(rs2);
-        store.addObject(rs3);
-        store.addObject(rs4);
-        store.addObject(rs5);
-        store.addObject(rs6);
-        store.addObject(rs7);
-        store.addObject(rs8);
-        store.addObjects(rsElements);
-        store.addObjects(rsElements2);
-        store.addObjects(rsElements3);
-        store.addObjects(rsElements4);
-        store.addObjects(rsElements5);
-        store.addObjects(rsElements6);
-        store.addObjects(rsElements7);
-        store.addObjects(rsElements8);
-
-        store.addObject(doc1);
-        store.addObject(doc1a);
-//        store.addObject(doc2);
-//        store.addObject(doc3);
-//        store.addObject(doc4);
-
-        return facade;                
+    public static TransformationMetadata exampleBQT() { 
+    	return RealMetadataFactory.exampleBQT();
     }
 
-    public static FakeMetadataFacade exampleXQT1() {
-        FakeMetadataStore store = new FakeMetadataStore();
-        FakeMetadataFacade facade = new FakeMetadataFacade(store);
-        
-        // Create models
-        FakeMetadataObject xqt = FakeMetadataFactory.createPhysicalModel("XQT"); //$NON-NLS-1$
-        FakeMetadataObject xqttest = FakeMetadataFactory.createVirtualModel("xqttest");     //$NON-NLS-1$
-
-        // Create physical groups
-        //FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("xqt.data", xqt);
-        FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", xqt); //$NON-NLS-1$
-                      
-        // Create physical elements
-        List xqtData = FakeMetadataFactory.createElements(xqtGroup, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        // Create virtual groups
-        QueryNode rsQuery = new QueryNode("xqttest.data", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey=13"); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject rs = FakeMetadataFactory.createVirtualGroup("xqttest.data", xqttest, rsQuery); //$NON-NLS-1$
-
-        // Create virtual elements
-        List rsElements = FakeMetadataFactory.createElements(rs, 
-            new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-        FakeMetadataObject doc1 = FakeMetadataFactory.createVirtualGroup("xqttest.doc1", xqttest,   createBQTDocTest_Plan()); //$NON-NLS-1$
-
-        store.addObject(xqt);
-        store.addObject(xqtGroup);
-        store.addObjects(xqtData);
-
-        store.addObject(xqttest);
-        store.addObject(rs);
-        store.addObjects(rsElements);
-        store.addObject(doc1);
-
-        return facade;                
-    }
-    
-    /**
-     * Method createXQTPlanRecursive.
-     * @return Object
-     */
-    private static MappingDocument createXQTPlanRecursive_5988() {
-        MappingDocument doc = new MappingDocument(true);
-        MappingElement root = doc.addChildElement(new MappingElement("recursiveTest")); //$NON-NLS-1$
-
-        MappingElement src1 = root.addChildElement(new MappingElement("src")); //$NON-NLS-1$
-        src1.setSource("xqttest.data");//$NON-NLS-1$
-
-        MappingSequenceNode seq1 = src1.addSequenceNode(new MappingSequenceNode());
-        seq1.addChildElement(new MappingElement("key", "xqttest.data.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
-        seq1.addChildElement(new MappingElement("data", "xqttest.data.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
-        MappingElement src2 = seq1.addChildElement(new MappingElement("srcNested")); //$NON-NLS-1$
-        src2.setSource("xqttest.data2");//$NON-NLS-1$
-
-        MappingSequenceNode seq2 = src2.addSequenceNode(new MappingSequenceNode());
-        seq2.addChildElement(new MappingElement("key", "xqttest.data2.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
-        seq2.addChildElement(new MappingElement("data", "xqttest.data2.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-        
-        MappingElement recursive = seq2.addChildElement(new MappingRecursiveElement("srcNestedRecursive", "xqttest.data2")); //$NON-NLS-1$ //$NON-NLS-2$
-        recursive.setSource("xqttest.data3");//$NON-NLS-1$
-                
-        return doc;
-    }
-        
-    /**
-     * Method createXQTPlanRecursive.
-     * @return Object
-     */
-    private static MappingDocument createXQTPlanRecursive1a_5988() {
-        
-        MappingDocument doc = new MappingDocument(true);
-        MappingElement root = doc.addChildElement(new MappingElement("recursiveTest")); //$NON-NLS-1$
-
-        MappingElement src1 = root.addChildElement(new MappingElement("src")); //$NON-NLS-1$
-        src1.setSource("xqttest.data");//$NON-NLS-1$
-
-        MappingSequenceNode seq1 = src1.addSequenceNode(new MappingSequenceNode());
-        seq1.addChildElement(new MappingElement("key", "xqttest.data.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
-        seq1.addChildElement(new MappingElement("data", "xqttest.data.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
-        MappingElement src2 = seq1.addChildElement(new MappingElement("srcNested")); //$NON-NLS-1$
-        src2.setSource("xqttest.data2");//$NON-NLS-1$
-
-        MappingSequenceNode seq2 = src2.addSequenceNode(new MappingSequenceNode());
-        seq2.addChildElement(new MappingElement("key", "xqttest.data2.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
-        seq2.addChildElement(new MappingElement("data", "xqttest.data2.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
-        MappingElement recursive = seq2.addChildElement(new MappingRecursiveElement("srcRecursive", "xqttest.data2")); //$NON-NLS-1$ //$NON-NLS-2$
-        recursive.setSource("xqttest.data3");//$NON-NLS-1$  
-
-        //          was not being used
-//        MappingRecursiveElement src4 = new MappingRecursiveElement("srcRecursive", "xqttest.data"); //$NON-NLS-1$ //$NON-NLS-2$
-//        src4.setSource("xqttest.data4"); //$NON-NLS-1$
-        return doc;
-    }
-
-    /**
-     * Method createXQTPlanRecursive.
-     * @return Object
-     */
-    private static MappingDocument createBQTDocTest_Plan() {
-        MappingDocument doc = new MappingDocument(false);
-        MappingElement root = doc.addChildElement(new MappingElement("BQTDocTest")); //$NON-NLS-1$
-        
-        MappingElement src1 = root.addChildElement(new MappingElement("src")); //$NON-NLS-1$
-        src1.setSource("xqttest.data");//$NON-NLS-1$ 
-
-        MappingSequenceNode seq1 = src1.addSequenceNode(new MappingSequenceNode());
-        seq1.addChildElement(new MappingElement("key", "xqttest.data.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
-        seq1.addChildElement(new MappingElement("data", "xqttest.data.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-        return doc;
-    }
-
     public static FakeMetadataFacade exampleSymphony() { 
         // Create models
         FakeMetadataObject model = createPhysicalModel("COMPLEX"); //$NON-NLS-1$
@@ -2750,489 +2169,6 @@
         return new FakeMetadataFacade(store);
     }       
 
-    public static FakeMetadataFacade exampleSystemPhysical() { 
-        // Create models
-        FakeMetadataObject systemPhysical = createPhysicalModel("SystemPhysical"); //$NON-NLS-1$
-        
-        // Create physical groups
-        FakeMetadataObject rtVirtualDbs = createPhysicalGroup("SystemPhysical.RT_VIRTUAL_DBS", systemPhysical); //$NON-NLS-1$
-        List rtVirtualDbsEl = createElements(rtVirtualDbs, 
-            new String[] { 
-                "VDB_UID", //$NON-NLS-1$
-                "VDB_VERSION", //$NON-NLS-1$
-                "VDB_NM", //$NON-NLS-1$
-                "DESCRIPTION", //$NON-NLS-1$
-                "PROJECT_GUID", //$NON-NLS-1$
-                "VDB_STATUS", //$NON-NLS-1$
-                "VERSION_BY", //$NON-NLS-1$
-                "VERSION_DATE", //$NON-NLS-1$
-                "CREATED_BY", //$NON-NLS-1$
-                "CREATED_DATE" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING });
-                
-        FakeMetadataObject rtVdbMdls = createPhysicalGroup("SystemPhysical.RT_VDB_MDLS", systemPhysical); //$NON-NLS-1$
-        List rtVdbMdlsEl = createElements(rtVdbMdls, 
-            new String[] { 
-                "VDB_UID", //$NON-NLS-1$
-                "MDL_UID", //$NON-NLS-1$
-                "CNCTR_BNDNG_NM", //$NON-NLS-1$
-                "VISIBILITY" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER });
-                
-        FakeMetadataObject rtMdls = createPhysicalGroup("SystemPhysical.RT_MDLS", systemPhysical); //$NON-NLS-1$
-        List rtMdlsEl = createElements(rtMdls, 
-            new String[] { 
-                "MDL_UID", //$NON-NLS-1$
-                "MDL_NM", //$NON-NLS-1$
-                "MDL_VERSION", //$NON-NLS-1$
-                "DESCRIPTION", //$NON-NLS-1$
-                "IS_PHYSICAL", //$NON-NLS-1$
-                "SUP_AND", //$NON-NLS-1$
-                "SUP_OR", //$NON-NLS-1$
-                "SUP_SET", //$NON-NLS-1$
-                "SUP_AGGREGATE", //$NON-NLS-1$
-                "SUP_WHERE_ALL", //$NON-NLS-1$
-                "SUP_SELECT_ALL", //$NON-NLS-1$
-                "SUP_ORDER_BY", //$NON-NLS-1$
-                "SUP_GRP_BY", //$NON-NLS-1$
-                "SUP_JOIN", //$NON-NLS-1$
-                "SUP_DISTINCT", //$NON-NLS-1$
-                "SUP_OUTER_JOIN", //$NON-NLS-1$
-                "SUP_TRANSACTION", //$NON-NLS-1$
-                "SUP_SUBSCRIPTION", //$NON-NLS-1$
-                "MAX_SET_SIZE", //$NON-NLS-1$
-                "MAX_RESULT_SIZE", //$NON-NLS-1$
-                "MDL_UUID" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING });
-
-        FakeMetadataObject rtGrps = createPhysicalGroup("SystemPhysical.RT_GRPS", systemPhysical); //$NON-NLS-1$
-        List rtGrpsEl = createElements(rtGrps, 
-            new String[] { 
-                "GRP_UID", //$NON-NLS-1$
-                "GRP_NM", //$NON-NLS-1$
-                "GRP_UPPR_NM", //$NON-NLS-1$
-                "MDL_UID", //$NON-NLS-1$
-                "DESCRIPTION", //$NON-NLS-1$
-                "ALIAS", //$NON-NLS-1$
-                "PATH_1", //$NON-NLS-1$
-                "TABLE_TYPE", //$NON-NLS-1$
-                "IS_PHYSICAL", //$NON-NLS-1$
-                "HAS_QUERY_PLAN", //$NON-NLS-1$
-                "SUP_UPDATE" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN });
-
-        FakeMetadataObject rtTableTypes = createPhysicalGroup("SystemPhysical.RT_TABLE_TYPES", systemPhysical); //$NON-NLS-1$
-        List rtTableTypesEl = createElements(rtTableTypes, 
-            new String[] { 
-                "TABLE_TYPE_CODE", //$NON-NLS-1$
-                "TABLE_TYPE_NM", //$NON-NLS-1$
-                "DESCRIPTION" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING });
-
-        FakeMetadataObject rtKyIdxes = createPhysicalGroup("SystemPhysical.RT_KY_IDXES", systemPhysical); //$NON-NLS-1$
-        List rtKyIdxesEl = createElements(rtKyIdxes, 
-            new String[] { 
-                "KEY_UID", //$NON-NLS-1$
-                "GRP_UID", //$NON-NLS-1$
-                "KEY_NM", //$NON-NLS-1$
-                "DESCRIPTION", //$NON-NLS-1$
-                "ALIAS", //$NON-NLS-1$
-                "KEY_TYPE", //$NON-NLS-1$
-                "IS_INDEXED", //$NON-NLS-1$
-                "REF_KEY_UID", //$NON-NLS-1$
-                "MATCH_TYPE" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER });
-
-        FakeMetadataObject rtKeyTypes = createPhysicalGroup("SystemPhysical.RT_KEY_TYPES", systemPhysical); //$NON-NLS-1$
-        List rtKeyTypesEl = createElements(rtKeyTypes, 
-            new String[] { 
-                "KEY_TYPE_CODE", //$NON-NLS-1$
-                "KEY_TYPE_NM", //$NON-NLS-1$
-                "DESCRIPTION" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING });
-
-        FakeMetadataObject rtKyIdxElmnts = createPhysicalGroup("SystemPhysical.RT_KY_IDX_ELMNTS", systemPhysical); //$NON-NLS-1$
-        List rtKyIdxElmntsEl = createElements(rtKyIdxElmnts, 
-            new String[] { 
-                "ELMNT_UID", //$NON-NLS-1$
-                "KEY_UID", //$NON-NLS-1$
-                "POSITION" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER });
-
-        FakeMetadataObject rtElmnts = createPhysicalGroup("SystemPhysical.RT_ELMNTS", systemPhysical); //$NON-NLS-1$
-        List rtElmntsEl = createElements(rtElmnts, 
-            new String[] { 
-                "ELMNT_UID", //$NON-NLS-1$
-                "ELMNT_NM", //$NON-NLS-1$
-                "ELMNT_UPPR_NM", //$NON-NLS-1$
-                "POSITION", //$NON-NLS-1$
-                "GRP_UID", //$NON-NLS-1$
-                "DESCRIPTION", //$NON-NLS-1$
-                "ALIAS", //$NON-NLS-1$
-                "LABEL", //$NON-NLS-1$
-                "DT_UID", //$NON-NLS-1$
-                "SCALE", //$NON-NLS-1$
-                "LNGTH", //$NON-NLS-1$
-                "PRCSN_LNGTH", //$NON-NLS-1$
-                "RADIX", //$NON-NLS-1$
-                "CHR_OCTCT_LNGTH", //$NON-NLS-1$
-                "IS_PHYSICAL", //$NON-NLS-1$
-                "IS_LENGTH_FIXED", //$NON-NLS-1$
-                "NULL_TYPE", //$NON-NLS-1$
-                "SUP_SELECT", //$NON-NLS-1$
-                "SUP_SET", //$NON-NLS-1$
-                "SUP_SUBSCRIPTION", //$NON-NLS-1$
-                "SUP_UPDATE", //$NON-NLS-1$
-                "IS_CASE_SENSITIVE", //$NON-NLS-1$
-                "IS_SIGNED", //$NON-NLS-1$
-                "IS_CURRENCY", //$NON-NLS-1$
-                "IS_AUTOINCREMENT", //$NON-NLS-1$
-                "MIN_RANGE", //$NON-NLS-1$
-                "MAX_RANGE", //$NON-NLS-1$
-                "SEARCH_TYPE", //$NON-NLS-1$
-                "FORMAT", //$NON-NLS-1$
-                "MULTIPLICITY", //$NON-NLS-1$
-                "DEFAULT_VL" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING });
-
-        // Create virtual groups
-        FakeMetadataObject system = createVirtualModel("System");        //$NON-NLS-1$
-        QueryNode node = new QueryNode("System.Models",  //$NON-NLS-1$
-            "SELECT RT_VIRTUAL_DBS.VDB_NM AS VDBName, RT_VIRTUAL_DBS.VDB_VERSION AS VDBVersion, RT_MDLS.MDL_NM AS Name, RT_MDLS.MDL_VERSION AS Version, RT_MDLS.DESCRIPTION, RT_MDLS.IS_PHYSICAL AS IsPhysical, RT_MDLS.SUP_AND AS SupportsAnd, RT_MDLS.SUP_OR AS SupportsOr, RT_MDLS.SUP_SET AS SupportsSetCriteria, RT_MDLS.SUP_AGGREGATE AS SupportsAggregates, RT_MDLS.SUP_WHERE_ALL AS SupportsWhereAll, RT_MDLS.SUP_SELECT_ALL AS SupportsSelectAll, RT_MDLS.SUP_ORDER_BY AS SupportsOrderBy, RT_MDLS.SUP_GRP_BY AS SupportsGroupBy, RT_MDLS.SUP_JOIN AS SupportsJoin, RT_MDLS.SUP_DISTINCT AS SupportsDistinct, RT_MDLS.SUP_OUTER_JOIN AS SupportsOuterJoin, RT_MDLS.SUP_TRANSACTION AS SupportsTransactions, RT_MDLS.SUP_SUBSCRIPTION AS SupportsSubscriptions, RT_MDLS.MAX_SET_SIZE AS MaxSetSize, RT_MDLS.MAX_RESULT_SIZE AS MaxResultSize, RT_MDLS.MDL_UID AS UID, RT_VIRTUAL_DBS.VDB_UID AS VDBUID " + //$NON-NLS-1$
-            "FROM SystemPhysical.RT_VIRTUAL_DBS AS RT_VIRTUAL_DBS, SystemPhysical.RT_VDB_MDLS AS RT_VDB_MDLS, SystemPhysical.RT_MDLS AS RT_MDLS " +           //$NON-NLS-1$
-            "WHERE (RT_VIRTUAL_DBS.VDB_UID = RT_VDB_MDLS.VDB_UID) AND (RT_VDB_MDLS.MDL_UID = RT_MDLS.MDL_UID) AND (RT_VDB_MDLS.VISIBILITY = 0)"); //$NON-NLS-1$
-        FakeMetadataObject models = createVirtualGroup("System.Models", system, node); //$NON-NLS-1$
-        List modelsEl = createElements(models, 
-            new String[] { 
-                "VDBName", //$NON-NLS-1$
-                "VDBVersion", //$NON-NLS-1$
-                "Name",  //$NON-NLS-1$
-                "Version", //$NON-NLS-1$
-                "Description", //$NON-NLS-1$
-                "IsPhysical", //$NON-NLS-1$
-                "SupportsAnd", //$NON-NLS-1$
-                "SupportsOr", //$NON-NLS-1$
-                "SupportsSetCriteria", //$NON-NLS-1$
-                "SupportsAggregates", //$NON-NLS-1$
-                "SupportsWhereAll", //$NON-NLS-1$
-                "SupportsSelectAll", //$NON-NLS-1$
-                "SupportsOrderBy", //$NON-NLS-1$
-                "SupportsGroupBy", //$NON-NLS-1$
-                "SupportsJoin", //$NON-NLS-1$
-                "SupportsDistinct", //$NON-NLS-1$
-                "SupportsOuterJoin", //$NON-NLS-1$
-                "SupportsTransactions", //$NON-NLS-1$
-                "SupportsSubscriptions", //$NON-NLS-1$
-                "MaxSetSize", //$NON-NLS-1$
-                "MaxResultSize", //$NON-NLS-1$
-                "UID", //$NON-NLS-1$
-                "VDBUID" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER });
-        
-        node = new QueryNode("System.Groups",  //$NON-NLS-1$
-            "SELECT Models.VDBName, Models.VDBVersion, Models.Name AS ModelName, RT_GRPS.PATH_1 AS FullName, RT_GRPS.GRP_NM AS Name, RT_GRPS.DESCRIPTION, RT_TABLE_TYPES.TABLE_TYPE_NM AS Type, RT_GRPS.ALIAS AS NameInSource, RT_GRPS.IS_PHYSICAL AS IsPhysical, RT_GRPS.HAS_QUERY_PLAN AS HasQueryPlan, RT_GRPS.GRP_UPPR_NM AS UpperName, RT_GRPS.SUP_UPDATE AS SupportsUpdates, RT_GRPS.GRP_UID AS UID " + //$NON-NLS-1$
-            "FROM SystemPhysical.RT_GRPS AS RT_GRPS, System.Models AS Models, SystemPhysical.RT_TABLE_TYPES AS RT_TABLE_TYPES " + //$NON-NLS-1$
-            "WHERE (RT_GRPS.MDL_UID = Models.UID) AND (RT_GRPS.TABLE_TYPE = RT_TABLE_TYPES.TABLE_TYPE_CODE) AND (RT_GRPS.TABLE_TYPE <> 5)"); //$NON-NLS-1$
-        FakeMetadataObject groups = createVirtualGroup("System.Groups", system, node); //$NON-NLS-1$
-        List groupsEl = createElements(groups, 
-            new String[] { 
-                "VDBName", //$NON-NLS-1$
-                "VDBVersion", //$NON-NLS-1$
-                "ModelName",  //$NON-NLS-1$
-                "FullName", //$NON-NLS-1$
-                "Name", //$NON-NLS-1$
-                "Description", //$NON-NLS-1$
-                "Type", //$NON-NLS-1$
-                "NameInSource", //$NON-NLS-1$
-                "IsPhysical", //$NON-NLS-1$
-                "HasQueryPlan", //$NON-NLS-1$
-                "UpperName", //$NON-NLS-1$
-                "SupportsUpdates", //$NON-NLS-1$
-                "UID" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.INTEGER });
-
-        node = new QueryNode("System.Keys",  //$NON-NLS-1$
-            "SELECT GROUPS.VDBName, GROUPS.VDBVersion, GROUPS.ModelName, GROUPS.FullName AS GroupFullName, RT_KY_IDXES.KEY_NM AS Name, RT_KY_IDXES.DESCRIPTION, RT_KY_IDXES.ALIAS AS NameInSource, RT_KEY_TYPES.KEY_TYPE_NM AS Type, RT_KY_IDXES.IS_INDEXED AS IsIndexed, RT_KY_IDXES.MATCH_TYPE AS MatchType, GROUPS.Name AS GroupName, GROUPS.UpperName AS GroupUpperName, RT_KY_IDXES.REF_KEY_UID AS RefKeyUID, RT_KY_IDXES.KEY_UID AS UID " + //$NON-NLS-1$
-            "FROM SystemPhysical.RT_KY_IDXES AS RT_KY_IDXES, System.Groups AS GROUPS, SystemPhysical.RT_KEY_TYPES AS RT_KEY_TYPES " + //$NON-NLS-1$
-            "WHERE (RT_KY_IDXES.GRP_UID = GROUPS.UID) AND (RT_KY_IDXES.KEY_TYPE = RT_KEY_TYPES.KEY_TYPE_CODE)"); //$NON-NLS-1$
-        FakeMetadataObject keys = createVirtualGroup("System.Keys", system, node); //$NON-NLS-1$
-        List keysEl = createElements(keys, 
-            new String[] { 
-                "VDBName", //$NON-NLS-1$
-                "VDBVersion", //$NON-NLS-1$
-                "ModelName",  //$NON-NLS-1$
-                "GroupFullName", //$NON-NLS-1$
-                "Name", //$NON-NLS-1$
-                "Description", //$NON-NLS-1$
-                "NameInSource", //$NON-NLS-1$
-                "Type", //$NON-NLS-1$
-                "IsIndexed", //$NON-NLS-1$
-                "MatchType", //$NON-NLS-1$
-                "GroupName", //$NON-NLS-1$
-                "GroupUpperName", //$NON-NLS-1$
-                "RefKeyUID", //$NON-NLS-1$
-                "UID" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.BOOLEAN,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER });
-
-        node = new QueryNode("System.KeyElements",  //$NON-NLS-1$
-            "SELECT KEYS.VDBName, KEYS.VDBVersion, KEYS.ModelName, KEYS.GroupFullName, RT_ELMNTS.ELMNT_NM AS Name, RT_KY_IDX_ELMNTS.POSITION, KEYS.Name AS KeyName, KEYS.Type AS KeyType, KEYS.GroupName, KEYS.GroupUpperName, KEYS.RefKeyUID, KEYS.UID " + //$NON-NLS-1$
-            "FROM System.Keys AS KEYS LEFT OUTER JOIN SystemPhysical.RT_KY_IDX_ELMNTS AS RT_KY_IDX_ELMNTS ON RT_KY_IDX_ELMNTS.KEY_UID = KEYS.UID, SystemPhysical.RT_ELMNTS AS RT_ELMNTS " + //$NON-NLS-1$
-            "WHERE RT_KY_IDX_ELMNTS.ELMNT_UID = RT_ELMNTS.ELMNT_UID"); //$NON-NLS-1$
-        FakeMetadataObject keyElements = createVirtualGroup("System.KeyElements", system, node); //$NON-NLS-1$
-        List keyElementsEl = createElements(keyElements, 
-            new String[] { 
-                "VDBName", //$NON-NLS-1$
-                "VDBVersion", //$NON-NLS-1$
-                "ModelName",  //$NON-NLS-1$
-                "GroupFullName", //$NON-NLS-1$
-                "Name", //$NON-NLS-1$
-                "Position", //$NON-NLS-1$
-                "KeyName", //$NON-NLS-1$
-                "KeyType", //$NON-NLS-1$
-                "GroupName", //$NON-NLS-1$
-                "GroupUpperName", //$NON-NLS-1$
-                "RefKeyUID", //$NON-NLS-1$
-                "UID" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.INTEGER });
-
-        node = new QueryNode("System.ReferenceKeyElements",  //$NON-NLS-1$
-            "SELECT PK.VDBName, PK.VDBVersion, PK.ModelName, PK.GroupName AS PKGroupName, PK.GroupFullName AS PKGroupFullName, PK.Name AS PKElementName, FK.ModelName AS FKModelName, FK.GroupName AS FKGroupName, FK.GroupFullName AS FKGroupFullName, FK.Name AS FKElementName, FK.Position AS FKPosition, PK.KeyName AS PKKeyName, FK.KeyName AS FKKeyName, PK.KeyType AS PKKeyType, FK.KeyType AS FKKeyType, PK.GroupUpperName AS PKGroupUpperName, FK.GroupUpperName AS FKGroupUpperName " + //$NON-NLS-1$
-            "FROM System.KeyElements AS PK, System.KeyElements AS FK " + //$NON-NLS-1$
-            "WHERE (PK.UID = FK.RefKeyUID) AND (PK.Position = FK.Position)"); //$NON-NLS-1$
-        FakeMetadataObject refKeyElements = createVirtualGroup("System.ReferenceKeyElements", system, node); //$NON-NLS-1$
-        List refKeyElementsEl = createElements(refKeyElements, 
-            new String[] { 
-                "VDBName", //$NON-NLS-1$
-                "VDBVersion", //$NON-NLS-1$
-                "ModelName",  //$NON-NLS-1$
-                "PKGroupName", //$NON-NLS-1$
-                "PKGroupFullName", //$NON-NLS-1$
-                "PKElementName", //$NON-NLS-1$
-                "FKModelName",  //$NON-NLS-1$
-                "FKGroupName", //$NON-NLS-1$
-                "FKGroupFullName", //$NON-NLS-1$
-                "FKElementName", //$NON-NLS-1$
-                "FKPosition", //$NON-NLS-1$
-                "PKKeyName", //$NON-NLS-1$
-                "FKKeyName", //$NON-NLS-1$
-                "PKKeyType", //$NON-NLS-1$
-                "FKKeyType", //$NON-NLS-1$
-                "PKGroupUpperName", //$NON-NLS-1$
-                "FKGroupUpperName" }, //$NON-NLS-1$
-            new String[] { 
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.INTEGER,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING,
-                DataTypeManager.DefaultDataTypes.STRING });
-                
-        // Add all objects to the store
-        FakeMetadataStore store = new FakeMetadataStore();
-        store.addObject(systemPhysical);
-        store.addObject(rtVirtualDbs);     
-        store.addObjects(rtVirtualDbsEl);
-        store.addObject(rtVdbMdls);
-        store.addObjects(rtVdbMdlsEl);
-        store.addObject(rtMdls);     
-        store.addObjects(rtMdlsEl);
-        store.addObject(rtGrps);
-        store.addObjects(rtGrpsEl);
-        store.addObject(rtTableTypes);     
-        store.addObjects(rtTableTypesEl);
-        store.addObject(rtKyIdxes);
-        store.addObjects(rtKyIdxesEl);
-        store.addObject(rtKeyTypes);
-        store.addObjects(rtKeyTypesEl);
-        store.addObject(rtKyIdxElmnts);
-        store.addObjects(rtKyIdxElmntsEl);
-        store.addObject(rtElmnts);
-        store.addObjects(rtElmntsEl);
-
-        store.addObject(system);
-        store.addObject(models);
-        store.addObjects(modelsEl);
-        store.addObject(groups);
-        store.addObjects(groupsEl);
-        store.addObject(keys);
-        store.addObjects(keysEl);
-        store.addObject(keyElements);
-        store.addObjects(keyElementsEl);
-        store.addObject(refKeyElements);
-        store.addObjects(refKeyElementsEl);
-
-        // Create the facade from the store
-        return new FakeMetadataFacade(store);
-    }    
-        
     public static FakeMetadataFacade exampleYahoo() { 
         // Create models
         FakeMetadataObject yahoo = createPhysicalModel("Yahoo"); //$NON-NLS-1$
@@ -3367,6 +2303,19 @@
         return new FakeMetadataFacade(store);
     }
     
+    
+    public static VDBMetaData examplePrivatePhysicalModelVDB() {
+    	VDBMetaData vdb = new VDBMetaData();
+    	vdb.setName("example1");
+    	vdb.setVersion(1);
+    	ModelMetaData m = createModel("pm1", true);
+    	m.setVisible(false);
+    	vdb.addModel(m);
+    	vdb.addModel(createModel("vm1", false));
+    	
+    	return vdb;
+    }    
+    
     public static FakeMetadataFacade examplePrivatePhysicalModel() { 
         // Create models
         FakeMetadataObject pm1 = createPhysicalModel("pm1"); //$NON-NLS-1$
@@ -3577,6 +2526,24 @@
         store.addObjects(dealersElements);
     }
     
+    
+    public static VDBMetaData exampleMultiBindingVDB() {
+    	VDBMetaData vdb = new VDBMetaData();
+    	vdb.setName("exampleMultiBinding");
+    	vdb.setVersion(1);
+    	
+    	ModelMetaData model = new ModelMetaData();
+    	model.setName("MultiModel");
+   		model.setModelType(ModelType.getString(ModelType.PHYSICAL));
+    	model.setVisible(true);
+    	
+    	model.setSupportsMultiSourceBindings(true);
+    	vdb.addModel(model);
+    	vdb.addModel(createModel("Virt", false));
+    	
+    	return vdb;
+    }
+    
     /** 
      * Metadata for Multi-Binding models
      * @return example
@@ -3931,6 +2898,14 @@
         return facade;
     }    
     
+    public static VDBMetaData exampleXQueryTransformationsVDB() {
+    	VDBMetaData vdb = new VDBMetaData();
+    	vdb.setName("exampleXQueryTransformations");
+    	vdb.setVersion(1);
+    	vdb.addModel(createModel("m", true));
+    	return vdb;
+    }
+    
     public static FakeMetadataFacade exampleXQueryTransformations() {
         FakeMetadataObject model = FakeMetadataFactory.createPhysicalModel("m");//$NON-NLS-1$ 
        

Copied: trunk/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java (from rev 1900, branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java	                        (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,554 @@
+/*
+ * 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.unittest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.ColumnSet;
+import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.connector.metadata.runtime.Procedure;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
+import org.teiid.connector.metadata.runtime.Schema;
+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.connector.metadata.runtime.ProcedureParameter.Type;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
+
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.dqp.message.ParameterInfo;
+import com.metamatrix.query.mapping.relational.QueryNode;
+import com.metamatrix.query.sql.lang.SPParameter;
+
+public class RealMetadataFactory {
+
+    private static TransformationMetadata CACHED_BQT = exampleBQT();
+        
+	private RealMetadataFactory() { }
+	
+    public static TransformationMetadata exampleBQTCached() {
+        return CACHED_BQT;
+    }
+    
+    public static TransformationMetadata exampleBQT() {
+    	MetadataStore metadataStore = new MetadataStore();
+    	
+        Schema bqt1 = createPhysicalModel("BQT1", metadataStore); //$NON-NLS-1$
+        Schema bqt2 = createPhysicalModel("BQT2", metadataStore); //$NON-NLS-1$
+        Schema bqt3 = createPhysicalModel("BQT3", metadataStore); //$NON-NLS-1$
+        Schema lob = createPhysicalModel("LOB", metadataStore); //$NON-NLS-1$
+        Schema vqt = createVirtualModel("VQT", metadataStore); //$NON-NLS-1$
+        Schema bvqt = createVirtualModel("BQT_V", metadataStore); //$NON-NLS-1$
+        Schema bvqt2 = createVirtualModel("BQT2_V", metadataStore); //$NON-NLS-1$
+        
+        // Create physical groups
+        Table bqt1SmallA = createPhysicalGroup("SmallA", bqt1); //$NON-NLS-1$
+        Table bqt1SmallB = createPhysicalGroup("SmallB", bqt1); //$NON-NLS-1$
+        Table bqt1MediumA = createPhysicalGroup("MediumA", bqt1); //$NON-NLS-1$
+        Table bqt1MediumB = createPhysicalGroup("MediumB", bqt1); //$NON-NLS-1$
+        Table bqt2SmallA = createPhysicalGroup("SmallA", bqt2); //$NON-NLS-1$
+        Table bqt2SmallB = createPhysicalGroup("SmallB", bqt2); //$NON-NLS-1$
+        Table bqt2MediumA = createPhysicalGroup("MediumA", bqt2); //$NON-NLS-1$
+        Table bqt2MediumB = createPhysicalGroup("MediumB", bqt2); //$NON-NLS-1$
+        Table bqt3SmallA = createPhysicalGroup("SmallA", bqt3); //$NON-NLS-1$
+        Table bqt3SmallB = createPhysicalGroup("SmallB", bqt3); //$NON-NLS-1$
+        Table bqt3MediumA = createPhysicalGroup("MediumA", bqt3); //$NON-NLS-1$
+        Table bqt3MediumB = createPhysicalGroup("MediumB", bqt3); //$NON-NLS-1$
+        Table lobTable = createPhysicalGroup("LobTbl", lob); //$NON-NLS-1$
+        Table library = createPhysicalGroup("LOB_TESTING_ONE", lob); //$NON-NLS-1$
+        
+        createElements( library, new String[] { "CLOB_COLUMN", "BLOB_COLUMN", "KEY_EMULATOR" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        		new String[] { DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.BLOB, DataTypeManager.DefaultDataTypes.INTEGER }); 
+
+        // Create virtual groups
+        QueryNode vqtn1 = new QueryNode("VQT.SmallA", "SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg1 = createUpdatableVirtualGroup("SmallA", vqt, vqtn1); //$NON-NLS-1$
+        
+        QueryNode vqtn2 = new QueryNode("VQT.SmallB", "SELECT Concat(stringKey, stringNum) as a12345 FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2 = createUpdatableVirtualGroup("SmallB", vqt, vqtn2); //$NON-NLS-1$        
+
+        // Case 2589
+        QueryNode vqtn2589 = new QueryNode("VQT.SmallA_2589", "SELECT * FROM BQT1.SmallA WHERE StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2589 = createVirtualGroup("SmallA_2589", vqt, vqtn2589); //$NON-NLS-1$
+
+        QueryNode vqtn2589a = new QueryNode("VQT.SmallA_2589a", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.IntKey = SmallB.IntKey WHERE SmallA.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2589a = createVirtualGroup("SmallA_2589a", vqt, vqtn2589a); //$NON-NLS-1$
+
+        QueryNode vqtn2589b = new QueryNode("VQT.SmallA_2589b", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2589b = createVirtualGroup("SmallA_2589b", vqt, vqtn2589b); //$NON-NLS-1$
+
+        QueryNode vqtn2589c = new QueryNode("VQT.SmallA_2589c", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE concat(SmallA.StringNum, SmallB.StringNum) = '1010'"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2589c = createVirtualGroup("SmallA_2589c", vqt, vqtn2589c); //$NON-NLS-1$
+        
+        QueryNode vqtn2589d = new QueryNode("VQT.SmallA_2589d", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10' AND SmallA.IntNum = 10"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2589d = createVirtualGroup("SmallA_2589d", vqt, vqtn2589d); //$NON-NLS-1$
+
+        QueryNode vqtn2589f = new QueryNode("VQT.SmallA_2589f", "SELECT * FROM VQT.SmallA_2589"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2589f = createVirtualGroup("SmallA_2589f", vqt, vqtn2589f); //$NON-NLS-1$
+
+        QueryNode vqtn2589g = new QueryNode("VQT.SmallA_2589g", "SELECT * FROM VQT.SmallA_2589b"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2589g = createVirtualGroup("SmallA_2589g", vqt, vqtn2589g); //$NON-NLS-1$
+
+        QueryNode vqtn2589h = new QueryNode("VQT.SmallA_2589h", "SELECT VQT.SmallA_2589.* FROM VQT.SmallA_2589 INNER JOIN BQT1.SmallB ON VQT.SmallA_2589.StringKey = SmallB.StringKey"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2589h = createVirtualGroup("SmallA_2589h", vqt, vqtn2589h); //$NON-NLS-1$
+        
+        QueryNode vqtn2589i = new QueryNode("VQT.SmallA_2589i", "SELECT BQT1.SmallA.* FROM BQT1.SmallA INNER JOIN BQT1.SmallB ON SmallA.StringKey = SmallB.StringKey WHERE SmallA.StringNum = '10' AND SmallB.StringNum = '10'"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg2589i = createVirtualGroup("SmallA_2589i", vqt, vqtn2589i); //$NON-NLS-1$
+
+        // defect 15355
+        QueryNode vqtn15355  = new QueryNode("VQT.Defect15355", "SELECT convert(IntKey, string) as StringKey, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg15355  = createVirtualGroup("Defect15355", vqt, vqtn15355); //$NON-NLS-1$
+        QueryNode vqtn15355a  = new QueryNode("VQT.Defect15355a", "SELECT StringKey, StringNum, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, StringNum, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg15355a  = createVirtualGroup("Defect15355a", vqt, vqtn15355a); //$NON-NLS-1$
+        QueryNode vqtn15355b  = new QueryNode("VQT.Defect15355b", "SELECT convert(IntKey, string) as IntKey, BigIntegerValue FROM BQT1.SmallA UNION SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table vqtg15355b  = createVirtualGroup("Defect15355b", vqt, vqtn15355b); //$NON-NLS-1$
+        
+        QueryNode bvqtn1 = new QueryNode("BQT_V.BQT_V", "SELECT a.* FROM BQT1.SMALLA AS a WHERE a.INTNUM = (SELECT MIN(b.INTNUM) FROM BQT1.SMALLA AS b WHERE b.INTKEY = a.IntKey ) OPTION MAKEDEP a"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table bvqtg1 = createUpdatableVirtualGroup("BQT_V", bvqt, bvqtn1); //$NON-NLS-1$
+        QueryNode bvqt2n1 = new QueryNode("BQT2_V.BQT2_V", "SELECT BQT2.SmallA.* FROM BQT2.SmallA, BQT_V.BQT_V WHERE BQT2.SmallA.IntKey = BQT_V.BQT_V.IntKey"); //$NON-NLS-1$ //$NON-NLS-2$
+        Table bvqt2g1 = createUpdatableVirtualGroup("BQT2_V", bvqt2, bvqt2n1); //$NON-NLS-1$
+
+     // Create physical elements
+        String[] elemNames = new String[] { 
+             "IntKey", "StringKey",  //$NON-NLS-1$ //$NON-NLS-2$
+             "IntNum", "StringNum",  //$NON-NLS-1$ //$NON-NLS-2$
+             "FloatNum", "LongNum",  //$NON-NLS-1$ //$NON-NLS-2$
+             "DoubleNum", "ByteNum",  //$NON-NLS-1$ //$NON-NLS-2$
+             "DateValue", "TimeValue",  //$NON-NLS-1$ //$NON-NLS-2$
+             "TimestampValue", "BooleanValue",  //$NON-NLS-1$ //$NON-NLS-2$
+             "CharValue", "ShortValue",  //$NON-NLS-1$ //$NON-NLS-2$
+             "BigIntegerValue", "BigDecimalValue",  //$NON-NLS-1$ //$NON-NLS-2$
+             "ObjectValue" }; //$NON-NLS-1$
+         String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, 
+                             DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, 
+                             DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG, 
+                             DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE, 
+                             DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME, 
+                             DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN, 
+                             DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT, 
+                             DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, 
+                             DataTypeManager.DefaultDataTypes.OBJECT };
+        
+        List<Column> bqt1SmallAe = createElements(bqt1SmallA, elemNames, elemTypes);
+        bqt1SmallAe.get(1).setNativeType("char"); //$NON-NLS-1$
+        List bqt1SmallBe = createElements(bqt1SmallB, elemNames, elemTypes);
+        List bqt1MediumAe = createElements(bqt1MediumA, elemNames, elemTypes);
+        List bqt1MediumBe = createElements(bqt1MediumB, elemNames, elemTypes);
+        List bqt2SmallAe = createElements(bqt2SmallA, elemNames, elemTypes);
+        List bqt2SmallBe = createElements(bqt2SmallB, elemNames, elemTypes);
+        List bqt2MediumAe = createElements(bqt2MediumA, elemNames, elemTypes);
+        List bqt2MediumBe = createElements(bqt2MediumB, elemNames, elemTypes);                
+        List bqt3SmallAe = createElements(bqt3SmallA, elemNames, elemTypes);
+        List bqt3SmallBe = createElements(bqt3SmallB, elemNames, elemTypes);
+        List bqt3MediumAe = createElements(bqt3MediumA, elemNames, elemTypes);
+        List bqt3MediumBe = createElements(bqt3MediumB, elemNames, elemTypes);
+        List lobTable_elem = createElements(lobTable, new String[] {"ClobValue"}, new String[] {DataTypeManager.DefaultDataTypes.CLOB}); //$NON-NLS-1$
+        
+        // Create virtual elements
+        List vqtg1e = createElements(vqtg1, elemNames, elemTypes);        
+        List vqtg2e = createElements(vqtg2, new String[] {"a12345"}, new String[] {DataTypeManager.DefaultDataTypes.STRING});  //$NON-NLS-1$
+        List vqtg15355e = createElements(vqtg15355, new String[] {"StringKey", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER});         //$NON-NLS-1$ //$NON-NLS-2$
+        List vqtg15355ae = createElements(vqtg15355a, new String[] {"StringKey", "StringNum", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER});         //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        List vqtg15355be = createElements(vqtg15355b, new String[] {"IntKey", "BigIntegerValue"}, new String[] {DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BIG_INTEGER});         //$NON-NLS-1$ //$NON-NLS-2$
+        List vqtg2589e = createElements(vqtg2589, elemNames, elemTypes);        
+        List vqtg2589ae = createElements(vqtg2589a, elemNames, elemTypes);        
+        List vqtg2589be = createElements(vqtg2589b, elemNames, elemTypes);        
+        List vqtg2589ce = createElements(vqtg2589c, elemNames, elemTypes);        
+        List vqtg2589de = createElements(vqtg2589d, elemNames, elemTypes);        
+        List vqtg2589fe = createElements(vqtg2589f, elemNames, elemTypes);        
+        List vqtg2589ge = createElements(vqtg2589g, elemNames, elemTypes);        
+        List vqtg2589he = createElements(vqtg2589h, elemNames, elemTypes);        
+        List vqtg2589ie = createElements(vqtg2589i, elemNames, elemTypes);
+        List bvqtg1e = createElements(bvqtg1, elemNames, elemTypes);        
+        List bvqt2g1e = createElements(bvqt2g1, elemNames, elemTypes);        
+
+     // Add stored procedure
+        Schema pm1 = createPhysicalModel("pm1", metadataStore); //$NON-NLS-1$
+        ProcedureParameter rs1p1 = createParameter("intkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null);         //$NON-NLS-1$
+        ColumnSet<Procedure> rs1 = createResultSet("rs1", pm1, new String[] { "IntKey", "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        Procedure spTest5 = createStoredProcedure("spTest5", pm1, Arrays.asList(rs1p1), "spTest5"); //$NON-NLS-1$ //$NON-NLS-2$
+        spTest5.setResultSet(rs1);
+
+        Schema pm2 = createPhysicalModel("pm2", metadataStore); //$NON-NLS-1$
+        ProcedureParameter rs2p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+        ProcedureParameter rs2p2 = createParameter("outkey", 3, ParameterInfo.OUT, DataTypeManager.DefaultDataTypes.INTEGER, null);                 //$NON-NLS-1$
+        ColumnSet<Procedure> rs2 = createResultSet("rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        Procedure spTest8 = createStoredProcedure("spTest8", pm2, Arrays.asList(rs2p1, rs2p2), "spTest8"); //$NON-NLS-1$ //$NON-NLS-2$
+        spTest8.setResultSet(rs2);
+        
+        ProcedureParameter rs2p2a = createParameter("outkey", 3, ParameterInfo.OUT, DataTypeManager.DefaultDataTypes.INTEGER, null);                 //$NON-NLS-1$
+        ColumnSet<Procedure> rs2a = createResultSet("rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        Procedure spTest8a = createStoredProcedure("spTest8a", pm2, Arrays.asList(rs2p2a), "spTest8a"); //$NON-NLS-1$ //$NON-NLS-2$
+        spTest8a.setResultSet(rs2a);
+        
+        Schema pm4 = createPhysicalModel("pm4", metadataStore); //$NON-NLS-1$
+        ProcedureParameter rs4p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+        ProcedureParameter rs4p2 = createParameter("ret", 1, ParameterInfo.RETURN_VALUE, DataTypeManager.DefaultDataTypes.INTEGER, null);  //$NON-NLS-1$
+        Procedure spTest9 = createStoredProcedure("spTest9", pm4, Arrays.asList(rs4p1, rs4p2), "spTest9"); //$NON-NLS-1$ //$NON-NLS-2$
+        
+        Schema pm3 = createPhysicalModel("pm3", metadataStore); //$NON-NLS-1$
+        ProcedureParameter rs3p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+        ProcedureParameter rs3p2 = createParameter("outkey", 3, ParameterInfo.INOUT, DataTypeManager.DefaultDataTypes.INTEGER, null);                 //$NON-NLS-1$
+        ColumnSet<Procedure> rs3 = createResultSet("rs3", pm3, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        Procedure spTest11 = createStoredProcedure("spTest11", pm3, Arrays.asList(rs3p1, rs3p2), "spTest11"); //$NON-NLS-1$ //$NON-NLS-2$
+        spTest11.setResultSet(rs3);
+        
+        //add virtual stored procedures 
+        Schema mmspTest1 = createVirtualModel("mmspTest1", metadataStore); //$NON-NLS-1$
+        ColumnSet<Procedure> vsprs1 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+        QueryNode vspqn1 = new QueryNode("vsp1", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
+        Procedure vsp1 = createVirtualProcedure("MMSP1", mmspTest1, null, vspqn1); //$NON-NLS-1$
+        vsp1.setResultSet(vsprs1);
+
+        ColumnSet<Procedure> vsprs2 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+        QueryNode vspqn2 = new QueryNode("vsp2", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor1 BEGIN LOOP ON (SELECT intkey FROM bqt1.smallB) AS intKeyCursor2 BEGIN x= intKeyCursor1.intkey - intKeyCursor2.intkey; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
+        Procedure vsp2 = createVirtualProcedure("MMSP2", mmspTest1, null, vspqn2); //$NON-NLS-1$
+        vsp2.setResultSet(vsprs2);
+
+        ColumnSet<Procedure> vsprs3 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+        QueryNode vspqn3 = new QueryNode("vsp3", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
+        Procedure vsp3 = createVirtualProcedure("MMSP3", mmspTest1, null, vspqn3); //$NON-NLS-1$
+        vsp3.setResultSet(vsprs3);
+
+        ColumnSet<Procedure> vsprs4 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+        QueryNode vspqn4 = new QueryNode("vsp4", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; x=0; WHILE(x < 50) BEGIN x= x + 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
+        Procedure vsp4 = createVirtualProcedure("MMSP4", mmspTest1, null, vspqn4); //$NON-NLS-1$
+        vsp4.setResultSet(vsprs4);
+        
+        ColumnSet<Procedure> vsprs5 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+        ProcedureParameter vsp5p1 = createParameter("param1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
+        QueryNode vspqn5 = new QueryNode("vsp5", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 0; END"); //$NON-NLS-1$ //$NON-NLS-2$
+        Procedure vsp5 = createVirtualProcedure("MMSP5", mmspTest1, Arrays.asList(vsp5p1), vspqn5); //$NON-NLS-1$
+        vsp5.setResultSet(vsprs5);
+
+        ColumnSet<Procedure> vsprs6 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+        ProcedureParameter vsp6p1 = createParameter("p1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
+        QueryNode vspqn6 = new QueryNode("vsp6", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 1; END"); //$NON-NLS-1$ //$NON-NLS-2$
+        Procedure vsp6 = createVirtualProcedure("MMSP6", mmspTest1, Arrays.asList(vsp6p1), vspqn6); //$NON-NLS-1$
+        vsp6.setResultSet(vsprs6);
+    	
+    	CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
+    	VDBMetaData vdbMetaData = new VDBMetaData();
+    	vdbMetaData.setName("bqt"); //$NON-NLS-1$
+    	vdbMetaData.setVersion(1);
+    	for (Schema schema : metadataStore.getSchemas().values()) {
+			vdbMetaData.addModel(FakeMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
+		}
+    	return new TransformationMetadata(vdbMetaData, store, null, null); 
+    }
+
+    /**
+     * Create a physical model with default settings.
+     */
+	public static Schema createPhysicalModel(String name, MetadataStore metadataStore) {
+		Schema schema = new Schema();
+		schema.setName(name);
+		metadataStore.addSchema(schema);
+		return schema;	
+	}
+	
+    /**
+     * Create a virtual model with default settings.
+     */
+	public static Schema createVirtualModel(String name, MetadataStore metadataStore) {
+		Schema schema = new Schema();
+		schema.setName(name);
+		schema.setPhysical(false);
+		metadataStore.addSchema(schema);
+		return schema;	
+	}
+	
+    /**
+     * Create a physical group with default settings.
+     * @param name Name of physical group, must match model name
+     * @param model Associated model
+     * @return FakeMetadataObject Metadata object for group
+     */
+	public static Table createPhysicalGroup(String name, Schema model, boolean fullyQualify) {
+		Table table = new Table();
+		table.setName(name);
+		model.addTable(table);
+		table.setSupportsUpdate(true);
+		table.setNameInSource((fullyQualify || name.lastIndexOf(".") == -1)? name : name.substring(name.lastIndexOf(".") + 1));  //$NON-NLS-1$ //$NON-NLS-2$
+		return table;
+	}
+
+    public static Table createPhysicalGroup(String name, Schema model) {
+    	return createPhysicalGroup(name, model, false);
+    }
+    	
+    /**
+     * Create a virtual group with default settings.
+     */
+	public static Table createVirtualGroup(String name, Schema model, QueryNode plan) {
+        Table table = new Table();
+        table.setName(name);
+        model.addTable(table);
+        table.setVirtual(true);
+        table.setSelectTransformation(plan.getQuery());
+		return table;
+	}
+
+    /**
+     * Create a temp group with default settings.
+     * @param name Name of virtual group, must match model name
+     * @param model Associated model
+     * @param plan Appropriate query plan definition object for the temp group
+     * @return FakeMetadataObject Metadata object for group
+     */
+    public static FakeMetadataObject createTempGroup(String name, FakeMetadataObject model, Object plan) {
+        FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.GROUP);
+        obj.putProperty(FakeMetadataObject.Props.MODEL, model);
+        obj.putProperty(FakeMetadataObject.Props.IS_VIRTUAL, Boolean.FALSE);
+        obj.putProperty(FakeMetadataObject.Props.PLAN, plan);
+        obj.putProperty(FakeMetadataObject.Props.UPDATE, Boolean.FALSE); 
+        obj.putProperty(FakeMetadataObject.Props.TEMP, Boolean.TRUE);  
+        return obj; 
+    }
+	
+    /**
+     * Create a virtual group that allows updates with default settings.
+     */
+	public static Table createUpdatableVirtualGroup(String name, Schema model, QueryNode plan) {
+		return createUpdatableVirtualGroup(name, model, plan, null);
+	}
+    
+    public static Table createUpdatableVirtualGroup(String name, Schema model, QueryNode plan, String updatePlan) {
+        Table table = createVirtualGroup(name, model, plan);
+        table.setUpdatePlan(updatePlan);
+        table.setSupportsUpdate(true);
+        return table;
+    }
+		
+    public static Column createElement(String name, ColumnSet<?> group, String type) { 
+        Column column = new Column();
+        column.setName(name);
+        group.addColumn(column);
+        column.setRuntimeType(type);
+        if(type.equals(DataTypeManager.DefaultDataTypes.STRING)) {  
+            column.setSearchType(SearchType.Searchable);        
+        } else if (DataTypeManager.isNonComparable(type)){
+        	column.setSearchType(SearchType.Unsearchable);
+        } else {        	
+        	column.setSearchType(SearchType.All_Except_Like);
+        }   
+        column.setNullType(NullType.Nullable);
+        column.setPosition(group.getColumns().size()); //1 based indexing
+        column.setUpdatable(true);
+        column.setLength(100);
+        column.setNameInSource(name);
+        return column; 
+    }
+    
+    /**
+     * Create a set of elements in batch 
+     */
+	public static List<Column> createElements(ColumnSet<?> group, String[] names, String[] types) { 
+		return createElementsWithDefaults(group, names, types, new String[names.length]);
+	}
+
+    /**
+     * Create a set of elements in batch 
+     */
+	public static List<Column> createElementsWithDefaults(ColumnSet<?> group, String[] names, String[] types, String[] defaults) {
+		List<Column> elements = new ArrayList<Column>();
+		
+		for(int i=0; i<names.length; i++) { 
+            Column element = createElement(names[i], group, types[i]);
+            element.setDefaultValue(defaults[i]);
+			elements.add(element);		
+		}
+		
+		return elements;
+	}	
+
+    /**
+     * Create index.  The name will be used as the Object metadataID.
+     * @param name String name of index
+     * @param group the group for the index
+     * @param elements the elements of the index (will be used as if they were
+     * metadata IDs)
+     * @return key metadata object
+     */
+    public static FakeMetadataObject createIndex(String name, FakeMetadataObject group, List elements) { 
+        FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.KEY);
+        obj.putProperty(FakeMetadataObject.Props.KEY_TYPE, FakeMetadataObject.TYPE_INDEX);
+        obj.putProperty(FakeMetadataObject.Props.KEY_ELEMENTS, elements);
+        Collection keys = (Collection)group.getProperty(FakeMetadataObject.Props.KEYS);
+        if (keys == null){
+            keys = new ArrayList();
+            group.putProperty(FakeMetadataObject.Props.KEYS, keys);
+        }
+        keys.add(obj);
+        return obj; 
+    }
+
+	/**
+	 * Create primary key.  The name will be used as the Object metadataID.
+	 * @param name String name of key
+	 * @param group the group for the key
+	 * @param elements the elements of the key (will be used as if they were
+	 * metadata IDs)
+	 * @return key metadata object
+	 */
+	public static FakeMetadataObject createKey(String name, FakeMetadataObject group, List elements) { 
+		FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.KEY);
+        obj.putProperty(FakeMetadataObject.Props.KEY_TYPE, FakeMetadataObject.TYPE_PRIMARY_KEY);
+		obj.putProperty(FakeMetadataObject.Props.KEY_ELEMENTS, elements);
+		Collection keys = (Collection)group.getProperty(FakeMetadataObject.Props.KEYS);
+		if (keys == null){
+			keys = new ArrayList();
+			group.putProperty(FakeMetadataObject.Props.KEYS, keys);
+		}
+		keys.add(obj);
+		return obj; 
+	}
+
+    /**
+     * Create foreign key.  The name will be used as the Object metadataID.
+     * @param name String name of key
+     * @param group the group for the key
+     * @param elements the elements of the key (will be used as if they were
+     * @param primaryKey referenced by this foreign key
+     * metadata IDs)
+     * @return key metadata object
+     */
+    public static FakeMetadataObject createForeignKey(String name, FakeMetadataObject group, List elements, FakeMetadataObject primaryKey) { 
+        FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.KEY);
+        obj.putProperty(FakeMetadataObject.Props.KEY_TYPE, FakeMetadataObject.TYPE_FOREIGN_KEY);
+        obj.putProperty(FakeMetadataObject.Props.KEY_ELEMENTS, elements);
+        obj.putProperty(FakeMetadataObject.Props.REFERENCED_KEY, primaryKey);
+        Collection keys = (Collection)group.getProperty(FakeMetadataObject.Props.KEYS);
+        if (keys == null){
+            keys = new ArrayList();
+            group.putProperty(FakeMetadataObject.Props.KEYS, keys);
+        }
+        keys.add(obj);
+        return obj; 
+    }
+
+    /**
+     * Create access pattern (currently an access pattern is implemented as a type of key).  The name will
+     * be used as the Object metadataID.
+     * @param name String name of key
+     * @param group the group for the access pattern
+     * @param elements the elements of the access pattern (will be used as if they were
+     * metadata IDs)
+     * @return Access pattern metadata object
+     */
+    public static FakeMetadataObject createAccessPattern(String name, FakeMetadataObject group, List elements) { 
+        FakeMetadataObject obj = new FakeMetadataObject(name, FakeMetadataObject.KEY);
+        obj.putProperty(FakeMetadataObject.Props.KEY_TYPE, FakeMetadataObject.TYPE_ACCESS_PATTERN);
+        obj.putProperty(FakeMetadataObject.Props.KEY_ELEMENTS, elements);
+        Collection keys = (Collection)group.getProperty(FakeMetadataObject.Props.KEYS);
+        if (keys == null){
+            keys = new ArrayList();
+            group.putProperty(FakeMetadataObject.Props.KEYS, keys);
+        }
+        keys.add(obj);
+        return obj; 
+    }
+    
+    /**
+     * Create stored procedure parameter.
+     */
+    public static ProcedureParameter createParameter(String name, int index, int direction, String type, Object rs) {
+        ProcedureParameter param = new ProcedureParameter();
+        param.setName(name);
+        switch (direction) {
+        case SPParameter.IN:
+        	param.setType(Type.In);
+        	break;
+        case SPParameter.INOUT:
+        	param.setType(Type.InOut);
+        	break;
+        case SPParameter.OUT:
+        	param.setType(Type.Out);
+        	break;
+        case SPParameter.RESULT_SET:
+        	throw new AssertionError("should not directly create a resultset param"); //$NON-NLS-1$
+        case SPParameter.RETURN_VALUE:
+        	param.setType(Type.ReturnValue);
+        	break;
+        }
+        param.setRuntimeType(type);
+        return param;
+    }
+
+    /**
+     * Create stored procedure.
+     * @param name Name of procedure, must match model name
+     * @param model Metadata object for the model
+     * @param params List of FakeMetadataObject that are the parameters for the procedure
+     * @param callableName Callable name of procedure, usually same as procedure name
+     * @return Metadata object for stored procedure
+     */
+    public static Procedure createStoredProcedure(String name, Schema model, List<ProcedureParameter> params, String callableName) {
+    	Procedure proc = new Procedure();
+    	proc.setName(name);
+    	if (params != null) {
+    		int index = 1;
+	    	for (ProcedureParameter procedureParameter : params) {
+				procedureParameter.setProcedure(proc);
+				procedureParameter.setPosition(index++);
+			}
+	    	proc.setParameters(params);
+    	}
+    	model.addProcedure(proc);
+        return proc;    
+    }
+    
+    /**
+     * Create virtual sotred procedure.
+     * @param name Name of stored query, must match model name
+     * @param model Metadata object for the model
+     * @param params List of FakeMetadataObject that are the parameters for the procedure
+     * @param queryPlan Object representing query plan
+     * @return Metadata object for stored procedure
+     */
+    public static Procedure createVirtualProcedure(String name, Schema model, List<ProcedureParameter> params, QueryNode queryPlan) {
+    	Procedure proc = createStoredProcedure(name, model, params, null);
+    	proc.setVirtual(true);
+    	proc.setQueryPlan(queryPlan.getQuery());
+        return proc;
+    }
+    
+    /**
+     * Create a result set.
+     */
+    public static ColumnSet<Procedure> createResultSet(String name, Object model, String[] colNames, String[] colTypes) {
+    	ColumnSet<Procedure> rs = new ColumnSet<Procedure>();
+    	rs.setName(name);
+        for(Column column : createElements(rs, colNames, colTypes)) {
+        	column.setParent(rs);
+        }
+        return rs;
+    }
+
+}

Modified: trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1060,34 +1060,6 @@
         helpValidate("EXEC pm1.sq1()", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
     }
     
-	// variable declared is of special type INPUT
-    @Test public void testCreateUpdateProcedure1() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer INPUT;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// variable declared is of special type CHANGING
-    @Test public void testCreateUpdateProcedure3() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer CHANGING;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-
 	// valid variable declared
     @Test public void testCreateUpdateProcedure4() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
@@ -1744,7 +1716,7 @@
         // Validate
         ValidatorReport report = helpValidateInModeler("pm1.vsp36", sql, metadata);  //$NON-NLS-1$
         assertEquals(1, report.getItems().size());
-        assertEquals("Elements cannot appear more than once in a SET or USING clause.  The following elements are duplicated: [\"USING\".id]", report.toString()); //$NON-NLS-1$
+        assertEquals("Elements cannot appear more than once in a SET or USING clause.  The following elements are duplicated: [DVARS.id]", report.toString()); //$NON-NLS-1$
     }    
     
     @Test public void testValidateAssignmentWithFunctionOnParameter_InModeler() throws Exception{

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -21,16 +21,12 @@
  */
 package org.teiid.dqp.internal.cache;
 
-import java.util.Properties;
-
 import junit.framework.TestCase;
 
 import org.teiid.dqp.internal.process.DQPWorkContext;
 
 import com.metamatrix.cache.Cache;
 import com.metamatrix.cache.FakeCache.FakeCacheFactory;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
 import com.metamatrix.platform.security.api.SessionToken;
 
 
@@ -40,17 +36,16 @@
 	
 	@Override
 	protected void setUp() throws Exception {
-		Properties p = new Properties();
-		p.setProperty(DQPEmbeddedProperties.PROCESSNAME, "host-process"); //$NON-NLS-1$
-		cacheContext = new DQPContextCache(p, new FakeCacheFactory());
-			
+		cacheContext =  new DQPContextCache();
+		cacheContext.setCacheFactory(new FakeCacheFactory());
+		cacheContext.setProcessName("host-process");		
 	}
 	
 	private DQPWorkContext getContext() {
         DQPWorkContext workContext = new DQPWorkContext();
         workContext.setVdbName("MyVDB"); //$NON-NLS-1$
-        workContext.setVdbVersion("1"); //$NON-NLS-1$
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
+        workContext.setVdbVersion(1); //$NON-NLS-1$
+        workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
         return workContext;
 	}
 
@@ -60,17 +55,17 @@
 		Cache cache = this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString());
 		cache.put("key", "request-value"); //$NON-NLS-1$ //$NON-NLS-2$
 
-		cache = this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue());		
+		cache = this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID()));		
 		cache.put("key", "session-value"); //$NON-NLS-1$ //$NON-NLS-2$
 	
 		assertEquals("request-value", this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
-		assertEquals("session-value", this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
+		assertEquals("session-value", this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
 	
 		// close the request
 		this.cacheContext.removeRequestScopedCache(context.getRequestID(12L).toString());
 		
 		assertNull(this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$ 
-		assertEquals("session-value", this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
+		assertEquals("session-value", this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 		
 	
@@ -97,7 +92,7 @@
 		assertEquals("request-value", this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
 		assertEquals("global-value", this.cacheContext.getGlobalScopedCache().get("key")); //$NON-NLS-1$ //$NON-NLS-2$
 		
-		this.cacheContext.shutdown();
+		this.cacheContext.stop();
 		
 		assertNull(this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$
 		// global only dies when the engine is shutdown

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,7 +25,7 @@
 import java.util.Arrays;
 import java.util.List;
 
-import javax.transaction.xa.XAResource;
+import junit.framework.Assert;
 
 import org.teiid.connector.api.Connection;
 import org.teiid.connector.api.ConnectorCapabilities;
@@ -40,17 +40,12 @@
 import org.teiid.connector.basic.BasicConnector;
 import org.teiid.connector.basic.BasicConnectorCapabilities;
 import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.IQueryCommand;
+import org.teiid.connector.language.Command;
+import org.teiid.connector.language.QueryExpression;
 import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.connector.xa.api.XAConnection;
-import org.teiid.connector.xa.api.XAConnector;
 
-import junit.framework.Assert;
 
-
-public class FakeConnector extends BasicConnector implements XAConnector {
+public class FakeConnector extends BasicConnector {
 	private static final int RESULT_SIZE = 5;
 	
 	private boolean executeBlocks;
@@ -63,6 +58,8 @@
     private int connectionCount;
     private int executionCount;
     
+    private ConnectorEnvironment env;
+    
     public int getConnectionCount() {
 		return connectionCount;
 	}
@@ -71,31 +68,27 @@
 		return executionCount;
 	}
     
-    @Override
-    public Connection getConnection(org.teiid.connector.api.ExecutionContext context) throws ConnectorException {
-        return new FakeConnection();
+    public ConnectorEnvironment getConnectorEnvironment() {
+    	return this.env;
     }
-    @Override
-    public void start(ConnectorEnvironment environment)
-    		throws ConnectorException {
-    	
+    
+    public void setConnectorEnvironment(ConnectorEnvironment env) {
+    	this.env = env;
     }
+    
     @Override
-    public void stop() {}
-    @Override
-	public XAConnection getXAConnection(ExecutionContext executionContext,
-			TransactionContext transactionContext) throws ConnectorException {
-		return new FakeConnection();
-	}
+    public Connection getConnection() throws ConnectorException {
+        return new FakeConnection();
+    }
 	
-    private class FakeConnection extends BasicConnection implements XAConnection {
+    private class FakeConnection extends BasicConnection {
     	
     	public FakeConnection() {
 			connectionCount++;
 		}
     	
         public boolean released = false;
-        public Execution createExecution(ICommand command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
+        public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
         	executionCount++;
             return new FakeBlockingExecution(executionContext);
         }
@@ -106,10 +99,6 @@
             Assert.assertFalse("The connection should not be released more than once", released); //$NON-NLS-1$
             released = true;
         }
-		@Override
-		public XAResource getXAResource() throws ConnectorException {
-			return null;
-		}
     }   
     
     private final class FakeBlockingExecution extends BasicExecution implements ResultSetExecution, UpdateExecution {
@@ -120,7 +109,7 @@
         public FakeBlockingExecution(ExecutionContext ec) {
             this.ec = ec;
         }
-        public void execute(IQueryCommand query, int maxBatchSize) throws ConnectorException {
+        public void execute(QueryExpression query, int maxBatchSize) throws ConnectorException {
             if (executeBlocks) {
                 waitForCancel();
             }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -38,9 +38,7 @@
 
 	public FakeExecutionContextImpl(int unique) {
 		super("VDB" + unique, //$NON-NLS-1$
-				"Version" + unique, //$NON-NLS-1$
-				"User" + unique, //$NON-NLS-1$ 
-				"Payload" + unique, //$NON-NLS-1$
+				unique, 
 				"ExecutionPayload" + unique, //$NON-NLS-1$            
 				"ConnectionID" + unique, //$NON-NLS-1$
 				"ConnectorID" + unique, //$NON-NLS-1$
@@ -50,8 +48,7 @@
 	}
 
 	public FakeExecutionContextImpl(ExecutionContext c) {
-		super(c.getVirtualDatabaseName(), c.getVirtualDatabaseVersion(), c
-				.getUser(), c.getTrustedPayload(), c.getExecutionPayload(), c
+		super(c.getVirtualDatabaseName(), c.getVirtualDatabaseVersion(), c.getExecutionPayload(), c
 				.getConnectionIdentifier(), c.getConnectorIdentifier(), c
 				.getRequestIdentifier(), c.getPartIdentifier(), c
 				.getExecutionCountIdentifier());

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,6 +24,7 @@
 
 import org.teiid.dqp.internal.transaction.TransactionProvider;
 import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+import org.teiid.dqp.internal.transaction.XidFactory;
 
 import com.metamatrix.core.util.SimpleMock;
 
@@ -31,6 +32,7 @@
 
 	public FakeTransactionService() {
 		this.setTransactionProvider(SimpleMock.createSimpleMock(TransactionProvider.class));
+		this.setXidFactory(new XidFactory());
 	}
 	
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,217 +26,65 @@
  */
 package org.teiid.dqp.internal.datamgr.impl;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
-import java.net.URL;
-import java.net.URLClassLoader;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.teiid.connector.api.Connection;
 import org.teiid.connector.api.Connector;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ConnectorPropertyNames;
-import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
-import org.teiid.dqp.internal.pooling.connector.FakeSourceConnectionFactory;
-import org.teiid.dqp.internal.process.DQPWorkContext;
 
-import com.metamatrix.cache.FakeCache;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.queue.FakeWorkManager;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.service.ConnectorStatus;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
 
 /**
  * JUnit test for TestConnectorManagerImpl
  */
 public final class TestConnectorManagerImpl {
-    private Properties helpGetAppProps() {
-        Properties appProperties = new Properties();
-
-        appProperties.setProperty(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, "AFakeConnectorBinding"); //$NON-NLS-1$
-        appProperties.setProperty(ConnectorPropertyNames.MAX_RESULT_ROWS, "10"); //$NON-NLS-1$
-        appProperties.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
-
-        return appProperties;
+   
+	private ConnectorEnvironment helpGetAppProps() {
+		ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
+		Mockito.stub(env.getMaxResultRows()).toReturn(10);
+		return env;
     }
+	
+	static ConnectorManager getConnectorManager(ConnectorEnvironment env) throws Exception {
+		final FakeConnector c = new FakeConnector();
+		c.setConnectorEnvironment(env);		
+		ConnectorManager cm = new ConnectorManager("FakeConnector") {
+			Connector getConnector() {
+				return c;
+			}
+		};
+		cm.start();
+		return cm;
+	}	
 
     // =========================================================================
     //                         T E S T   C A S E S
     // =========================================================================
 
-    @Test public void testStartFailsWithNullRequiredProp() throws Exception {
-        ConnectorManager cm = new ConnectorManager();
-        Properties appProperties = helpGetAppProps();
-        // Remove required property
-        appProperties.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, ""); //$NON-NLS-1$
-        
-        try {
-            startConnectorManager(cm, appProperties);
-    		cm.stop();
-            fail("Able to start ConnectorManager with null required props."); //$NON-NLS-1$
-        } catch (ApplicationLifecycleException e) {
-        	assertEquals("Connector is missing required property ConnectorClass or wrong value supplied AFakeConnectorBinding<null> ", e.getMessage()); //$NON-NLS-1$
-        } 
-    }
 
     @Test public void testReceive() throws Exception {
-    	ConnectorManager cm = new ConnectorManager();
-    	startConnectorManager(cm, helpGetAppProps());
-        
+    	ConnectorManager cm = getConnectorManager(helpGetAppProps());
         AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
         QueueResultsReceiver receiver = new QueueResultsReceiver();
-        cm.executeRequest(receiver, request);
+        cm.executeRequest(new FakeWorkManager(), receiver, request);
         assertNotNull(receiver.getResults().poll(1000, TimeUnit.MILLISECONDS));
         cm.stop();
     }
     
-    @Test public void testConnectorCapabilitiesOverride() throws Exception {
-    	ConnectorManager cm = new ConnectorManager();
-    	startConnectorManager(cm, helpGetAppProps());
-
-    	AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
-    	
-    	SourceCapabilities caps = cm.getCapabilities(request.getRequestID(), null, Mockito.mock(DQPWorkContext.class));
-    	assertFalse(caps.supportsCapability(Capability.CRITERIA_EXISTS));
-    	assertFalse(caps.supportsCapability(Capability.QUERY_EXCEPT));
-
-    	
-    	ConnectorManager cmnew = new ConnectorManager();
-    	Properties props = helpGetAppProps();
-    	props.setProperty("supportsExistsCriteria", "true"); //$NON-NLS-1$ //$NON-NLS-2$
-    	props.setProperty("supportsExcept", "true"); //$NON-NLS-1$ //$NON-NLS-2$
-    	startConnectorManager(cmnew, props);
-
-    	SourceCapabilities capsnew = cmnew.getCapabilities(request.getRequestID(), null, Mockito.mock(DQPWorkContext.class));
-    	assertTrue(capsnew.supportsCapability(Capability.CRITERIA_EXISTS));
-    	assertTrue(capsnew.supportsCapability(Capability.QUERY_EXCEPT));
-    }
-
-	private void startConnectorManager(ConnectorManager cm, Properties props)
-			throws ApplicationLifecycleException {
-		cm.initialize(props);
-        ApplicationEnvironment env = new ApplicationEnvironment();
-        env.bindService(DQPServiceNames.METADATA_SERVICE, new FakeMetadataService());
-        env.bindService(DQPServiceNames.TRANSACTION_SERVICE, new FakeTransactionService());
-        env.setCacheFactory(new FakeCache.FakeCacheFactory());
-        cm.start(env);
-	}
     
-    @Test public void testIsXA() throws Exception {
-    	ConnectorManager cm = new ConnectorManager();
-        Properties props = new Properties();
-        props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
-        props.setProperty(ConnectorPropertyNames.IS_XA, Boolean.TRUE.toString());
-        startConnectorManager(cm, props);
-        assertTrue(cm.isXa());
-        cm.stop();
-    }
-    
-    @Test public void testIsXA_Failure() throws Exception {
-        ConnectorManager cm = new ConnectorManager();
-        Properties props = new Properties();
-        props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeSourceConnectionFactory.class.getName());
-        props.setProperty(ConnectorPropertyNames.IS_XA, Boolean.TRUE.toString());
-        try {
-        	startConnectorManager(cm, props);
-        } catch (ApplicationLifecycleException e) {
-        	assertEquals("Connector \"Unknown_Binding_Name<null>\" was configured to support XA transactions, but the connector is not an XAConnector", e.getMessage()); //$NON-NLS-1$
-        }
-        cm.stop();
-    }
-        
     @Test public void testDefect19049() throws Exception {
-        ConnectorManager cm = new ConnectorManager();
-        Properties props = new Properties();
-        final String connectorName = FakeConnector.class.getName();
-        props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, connectorName);
-        URLClassLoader cl = new URLClassLoader(new URL[0]);
-        startConnectorManager(cm, props);
-        ((FakeConnector)cm.getConnector().getActualConnector()).setClassloader(cl);
+        ConnectorManager cm = getConnectorManager(helpGetAppProps());
         AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
         QueueResultsReceiver receiver = new QueueResultsReceiver();
-        cm.executeRequest(receiver, request);
+        cm.executeRequest(new FakeWorkManager(),receiver, request);
         assertNotNull(receiver.getResults().poll(1000, TimeUnit.MILLISECONDS));
         cm.stop();
     }
-
-    @Test public void testConnectorStatus() throws Exception {
-    	ConnectorManager cm = new ConnectorManager();
-    	assertEquals(ConnectorStatus.NOT_INITIALIZED, cm.getStatus());
-    	
-    	Properties props = new Properties();
-    	Connector mockConnector = Mockito.mock(Connector.class);
-    	Connection mockConnection = Mockito.mock(Connection.class);
-    	
-    	Mockito.stub(mockConnector.getConnection((ExecutionContext)Mockito.anyObject())).toReturn(mockConnection);        
-    	
-        final String connectorName = mockConnector.getClass().getName();
-        props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, connectorName);
-        startConnectorManager(cm, props);
-        cm.setConnector(new ConnectorWrapper(mockConnector)); // to make them same connector
-
-        // no identity can be defined
-        assertEquals(ConnectorStatus.UNABLE_TO_CHECK, cm.getStatus());
-    }
-    
-    @Test public void testConnectorStatus_alive() throws Exception {
-    	ConnectorManager cm = new ConnectorManager();
-    	assertEquals(ConnectorStatus.NOT_INITIALIZED, cm.getStatus());
-    	
-    	Connector mockConnector = Mockito.mock(Connector.class);
-    	Connection mockConnection = Mockito.mock(Connection.class);
-    	ConnectorIdentity mockIdentity = Mockito.mock(ConnectorIdentity.class);
-    	
-    	Mockito.stub(mockConnector.getConnection((ExecutionContext)Mockito.anyObject())).toReturn(mockConnection);        
-        Mockito.stub(mockConnector.createIdentity(null)).toReturn(mockIdentity);
-        Mockito.stub(mockConnection.isAlive()).toReturn(true);
-    	
-        ConnectorWrapper wrapper = new ConnectorWrapper(mockConnector);
-        
-        wrapper.updateStatus();
-        assertEquals(ConnectorStatus.OPEN, wrapper.getStatus());
-    }
-    
-    @Test public void testConnectorStatus_unavailable() throws Exception {
-    	ConnectorManager cm = new ConnectorManager();
-    	assertEquals(ConnectorStatus.NOT_INITIALIZED, cm.getStatus());
-    	
-    	Connector mockConnector = Mockito.mock(Connector.class);
-    	Connection mockConnection = Mockito.mock(Connection.class);
-    	ConnectorIdentity mockIdentity = Mockito.mock(ConnectorIdentity.class);
-    	
-    	Mockito.stub(mockConnector.getConnection((ExecutionContext)Mockito.anyObject())).toReturn(mockConnection);        
-        Mockito.stub(mockConnector.createIdentity(null)).toReturn(mockIdentity);
-        Mockito.stub(mockConnection.isAlive()).toReturn(false);
-    	
-        ConnectorWrapper wrapper = new ConnectorWrapper(mockConnector);
-        
-        wrapper.updateStatus();
-        assertEquals(ConnectorStatus.DATA_SOURCE_UNAVAILABLE, wrapper.getStatus());
-    }    
-    
-    @Test public void testConnectorStatus_exception() throws Exception {
-    	ConnectorManager cm = new ConnectorManager();
-    	assertEquals(ConnectorStatus.NOT_INITIALIZED, cm.getStatus());
-    	
-    	Connector mockConnector = Mockito.mock(Connector.class);
-    	ConnectorIdentity mockIdentity = Mockito.mock(ConnectorIdentity.class);
-    	
-    	Mockito.stub(mockConnector.getConnection((ExecutionContext)Mockito.anyObject())).toThrow(new ConnectorException());        
-        Mockito.stub(mockConnector.createIdentity(null)).toReturn(mockIdentity);
-    	
-        ConnectorWrapper wrapper = new ConnectorWrapper(mockConnector);
-        
-        wrapper.updateStatus();
-        assertEquals(ConnectorStatus.DATA_SOURCE_UNAVAILABLE, wrapper.getStatus());
-    }     
 }
\ No newline at end of file

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,14 +31,13 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 
-import org.mockito.Mockito;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
-
 import junit.framework.TestCase;
 
-import com.metamatrix.common.queue.WorkerPool;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
+
+import com.metamatrix.common.queue.FakeWorkManager;
 import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
@@ -63,19 +62,18 @@
     protected void setUp() throws Exception {
         super.setUp();
         request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
-        csm = new ConnectorManager();
-        csm.setConnectorWorkerPool(Mockito.mock(WorkerPool.class));
-        csm.setConnector(new ConnectorWrapper(new FakeConnector()));
-        csm.setWorkItemFactory(new ConnectorWorkItemFactory(csm, true));
+        csm = TestConnectorManagerImpl.getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+        csm.workItemFactory = new ConnectorWorkItemFactory(csm, true);
     }
 
-    void helpAssureOneState() {
-    	csm.executeRequest(null, request);
+    void helpAssureOneState() throws Exception {
+    	QueueResultsReceiver receiver = new QueueResultsReceiver();
+    	csm.executeRequest(new FakeWorkManager(), receiver, request);
     	ConnectorWorkItem state = csm.getState(request.getAtomicRequestID());
     	assertEquals(state, csm.getState(request.getAtomicRequestID()));
     }
 
-    public void testCreateAndAddRequestState() {
+    public void testCreateAndAddRequestState() throws Exception {
         helpAssureOneState();
         assertEquals("Expected size of 1", 1, csm.size()); //$NON-NLS-1$
     }
@@ -90,13 +88,13 @@
         }
     }
 
-    public void testRemoveRequestState() {
+    public void testRemoveRequestState() throws Exception {
         helpAssureOneState();
         csm.removeState(request.getAtomicRequestID());
         assertEquals("Expected size of 0", 0, csm.size()); //$NON-NLS-1$
     }
 
-    public void testRemoveUnknownRequestState() {
+    public void testRemoveUnknownRequestState() throws Exception {
         helpAssureOneState();
         csm.removeState(new AtomicRequestID(new RequestID("ZZZZ", 3210), 5, 5)); //$NON-NLS-1$
 
@@ -107,7 +105,7 @@
     	List<ResultsFuture<AtomicResultsMessage>> futures = new ArrayList<ResultsFuture<AtomicResultsMessage>>();
     	for (int i=0; i<20; i++) {
     		ResultsFuture<AtomicResultsMessage> future = new ResultsFuture<AtomicResultsMessage>();
-        	csm.executeRequest(future.getResultsReceiver(), TestConnectorWorkItem.createNewAtomicRequestMessage(i, 1));
+        	csm.executeRequest(new FakeWorkManager(),future.getResultsReceiver(), TestConnectorWorkItem.createNewAtomicRequestMessage(i, 1));
         }
 
         csm.stop();

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,35 +22,36 @@
 
 package org.teiid.dqp.internal.datamgr.impl;
 
+import static junit.framework.Assert.*;
+
 import java.util.Arrays;
 import java.util.List;
-import java.util.Properties;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
-import javax.transaction.Transaction;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.xa.Xid;
 
-import junit.framework.TestCase;
-
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorPropertyNames;
 import org.teiid.connector.api.ProcedureExecution;
-import org.teiid.connector.language.IProcedure;
-import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.connector.language.Call;
 import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
 import org.teiid.dqp.internal.process.DQPWorkContext;
 
 import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.queue.FakeWorkManager;
 import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.FakeMetadataService;
+import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
 import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.parser.QueryParser;
@@ -58,13 +59,11 @@
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.StoredProcedure;
 import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
 import com.metamatrix.query.unittest.FakeMetadataFactory;
 
-public class TestConnectorWorkItem extends TestCase {
+public class TestConnectorWorkItem {
 
-	private static final FakeMetadataFacade EXAMPLE_BQT = FakeMetadataFactory
-			.exampleBQTCached();
+	private static final QueryMetadataInterface EXAMPLE_BQT = FakeMetadataFactory.exampleBQTCached();
 
 	private static Command helpGetCommand(String sql,
 			QueryMetadataInterface metadata) throws Exception {
@@ -73,38 +72,40 @@
 		return command;
 	}
 
-	static ConnectorManager getConnectorManager() {
-		ConnectorManager cm = new ConnectorManager();
-		cm.setConnector(new ConnectorWrapper(new FakeConnector()));
-		cm.setTransactionService(new FakeTransactionService());
-		cm.setMetadataService(new FakeMetadataService());
+	static ConnectorManager getConnectorManager(ConnectorEnvironment env) {
+		final FakeConnector c = new FakeConnector();
+		c.setConnectorEnvironment(env);
+		
+		ConnectorManager cm = new ConnectorManager("FakeConnector") {
+			Connector getConnector() {
+				return c;
+			}			
+		};
 		return cm;
 	}
 
-	static AtomicRequestMessage createNewAtomicRequestMessage(int requestid,
-			int nodeid) throws Exception {
+	static AtomicRequestMessage createNewAtomicRequestMessage(int requestid, int nodeid) throws Exception {
 		RequestMessage rm = new RequestMessage();
-		DQPWorkContext workContext = new DQPWorkContext();
-		workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
-		AtomicRequestMessage request = new AtomicRequestMessage(rm,
-				workContext, nodeid);
-		request.setCommand(helpGetCommand(
-				"SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT)); //$NON-NLS-1$
+		
+		DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(EXAMPLE_BQT, FakeMetadataFactory.exampleBQTVDB());
+		workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
+		
+		AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
+		request.setCommand(helpGetCommand("SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT)); //$NON-NLS-1$
 		request.setRequestID(new RequestID(requestid));
-		request.setConnectorID(new ConnectorID("testing")); //$NON-NLS-1$
+		request.setConnectorName("testing"); //$NON-NLS-1$
 		request.setFetchSize(5);
 		return request;
 	}
 
-	public void testProcedureBatching() throws Exception {
+	@Test public void testProcedureBatching() throws Exception {
 		ProcedureExecution exec = new FakeProcedureExecution(2, 1);
 
 		// this has two result set columns and 1 out parameter
 		int total_columns = 3;
 		StoredProcedure command = (StoredProcedure)helpGetCommand("{call pm2.spTest8(?)}", EXAMPLE_BQT); //$NON-NLS-1$      
 		command.getInputParameters().get(0).setExpression(new Constant(1));
-		IProcedure proc = (IProcedure) new LanguageBridgeFactory(EXAMPLE_BQT)
-				.translate(command);
+		Call proc = (Call)new LanguageBridgeFactory(EXAMPLE_BQT).translate(command);
 
 		ProcedureBatchHandler pbh = new ProcedureBatchHandler(proc, exec);
 
@@ -121,26 +122,24 @@
 			fail("Expected exception from resultset mismatch"); //$NON-NLS-1$
 		} catch (ConnectorException err) {
 			assertEquals(
-					"Could not process stored procedure results for EXEC spTest8(, 1).  Expected 2 result set columns, but was 1.  Please update your models to allow for stored procedure results batching.", err.getMessage()); //$NON-NLS-1$
+					"Could not process stored procedure results for EXEC spTest8(1).  Expected 2 result set columns, but was 1.  Please update your models to allow for stored procedure results batching.", err.getMessage()); //$NON-NLS-1$
 		}
 	}
 
-	public void testCancelBeforeNew() throws Exception {
+	@Test public void testCancelBeforeNew() throws Exception {
 		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
 		// only one response is expected
+		FakeWorkManager wm = new FakeWorkManager();
 		ResultsFuture<AtomicResultsMessage> resultsFuture = new ResultsFuture<AtomicResultsMessage>();
-		ConnectorWorkItem state = new SynchConnectorWorkItem(request,
-				getConnectorManager(), resultsFuture
-						.getResultsReceiver());
+		ConnectorWorkItem state = new SynchConnectorWorkItem(request,getConnectorManager(Mockito.mock(ConnectorEnvironment.class)), resultsFuture.getResultsReceiver());
 
 		state.asynchCancel(); // cancel does not cause close, but the next
 								// processing will close
 		assertFalse(state.isDoneProcessing());
 
-		state.run();
+		wm.doWork(state, 0, null, state);
 
-		AtomicResultsMessage arm = resultsFuture.get(1000,
-				TimeUnit.MILLISECONDS);
+		AtomicResultsMessage arm = resultsFuture.get(1000, TimeUnit.MILLISECONDS);
 
 		assertTrue(arm.isRequestClosed());
 
@@ -149,8 +148,8 @@
 		 */
 		try {
 			state.requestMore();
-		} catch (IllegalStateException e) {
-
+		} catch (Throwable e) {
+			// catches the assertion error
 		}
 	}
 
@@ -169,8 +168,12 @@
 			switch (msgCount++) {
 			case 0:
 				// request more during delivery
-				((FakeConnector) manager.getConnector().getActualConnector()).setReturnsFinalBatch(true);
-				workItem.requestMore();
+				try {
+					((FakeConnector) manager.getConnector()).setReturnsFinalBatch(true);
+					workItem.requestMore();
+				} catch (ConnectorException e) {
+					exceptionOccurred(e);
+				}
 				break;
 			case 1:
 				if (results.isRequestClosed()) {
@@ -214,11 +217,10 @@
 		}
 	}
 
-	public void testMoreAsynch() throws Throwable {
+	 @Test public void testMoreAsynch() throws Throwable {
 		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		final ConnectorManager manager = getConnectorManager();
-		AsynchMoreResultsReceiver receiver = new AsynchMoreResultsReceiver(
-				manager);
+		final ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+		AsynchMoreResultsReceiver receiver = new AsynchMoreResultsReceiver(manager);
 		ConnectorWorkItem state = new SynchConnectorWorkItem(request, manager,
 				receiver);
 		receiver.workItem = state;
@@ -230,9 +232,9 @@
 		}
 	}
 	
-	public void testSynchInterrupt() throws Exception {
+	 @Test public void testSynchInterrupt() throws Exception {
 		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		final ConnectorManager manager = getConnectorManager();
+		final ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
 		QueueResultsReceiver receiver = new QueueResultsReceiver();
 		ConnectorWorkItem state = new SynchConnectorWorkItem(request, manager, receiver);
 		Thread t = runRequest(state);
@@ -241,10 +243,10 @@
 		assertTrue(state.isCancelled());
 	}
 
-	public void testImplicitClose() throws Exception {
+	 @Test public void testImplicitClose() throws Exception {
 		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		ConnectorManager manager = getConnectorManager();
-		FakeConnector connector = (FakeConnector) manager.getConnector().getActualConnector();
+		ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+		FakeConnector connector = (FakeConnector) manager.getConnector();
 
 		connector.setReturnsFinalBatch(true);
 
@@ -255,53 +257,55 @@
 		assertTrue(state.isDoneProcessing());
 	}
 
-	public void testCloseBeforeNew() throws Exception {
+	@Test public void testCloseBeforeNew() throws Exception {
 		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
+		FakeWorkManager wm = new FakeWorkManager();
 		ResultsFuture<AtomicResultsMessage> resultsFuture = new ResultsFuture<AtomicResultsMessage>();
-		ConnectorWorkItem state = new SynchConnectorWorkItem(request,
-				getConnectorManager(), resultsFuture.getResultsReceiver());
+		ConnectorWorkItem state = new SynchConnectorWorkItem(request,getConnectorManager(Mockito.mock(ConnectorEnvironment.class)), resultsFuture.getResultsReceiver());
 
 		state.requestClose();
 		assertFalse(resultsFuture.isDone());
-		state.run();
+		
+		wm.doWork(state, 0, null, state);
 
 		AtomicResultsMessage arm = resultsFuture.get(1000,
 				TimeUnit.MILLISECONDS);
 		assertTrue(arm.isRequestClosed());
 		assertTrue(state.isDoneProcessing());
 	}
-
-	public void testAsynchBasicMore() throws Exception {
+	@Test public void testAsynchBasicMore() throws Exception {
 		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		ConnectorManager manager = getConnectorManager();
-		FakeConnector connector = (FakeConnector) manager.getConnector().getActualConnector();
+		FakeWorkManager wm = new FakeWorkManager();
+		ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+		
+		FakeConnector connector = (FakeConnector) manager.getConnector();
 		QueueResultsReceiver resultsReceiver = new QueueResultsReceiver(); 
-		FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(
-				request, manager, resultsReceiver);
-
-		state.run();
-
+		
+		FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(request, manager, resultsReceiver, wm);
+		
+		wm.doWork(state, 0, null, state);
+		
 		assertFalse(state.isDoneProcessing());
 		connector.setReturnsFinalBatch(true);
 
 		state.requestMore();
-		state.run();
-
+		wm.doWork(state, 0, null, state);
+		
 		assertTrue(state.isDoneProcessing());
 
 		assertEquals(3, resultsReceiver.results.size());
 		assertEquals(1, state.resumeCount);
 	}
 
-	public void testAsynchKeepAlive() throws Exception {
+	@Test public void testAsynchKeepAlive() throws Exception {
 		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		ConnectorManager manager = getConnectorManager();
-		FakeConnector connector = (FakeConnector) manager.getConnector().getActualConnector();
+		ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+		FakeConnector connector = (FakeConnector) manager.getConnector();
 		QueueResultsReceiver resultsReceiver = new QueueResultsReceiver();
-		FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(
-				request, manager, resultsReceiver);
+		FakeWorkManager wm = new FakeWorkManager();
+		FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(request, manager, resultsReceiver, wm);
 
-		state.run();
+		wm.doWork(state, 0, null, state);
 
 		assertFalse(state.isDoneProcessing());
 
@@ -317,7 +321,7 @@
 		assertEquals(1, state.resumeCount);
 	}
 	
-	public void testUpdateExecution() throws Throwable {
+	@Test public void testUpdateExecution() throws Throwable {
 		QueueResultsReceiver receiver = helpExecuteUpdate();
 		AtomicResultsMessage results = receiver.getResults().remove();
 		assertEquals(Integer.valueOf(1), results.getResults()[0].get(0));
@@ -329,7 +333,7 @@
 		AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
 		arm.setCommand(command);
 		QueueResultsReceiver receiver = new QueueResultsReceiver();
-		SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(arm, getConnectorManager(), receiver);
+		SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(arm, getConnectorManager(Mockito.mock(ConnectorEnvironment.class)), receiver);
 		synchConnectorWorkItem.run();
 		if (receiver.exception != null) {
 			throw receiver.exception;
@@ -337,14 +341,14 @@
 		return receiver;
 	}
 	
-	public void testExecutionWarning() throws Throwable {
+	@Test public void testExecutionWarning() throws Throwable {
 		QueueResultsReceiver receiver = helpExecuteUpdate();
 		AtomicResultsMessage results = receiver.getResults().remove();
 		assertEquals(1, results.getWarnings().size());
 	}
 
     
-    public void testIsImmutablePropertySucceeds() throws Exception {
+	@Test public void testIsImmutablePropertySucceeds() throws Exception {
     	/*
     	 * Setup:
     	 *  1. requestMsg.isTransactional() must be TRUE 
@@ -352,16 +356,10 @@
     	 *  3. command must NOT be a SELECT
     	 *  4. Then, set isImmutable to TRUE, we should SUCCEED
     	 */
-		ConnectorManager cm = getConnectorManager();
-        Properties props = new Properties();
+    	ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
+    	Mockito.stub(env.isImmutable()).toReturn(true);
+		ConnectorManager cm = getConnectorManager(env);
 
-        // to create an XA ConnectorManager
-        props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
-
-        // to set IS_IMMUTABLE to true
-        props.setProperty(ConnectorPropertyNames.IS_IMMUTABLE, "true"); //$NON-NLS-1$ //$NON-NLS-2$
-		cm.initialize(props);
-        
 		// command must not be a SELECT
 		Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
 		AtomicRequestMessage requestMsg = createNewAtomicRequestMessage(1, 1);
@@ -369,29 +367,9 @@
 		
 		// To make the AtomicRequestMessage transactional, construct your own
 		requestMsg.setTransactionContext( new TransactionContext(){
-
 			@Override
-			public Transaction getTransaction() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public Scope getTransactionType() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public String getTxnID() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public boolean isInTransaction() {
-				// TODO Auto-generated method stub
-				return true;
+			public Xid getXid() {
+				return Mockito.mock(Xid.class);
 			}} );
 		
 		QueueResultsReceiver receiver = new QueueResultsReceiver();
@@ -407,7 +385,7 @@
 		}
     }
     
-    public void testIsImmutablePropertyFails() throws Exception {
+	@Test public void testIsImmutablePropertyFails() throws Exception {
     	/*
     	 * Setup:
     	 *  1. requestMsg.isTransactional() must be TRUE 
@@ -415,15 +393,9 @@
     	 *  3. command must NOT be a SELECT
     	 *  4. Then, set isImmutable to FALSE, and we should FAIL
     	 */
-		ConnectorManager cm = getConnectorManager();
-        Properties props = new Properties();
-
-        // to create an XA ConnectorManager
-        props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
-
-        // to set IS_IMMUTABLE to false
-        props.setProperty(ConnectorPropertyNames.IS_IMMUTABLE, "false"); //$NON-NLS-1$ //$NON-NLS-2$
-		cm.initialize(props);
+    	ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
+    	Mockito.stub(env.isImmutable()).toReturn(false);
+		ConnectorManager cm = getConnectorManager(env);
         
 		// command must not be a SELECT
 		Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
@@ -432,38 +404,18 @@
 		
 		// To make the AtomicRequestMessage transactional, construct your own
 		requestMsg.setTransactionContext( new TransactionContext(){
-
 			@Override
-			public Transaction getTransaction() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public Scope getTransactionType() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public String getTxnID() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public boolean isInTransaction() {
-				// TODO Auto-generated method stub
-				return true;
+			public Xid getXid() {
+				return Mockito.mock(Xid.class);
 			}} );
 		
 		QueueResultsReceiver receiver = new QueueResultsReceiver();
-		SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(requestMsg, cm, receiver);
 	
 		// This is the test
 		try {
+			SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(requestMsg, cm, receiver);
 			synchConnectorWorkItem.run();
-			this.assertNull("Connection should be null when IsImmutable is false", synchConnectorWorkItem.connection);  //$NON-NLS-1$ 
+			assertNull("Connection should be null when IsImmutable is false", synchConnectorWorkItem.connection);  //$NON-NLS-1$ 
 		} catch ( Exception e ) {
 			LogManager.logWarning(LogConstants.CTX_CONNECTOR, e.getMessage());			
 		}
@@ -473,9 +425,8 @@
 			AsynchConnectorWorkItem {
 		int resumeCount;
 
-		FakeQueuingAsynchConnectorWorkItem(AtomicRequestMessage message,
-				ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
-			super(message, manager, resultsReceiver);
+		FakeQueuingAsynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver, WorkManager wm) throws ConnectorException {
+			super(message, manager, resultsReceiver, wm);
 		}
 
 		@Override

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -37,7 +37,7 @@
     }
 
     public ExecutionContextImpl createContext(String requestID, String partID) {
-        return new ExecutionContextImpl("vdb", "1", "user", null, null,   //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+        return new ExecutionContextImpl("vdb", 1, null,   //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                                         "Connection", "Connector", requestID, partID, "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,7 +24,7 @@
 
 import java.sql.Clob;
 
-import org.teiid.dqp.internal.datamgr.impl.TypeFacilityImpl;
+import org.teiid.connector.basic.TypeFacilityImpl;
 
 import junit.framework.TestCase;
 

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,12 +22,12 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.connector.language.IAggregate;
-import org.teiid.dqp.internal.datamgr.language.AggregateImpl;
-import org.teiid.dqp.internal.datamgr.language.LiteralImpl;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.AggregateFunction;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.SQLReservedWords;
 
 import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.symbol.AggregateSymbol;
 import com.metamatrix.query.sql.symbol.Constant;
 
@@ -43,33 +43,33 @@
         super(name);
     }
 
-    public static AggregateImpl example(String name, String functionName, boolean distinct, int value) throws Exception {
+    public static AggregateFunction example(String name, String functionName, boolean distinct, int value) throws Exception {
         AggregateSymbol symbol = new AggregateSymbol(name,
                                                      functionName,
                                                      distinct,
                                                       new Constant(new Integer(value)));
-        return (AggregateImpl)TstLanguageBridgeFactory.factory.translate(symbol);
+        return (AggregateFunction)TstLanguageBridgeFactory.factory.translate(symbol);
         
     }
 
     public void testGetName() throws Exception {
-        assertEquals(IAggregate.COUNT, example("testName", ReservedWords.COUNT, true, 42).getName()); //$NON-NLS-1$ 
+        assertEquals(AggregateFunction.COUNT, example("testName", SQLReservedWords.COUNT, true, 42).getName()); //$NON-NLS-1$ 
     }
 
     public void testIsDistinct() throws Exception {
-        assertTrue(example("testName", ReservedWords.COUNT, true, 42).isDistinct()); //$NON-NLS-1$
-        assertFalse(example("testName", ReservedWords.COUNT, false, 42).isDistinct()); //$NON-NLS-1$
+        assertTrue(example("testName", SQLReservedWords.COUNT, true, 42).isDistinct()); //$NON-NLS-1$
+        assertFalse(example("testName", SQLReservedWords.COUNT, false, 42).isDistinct()); //$NON-NLS-1$
     }
 
     public void testGetExpression() throws Exception {
-        AggregateImpl agg = example("testName", ReservedWords.COUNT, true, 42); //$NON-NLS-1$
+        AggregateFunction agg = example("testName", SQLReservedWords.COUNT, true, 42); //$NON-NLS-1$
         assertNotNull(agg.getExpression());
-        assertTrue(agg.getExpression() instanceof LiteralImpl);
-        assertEquals(new Integer(42), ((LiteralImpl)agg.getExpression()).getValue());
+        assertTrue(agg.getExpression() instanceof Literal);
+        assertEquals(new Integer(42), ((Literal)agg.getExpression()).getValue());
     }
 
     public void testGetType() throws Exception {
-        assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, example("x", ReservedWords.COUNT, true, 42).getType()); //$NON-NLS-1$
+        assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, example("x", SQLReservedWords.COUNT, true, 42).getType()); //$NON-NLS-1$
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,10 +25,10 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.dqp.internal.datamgr.language.BatchedUpdatesImpl;
+import org.teiid.connector.language.BatchedUpdates;
+import org.teiid.connector.language.Delete;
+import org.teiid.connector.language.Insert;
+import org.teiid.connector.language.Update;
 
 import junit.framework.TestCase;
 
@@ -52,16 +52,16 @@
         return new BatchedUpdateCommand(updates);
     }
     
-    public static BatchedUpdatesImpl example() throws Exception {
-        return (BatchedUpdatesImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static BatchedUpdates example() throws Exception {
+        return (BatchedUpdates)TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetUpdateCommands() throws Exception {
         List updates = example().getUpdateCommands();
         assertEquals(3, updates.size());
-        assertTrue(updates.get(0) instanceof IInsert);
-        assertTrue(updates.get(1) instanceof IUpdate);
-        assertTrue(updates.get(2) instanceof IDelete);
+        assertTrue(updates.get(0) instanceof Insert);
+        assertTrue(updates.get(1) instanceof Update);
+        assertTrue(updates.get(2) instanceof Delete);
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,15 +22,15 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.connector.language.ICompareCriteria.Operator;
-import org.teiid.dqp.internal.datamgr.language.CompareCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.LiteralImpl;
+import junit.framework.TestCase;
 
-import com.metamatrix.query.sql.lang.CompareCriteria;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.Comparison.Operator;
+
+import com.metamatrix.query.sql.lang.AbstractCompareCriteria;
 import com.metamatrix.query.sql.symbol.Constant;
 
-import junit.framework.TestCase;
-
 public class TestCompareCriteriaImpl extends TestCase {
 
     /**
@@ -41,36 +41,37 @@
         super(name);
     }
 
-    public static CompareCriteria helpExample(int operator, int leftVal, int rightVal) {
+    public static com.metamatrix.query.sql.lang.CompareCriteria helpExample(int operator, int leftVal, int rightVal) {
         Constant left = new Constant(new Integer(leftVal));
         Constant right = new Constant(new Integer(rightVal));
-        return new CompareCriteria(left, operator, right);
+        return new com.metamatrix.query.sql.lang.CompareCriteria(left, operator, right);
     }
-    public static CompareCriteriaImpl example(int operator, int leftVal, int rightVal) throws Exception {
-        return (CompareCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(operator, leftVal, rightVal));
+    
+    public static Comparison example(int operator, int leftVal, int rightVal) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(operator, leftVal, rightVal));
     }
 
     public void testGetLeftExpression() throws Exception {
-        CompareCriteriaImpl impl = example(CompareCriteria.GE, 200, 100);
+        Comparison impl = example(AbstractCompareCriteria.GE, 200, 100);
         assertNotNull(impl.getLeftExpression());
-        assertTrue(impl.getLeftExpression() instanceof LiteralImpl);
-        assertEquals(new Integer(200), ((LiteralImpl)impl.getLeftExpression()).getValue());
+        assertTrue(impl.getLeftExpression() instanceof Literal);
+        assertEquals(new Integer(200), ((Literal)impl.getLeftExpression()).getValue());
     }
 
     public void testGetRightExpression() throws Exception {
-        CompareCriteriaImpl impl = example(CompareCriteria.GE, 200, 100);
+        Comparison impl = example(AbstractCompareCriteria.GE, 200, 100);
         assertNotNull(impl.getRightExpression());
-        assertTrue(impl.getRightExpression() instanceof LiteralImpl);
-        assertEquals(new Integer(100), ((LiteralImpl)impl.getRightExpression()).getValue());
+        assertTrue(impl.getRightExpression() instanceof Literal);
+        assertEquals(new Integer(100), ((Literal)impl.getRightExpression()).getValue());
     }
 
     public void testGetOperator() throws Exception {
-        assertEquals(Operator.EQ, example(CompareCriteria.EQ, 200, 100).getOperator());
-        assertEquals(Operator.GE, example(CompareCriteria.GE, 200, 100).getOperator());
-        assertEquals(Operator.GT, example(CompareCriteria.GT, 200, 100).getOperator());
-        assertEquals(Operator.LE, example(CompareCriteria.LE, 200, 100).getOperator());
-        assertEquals(Operator.LT, example(CompareCriteria.LT, 200, 100).getOperator());
-        assertEquals(Operator.NE, example(CompareCriteria.NE, 200, 100).getOperator());
+        assertEquals(Operator.EQ, example(AbstractCompareCriteria.EQ, 200, 100).getOperator());
+        assertEquals(Operator.GE, example(AbstractCompareCriteria.GE, 200, 100).getOperator());
+        assertEquals(Operator.GT, example(AbstractCompareCriteria.GT, 200, 100).getOperator());
+        assertEquals(Operator.LE, example(AbstractCompareCriteria.LE, 200, 100).getOperator());
+        assertEquals(Operator.LT, example(AbstractCompareCriteria.LT, 200, 100).getOperator());
+        assertEquals(Operator.NE, example(AbstractCompareCriteria.NE, 200, 100).getOperator());
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,17 +22,14 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import java.util.Iterator;
+import junit.framework.TestCase;
 
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.ICompoundCriteria.Operator;
-import org.teiid.dqp.internal.datamgr.language.CompoundCriteriaImpl;
+import org.teiid.connector.language.AndOr;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.AndOr.Operator;
 
 import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
 
-import junit.framework.TestCase;
-
 public class TestCompoundCriteriaImpl extends TestCase {
 
     /**
@@ -43,28 +40,25 @@
         super(name);
     }
 
-    public static CompoundCriteria helpExample(int operator) {
+    public static com.metamatrix.query.sql.lang.CompoundCriteria helpExample(int operator) {
         CompareCriteria c1 = TestCompareCriteriaImpl.helpExample(CompareCriteria.GE, 100, 200);
         CompareCriteria c2 = TestCompareCriteriaImpl.helpExample(CompareCriteria.LT, 500, 600);
-        return new CompoundCriteria(operator, c1, c2);
+        return new com.metamatrix.query.sql.lang.CompoundCriteria(operator, c1, c2);
     }
     
-    public static CompoundCriteriaImpl example(int operator) throws Exception {
-        return (CompoundCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(operator));
+    public static AndOr example(int operator) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(operator));
     }
 
     public void testGetOperator() throws Exception {
-        assertEquals(Operator.AND, example(CompoundCriteria.AND).getOperator());
-        assertEquals(Operator.OR, example(CompoundCriteria.OR).getOperator());
+        assertEquals(Operator.AND, example(com.metamatrix.query.sql.lang.CompoundCriteria.AND).getOperator());
+        assertEquals(Operator.OR, example(com.metamatrix.query.sql.lang.CompoundCriteria.OR).getOperator());
     }
 
     public void testGetCriteria() throws Exception {
-        CompoundCriteriaImpl cc = example(CompoundCriteria.AND);
-        assertNotNull(cc.getCriteria());
-        assertEquals(2, cc.getCriteria().size());
-        for (Iterator i = cc.getCriteria().iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof ICriteria);
-        }
+        AndOr cc = example(com.metamatrix.query.sql.lang.CompoundCriteria.AND);
+        assertTrue(cc.getLeftCondition() instanceof Comparison);
+        assertTrue(cc.getRightCondition() instanceof Comparison);
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,13 +22,13 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.DeleteImpl;
 
+import junit.framework.TestCase;
+
+import org.teiid.connector.language.Delete;
+
 import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Delete;
 
-import junit.framework.TestCase;
-
 public class TestDeleteImpl extends TestCase {
 
     /**
@@ -39,21 +39,21 @@
         super(name);
     }
 
-    public static Delete helpExample() {
-        return new Delete(TestGroupImpl.helpExample("vm1.g1"), //$NON-NLS-1$
+    public static com.metamatrix.query.sql.lang.Delete helpExample() {
+        return new com.metamatrix.query.sql.lang.Delete(TestGroupImpl.helpExample("vm1.g1"), //$NON-NLS-1$
                           TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND));
     }
     
-    public static DeleteImpl example() throws Exception {
-        return (DeleteImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static Delete example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetGroup() throws Exception {
-        assertNotNull(example().getGroup());
+        assertNotNull(example().getTable());
     }
 
     public void testGetCriteria() throws Exception {
-        assertNotNull(example().getCriteria());
+        assertNotNull(example().getWhere());
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,13 +24,10 @@
 
 import junit.framework.TestCase;
 
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.metadata.runtime.Element;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.NamedTable;
 
-import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
 import com.metamatrix.query.unittest.FakeMetadataObject;
 
 public class TestElementImpl extends TestCase {
@@ -75,12 +72,12 @@
         return symbol;
     }
     
-    public static ElementImpl example(String groupName, String elementName) throws Exception {
-        return (ElementImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName, elementName));
+    public static ColumnReference example(String groupName, String elementName) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, elementName));
     }
     
-    public static ElementImpl example(String groupName, String elementName, Object metadataID) throws Exception {
-        return (ElementImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName, elementName, metadataID));
+    public static ColumnReference example(String groupName, String elementName, Object metadataID) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, elementName, metadataID));
     }
     
     public void testGetName() throws Exception {
@@ -90,30 +87,15 @@
 
     public void testGetGroup() throws Exception {
         Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e1"); //$NON-NLS-1$
-        assertNotNull(example("pm1.g1", "e1", metadataID).getGroup()); //$NON-NLS-1$ //$NON-NLS-2$
+        assertNotNull(example("pm1.g1", "e1", metadataID).getTable()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testGetMetadataID() throws Exception {
-        FakeMetadataObject group = FakeMetadataFactory.createPhysicalGroup("pm1.g1", FakeMetadataFactory.createPhysicalModel("pm1.g1")); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject metadataID = FakeMetadataFactory.createElement("e", group, DataTypeManager.DefaultDataTypes.STRING, 0); //$NON-NLS-1$
-        assertNotNull(example("pm1.g1", "e", metadataID).getMetadataObject()); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
     public void testGetType() throws Exception {
         Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e2"); //$NON-NLS-1$
         assertTrue(example("pm1.g1", "e2", metadataID).getType().equals(Integer.class)); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testSetMetadataID() throws Exception {
-        Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e1"); //$NON-NLS-1$
-        ElementImpl element = example("pm1.g1", "e1", metadataID); //$NON-NLS-1$ //$NON-NLS-2$
-        Element elem = TstLanguageBridgeFactory.metadataFactory.getElement(metadataID);
-        element.setMetadataObject(elem);
-        assertNotNull(element.getMetadataObject());
-        assertEquals(elem, element.getMetadataObject());
-    }
-    
-    public void helpTestEquals(IElement e1, IElement e2, boolean equal) {
+    public void helpTestEquals(ColumnReference e1, ColumnReference e2, boolean equal) {
         boolean actual = e1.equals(e2);
         boolean actual2 = e2.equals(e1);
         
@@ -121,53 +103,12 @@
         assertEquals("Did not get expected equal value", equal, actual); //$NON-NLS-1$
     }
     
-    public IGroup createGroup(String context, String definition) {
-        return new GroupImpl(context, definition, null);
+    public NamedTable createGroup(String context, String definition) {
+        return new NamedTable(context, definition, null);
     }
     
-    public IElement createElement(IGroup group, String name) {
-        return new ElementImpl(group, name, null, String.class);
+    public ColumnReference createElement(NamedTable group, String name) {
+        return new ColumnReference(group, name, null, String.class);
     }
-    
-    public void testEquals1() {
-        IElement e1 = createElement(createGroup("a", "m.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        helpTestEquals(e1, e1, true);
-    }
-
-    public void testEquals2() {
-        IElement e1 = createElement(createGroup("a", "m.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        IElement e2 = createElement(createGroup("a", "m.g"), "e2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        helpTestEquals(e1, e2, false);
-    }
-
-    public void testEquals3() {
-        IElement e1 = createElement(createGroup("a", "m.g1"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        IElement e2 = createElement(createGroup("a", "m.g2"), "e2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        helpTestEquals(e1, e2, false);
-    }
-
-    public void testEquals4() {
-        IElement e1 = createElement(createGroup("a", "m.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        IElement e2 = createElement(createGroup("b", "m.g"), "e2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        helpTestEquals(e1, e2, false);
-    }
-
-    public void testEquals5() {
-        IElement e1 = createElement(createGroup("m.g1", null), "e1"); //$NON-NLS-1$ //$NON-NLS-2$
-        IElement e2 = createElement(createGroup("m.g1", null), "e1"); //$NON-NLS-1$ //$NON-NLS-2$
-        helpTestEquals(e1, e2, true);
-    }
-
-    public void testEquals6() {
-        IElement e1 = createElement(createGroup("a", "M.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        IElement e2 = createElement(createGroup("a", "m.G"), "E1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        helpTestEquals(e1, e2, true);
-    }
-
-    public void testEquals7() {
-        IElement e1 = createElement(createGroup("a", "m.g"), "m.g.e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        IElement e2 = createElement(createGroup("a", "m.g"), "e1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        helpTestEquals(e1, e2, true);
-    }
-
+   
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.ExistsCriteriaImpl;
 
+import org.teiid.connector.language.Exists;
+
 import com.metamatrix.query.sql.lang.ExistsCriteria;
 
 import junit.framework.TestCase;
@@ -41,16 +42,16 @@
     }
 
     public static ExistsCriteria helpExample() {
-        ExistsCriteria crit = new ExistsCriteria(TestQueryImpl.helpExample());
+        ExistsCriteria crit = new ExistsCriteria(TestQueryImpl.helpExample(true));
         return crit;
     }
     
-    public static ExistsCriteriaImpl example() throws Exception {
-        return (ExistsCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static Exists example() throws Exception {
+        return (Exists)TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetQuery() throws Exception {
-        assertNotNull(example().getQuery());    
+        assertNotNull(example().getSubquery());    
     }
     
 }

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.connector.language.IFromItem;
-import org.teiid.dqp.internal.datamgr.language.FromImpl;
-
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-
-import junit.framework.TestCase;
-
-public class TestFromImpl extends TestCase {
-
-    /**
-     * Constructor for TestFromImpl.
-     * @param name
-     */
-    public TestFromImpl(String name) {
-        super(name);
-    }
-    
-    public static From helpExample() {
-        List clauses = new ArrayList();
-        clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g1"))); //$NON-NLS-1$
-        clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("myAlias", "vm1.g2"))); //$NON-NLS-1$ //$NON-NLS-2$
-        clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g3"))); //$NON-NLS-1$
-        clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g4"))); //$NON-NLS-1$
-        return new From(clauses);
-    }
-    
-    public static FromImpl example() throws Exception {
-        return (FromImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
-    }
-
-    public void testGetItems() throws Exception {
-        FromImpl from = example();
-        assertNotNull(from.getItems());
-        assertEquals(4, from.getItems().size());
-        for (Iterator i = from.getItems().iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof IFromItem);
-        }
-    }
-
-}

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,15 +24,13 @@
 
 import java.util.List;
 
-import org.teiid.connector.language.IExpression;
-import org.teiid.dqp.internal.datamgr.language.FunctionImpl;
+import junit.framework.TestCase;
 
+import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.Function;
+
 import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
 
-import junit.framework.TestCase;
-
 public class TestFunctionImpl extends TestCase {
 
     /**
@@ -43,16 +41,16 @@
         super(name);
     }
 
-    public static Function helpExample(String name) {
+    public static com.metamatrix.query.sql.symbol.Function helpExample(String name) {
         Constant c1 = new Constant(new Integer(100));
         Constant c2 = new Constant(new Integer(200));
-        Function f = new Function(name, new Expression [] {c1, c2});
+        com.metamatrix.query.sql.symbol.Function f = new com.metamatrix.query.sql.symbol.Function(name, new com.metamatrix.query.sql.symbol.Expression[] {c1, c2});
         f.setType(Integer.class);
         return f;
     }
     
-    public static FunctionImpl example(String name) throws Exception {
-        return (FunctionImpl)TstLanguageBridgeFactory.factory.translate(helpExample(name));
+    public static Function example(String name) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(name));
     }
 
     public void testGetName() throws Exception {
@@ -60,7 +58,7 @@
     }
 
     public void testGetParameters() throws Exception {
-        List<IExpression> params = example("testFunction").getParameters(); //$NON-NLS-1$
+        List<Expression> params = example("testFunction").getParameters(); //$NON-NLS-1$
         assertNotNull(params);
         assertEquals(2, params.size());
         for (int i = 0; i < params.size(); i++) {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,16 +26,15 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.teiid.connector.language.IElement;
-import org.teiid.dqp.internal.datamgr.language.GroupByImpl;
+import junit.framework.TestCase;
 
-import com.metamatrix.query.sql.lang.GroupBy;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.GroupBy;
+
 import com.metamatrix.query.sql.symbol.ElementSymbol;
 import com.metamatrix.query.sql.symbol.Expression;
 import com.metamatrix.query.sql.symbol.Function;
 
-import junit.framework.TestCase;
-
 public class TestGroupByImpl extends TestCase {
 
     /**
@@ -46,37 +45,37 @@
         super(name);
     }
 
-    public static GroupBy helpExample() {
-        List symbols = new ArrayList();
+    public static com.metamatrix.query.sql.lang.GroupBy helpExample() {
+        List<ElementSymbol> symbols = new ArrayList<ElementSymbol>();
         symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
         symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
         symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
         symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
-        return new GroupBy(symbols);
+        return new com.metamatrix.query.sql.lang.GroupBy(symbols);
     }
 
-    public static GroupBy helpExampleWithFunctions() {
-        List symbols = new ArrayList();
+    public static com.metamatrix.query.sql.lang.GroupBy helpExampleWithFunctions() {
+        List<Expression> symbols = new ArrayList<Expression>();
         
         ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1");//$NON-NLS-1$ //$NON-NLS-2$
         Function f = new Function("length", new Expression[] { e1 } );//$NON-NLS-1$ 
         
         symbols.add(e1); 
         symbols.add(f);
-        return new GroupBy(symbols);
+        return new com.metamatrix.query.sql.lang.GroupBy(symbols);
     }
     
 
-    public static GroupByImpl example() throws Exception {
-        return (GroupByImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static GroupBy example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetElements() throws Exception {
-        GroupByImpl gb = example();
+        GroupBy gb = example();
         assertNotNull(gb.getElements());
         assertEquals(4, gb.getElements().size());
         for (Iterator i = gb.getElements().iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof IElement);
+            assertTrue(i.next() instanceof ColumnReference);
         }
     }
     

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.GroupImpl;
 
+import org.teiid.connector.language.NamedTable;
+
 import junit.framework.TestCase;
 
 import com.metamatrix.query.sql.symbol.GroupSymbol;
@@ -58,74 +59,26 @@
         return symbol;
     }
     
-    public static GroupImpl example(String groupName) throws Exception {
+    public static NamedTable example(String groupName) throws Exception {
         return example(groupName, null);
     }
 
-    public static GroupImpl example(String groupName, String definition) throws Exception {
-        return (GroupImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName, definition));
+    public static NamedTable example(String groupName, String definition) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, definition));
     }
 
-    public static GroupImpl example(String groupName, String definition, Object metadataID) throws Exception {
-        return (GroupImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName, definition, metadataID));
+    public static NamedTable example(String groupName, String definition, Object metadataID) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, definition, metadataID));
     }
 
     public void testGetContext() throws Exception {
         Object metadataID = TstLanguageBridgeFactory.metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
-        assertEquals("x", example("x", "pm1.g1", metadataID).getContext()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        assertEquals("x", example("x", "pm1.g1", metadataID).getCorrelationName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testGetDefinition() throws Exception {
         Object metadataID = TstLanguageBridgeFactory.metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
-        assertEquals("pm1.g1", example("x", "pm1.g1", metadataID).getDefinition()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        assertEquals("pm1.g1", example("x", "pm1.g1", metadataID).getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testEquals1() throws Exception {
-        GroupImpl g1 = new GroupImpl("alias", "pm1.g1", null); //$NON-NLS-1$ //$NON-NLS-2$
-        GroupImpl g2 = new GroupImpl("alias", "pm1.g1", null); //$NON-NLS-1$ //$NON-NLS-2$
-        
-        assertEquals(g1,g2);
-    }
-
-    public void testEquals2() throws Exception {
-        GroupImpl g1 = new GroupImpl("alias", "model.group1", null); //$NON-NLS-1$ //$NON-NLS-2$
-        GroupImpl g2 = new GroupImpl("alias", "model.group2", null); //$NON-NLS-1$ //$NON-NLS-2$
-        
-        assertEquals(g1,g2);
-    }
-
-    public void testEquals3() {
-        GroupImpl g1 = new GroupImpl("alias1", "model.group", null); //$NON-NLS-1$ //$NON-NLS-2$
-        GroupImpl g2 = new GroupImpl("alias2", "model.group", null); //$NON-NLS-1$ //$NON-NLS-2$
-        
-        assertTrue(! g1.equals(g2));
-    }
-
-    public void testEquals4() {
-        GroupImpl g1 = new GroupImpl("alias1", "model.group", null);   //$NON-NLS-1$ //$NON-NLS-2$
-              
-        assertEquals(g1, g1);
-    }
-
-    public void testEquals5() {
-        GroupImpl g1 = new GroupImpl("model.group", null, null); //$NON-NLS-1$
-        GroupImpl g2 = new GroupImpl("model.group", null, null); //$NON-NLS-1$
-        
-        assertEquals(g1, g2);
-    }
-
-    public void testEquals6() {
-        GroupImpl g1 = new GroupImpl("model.gRoUp", null, null); //$NON-NLS-1$
-        GroupImpl g2 = new GroupImpl("MoDeL.group", null, null); //$NON-NLS-1$
-        
-        assertEquals(g1, g2);
-    }
-
-    public void testEquals7() {
-        GroupImpl g1 = new GroupImpl("model.gRoUp", "alias", null); //$NON-NLS-1$ //$NON-NLS-2$
-        GroupImpl g2 = new GroupImpl("MoDeL.group", null, null); //$NON-NLS-1$
-        
-        assertTrue(! g1.equals(g2));
-    }
-
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,9 +26,9 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.dqp.internal.datamgr.language.InCriteriaImpl;
+import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.In;
 
 import com.metamatrix.query.sql.lang.SetCriteria;
 
@@ -55,15 +55,15 @@
         return crit;
     }
     
-    public static InCriteriaImpl example(boolean negated) throws Exception {
-        return (InCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(negated));
+    public static In example(boolean negated) throws Exception {
+        return (In)TstLanguageBridgeFactory.factory.translate(helpExample(negated));
     }
 
     public void testGetLeftExpression() throws Exception {
-        InCriteriaImpl inCriteria = example(false);
+        In inCriteria = example(false);
         assertNotNull(inCriteria.getLeftExpression());
-        assertTrue(inCriteria.getLeftExpression() instanceof ILiteral);
-        assertEquals(new Integer(300), ((ILiteral)inCriteria.getLeftExpression()).getValue());
+        assertTrue(inCriteria.getLeftExpression() instanceof Literal);
+        assertEquals(new Integer(300), ((Literal)inCriteria.getLeftExpression()).getValue());
     }
 
     public void testGetRightExpressions() throws Exception {
@@ -71,7 +71,7 @@
         assertNotNull(values);
         assertEquals(4, values.size());
         for (Iterator i = values.iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof IExpression);
+            assertTrue(i.next() instanceof Expression);
         }
         
     }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.InlineViewImpl;
 
+import org.teiid.connector.language.DerivedTable;
+
 import com.metamatrix.query.sql.lang.SubqueryFromClause;
 
 import junit.framework.TestCase;
@@ -35,19 +36,19 @@
     }
 
     public static SubqueryFromClause helpExample() {
-        return new SubqueryFromClause("xyz", TestQueryImpl.helpExample()); //$NON-NLS-1$
+        return new SubqueryFromClause("xyz", TestQueryImpl.helpExample(true)); //$NON-NLS-1$
     }
     
-    public static InlineViewImpl example() throws Exception {
-        return (InlineViewImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static DerivedTable example() throws Exception {
+        return (DerivedTable)TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetName() throws Exception {
-        assertEquals("xyz", example().getName()); //$NON-NLS-1$
+        assertEquals("xyz", example().getCorrelationName()); //$NON-NLS-1$
     }
 
     public void testGetQuery() throws Exception {
-        assertEquals("SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE (100 >= 200) AND (500 < 600) GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING (100 >= 200) AND (500 < 600) ORDER BY e1, e2 DESC, e3, e4 DESC", example().getQuery().toString()); //$NON-NLS-1$
+        assertEquals("SELECT DISTINCT vm1.g1.e1, vm1.g1.e2, vm1.g1.e3, vm1.g1.e4 FROM vm1.g1, vm1.g2 AS myAlias, vm1.g3, vm1.g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY vm1.g1.e1, vm1.g1.e2, vm1.g1.e3, vm1.g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC", example().getQuery().toString()); //$NON-NLS-1$
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,16 +25,17 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.dqp.internal.datamgr.language.InsertImpl;
+import junit.framework.TestCase;
 
-import com.metamatrix.query.sql.lang.Insert;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.ExpressionValueSource;
+import org.teiid.connector.language.Insert;
+
+import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 
-import junit.framework.TestCase;
-
 public class TestInsertImpl extends TestCase {
 
     /**
@@ -45,26 +46,26 @@
         super(name);
     }
 
-    public static Insert helpExample(String groupName) {
+    public static com.metamatrix.query.sql.lang.Insert helpExample(String groupName) {
         GroupSymbol group = TestGroupImpl.helpExample(groupName);
-        ArrayList elements = new ArrayList();
+        ArrayList<ElementSymbol> elements = new ArrayList<ElementSymbol>();
         elements.add(TestElementImpl.helpExample(groupName, "e1")); //$NON-NLS-1$
         elements.add(TestElementImpl.helpExample(groupName, "e2")); //$NON-NLS-1$
         elements.add(TestElementImpl.helpExample(groupName, "e3")); //$NON-NLS-1$
         elements.add(TestElementImpl.helpExample(groupName, "e4")); //$NON-NLS-1$
         
-        ArrayList values = new ArrayList();
+        ArrayList<Constant> values = new ArrayList<Constant>();
         values.add(TestLiteralImpl.helpExample(1));
         values.add(TestLiteralImpl.helpExample(2));
         values.add(TestLiteralImpl.helpExample(3));
         values.add(TestLiteralImpl.helpExample(4));
         
-        return new Insert(group,
+        return new com.metamatrix.query.sql.lang.Insert(group,
                           elements,
                           values);
     }
     
-    public static Insert helpExample2(String groupName) {
+    public static com.metamatrix.query.sql.lang.Insert helpExample2(String groupName) {
         GroupSymbol group = TestGroupImpl.helpExample(groupName);
         ArrayList elements = new ArrayList();
         elements.add(TestElementImpl.helpExample(groupName, "e1")); //$NON-NLS-1$
@@ -72,56 +73,56 @@
         ArrayList values = new ArrayList();
         values.add(TestSearchedCaseExpressionImpl.helpExample());
         
-        return new Insert(group,
+        return new com.metamatrix.query.sql.lang.Insert(group,
                           elements,
                           values);
     }
   
-    public static InsertImpl example(String groupName) throws Exception {
-        return (InsertImpl)TstLanguageBridgeFactory.factory.translate(helpExample(groupName));
+    public static Insert example(String groupName) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(groupName));
         
     }
-    public static InsertImpl example2(String groupName) throws Exception {
-        return (InsertImpl)TstLanguageBridgeFactory.factory.translate(helpExample2(groupName));
+    public static Insert example2(String groupName) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample2(groupName));
         
     }
     public void testGetGroup() throws Exception {
-        assertNotNull(example("a.b").getGroup()); //$NON-NLS-1$
+        assertNotNull(example("a.b").getTable()); //$NON-NLS-1$
     }
 
     public void testGetElements() throws Exception {
-        InsertImpl insert = example("a.b"); //$NON-NLS-1$
-        assertNotNull(insert.getElements());
-        assertEquals(4, insert.getElements().size());
-        for (Iterator i = insert.getElements().iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof IElement);
+        Insert insert = example("a.b"); //$NON-NLS-1$
+        assertNotNull(insert.getColumns());
+        assertEquals(4, insert.getColumns().size());
+        for (Iterator i = insert.getColumns().iterator(); i.hasNext();) {
+            assertTrue(i.next() instanceof ColumnReference);
         }
 
         // verify that elements are not qualified by group
         String sInsertSQL = insert.toString();
-        assertTrue(sInsertSQL.indexOf( '.') == -1 );                        
+        assertTrue(sInsertSQL.substring(sInsertSQL.indexOf('(')).indexOf( '.') == -1 );                        
     }
 
     public void testGetValues() throws Exception {
-        InsertImpl insert = example("a.b"); //$NON-NLS-1$
+        Insert insert = example("a.b"); //$NON-NLS-1$
         assertNotNull(insert.getValueSource());
-        assertEquals(4, ((IInsertExpressionValueSource)insert.getValueSource()).getValues().size());
-        for (Iterator i = ((IInsertExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof IExpression);
+        assertEquals(4, ((ExpressionValueSource)insert.getValueSource()).getValues().size());
+        for (Iterator i = ((ExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
+            assertTrue(i.next() instanceof Expression);
         }
     }
     
     public void testExpressionsInInsert() throws Exception {
-        InsertImpl insert = example2("a.b"); //$NON-NLS-1$
-        assertNotNull(insert.getElements());
-        assertEquals(1, insert.getElements().size());
-        for (Iterator i = insert.getElements().iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof IElement);
+        Insert insert = example2("a.b"); //$NON-NLS-1$
+        assertNotNull(insert.getColumns());
+        assertEquals(1, insert.getColumns().size());
+        for (Iterator i = insert.getColumns().iterator(); i.hasNext();) {
+            assertTrue(i.next() instanceof ColumnReference);
         }
         assertNotNull(insert.getValueSource());
-        assertEquals(1, ((IInsertExpressionValueSource)insert.getValueSource()).getValues().size());
-        for (Iterator i = ((IInsertExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof IExpression);
+        assertEquals(1, ((ExpressionValueSource)insert.getValueSource()).getValues().size());
+        for (Iterator i = ((ExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
+            assertTrue(i.next() instanceof Expression);
         }
     }
 

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.IsNullCriteriaImpl;
 
+import org.teiid.connector.language.IsNull;
+
 import com.metamatrix.query.sql.lang.IsNullCriteria;
 
 import junit.framework.TestCase;
@@ -39,13 +40,13 @@
     }
 
     public static IsNullCriteria helpExample(boolean negated) {
-        IsNullCriteria crit = new IsNullCriteria(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
+    	IsNullCriteria crit = new IsNullCriteria(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
         crit.setNegated(negated);
         return crit;
     }
     
-    public static IsNullCriteriaImpl example(boolean negated) throws Exception {
-        return (IsNullCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(negated));
+    public static IsNull example(boolean negated) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(negated));
     }
 
     public void testGetExpression() throws Exception {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -23,19 +23,18 @@
 package org.teiid.dqp.internal.datamgr.language;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 
-import org.teiid.connector.language.ICriteria;
-import org.teiid.dqp.internal.datamgr.language.JoinImpl;
+import junit.framework.TestCase;
 
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Join;
+
 import com.metamatrix.query.sql.lang.CompareCriteria;
 import com.metamatrix.query.sql.lang.JoinPredicate;
 import com.metamatrix.query.sql.lang.JoinType;
 import com.metamatrix.query.sql.lang.UnaryFromClause;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
 
-import junit.framework.TestCase;
-
 public class TestJoinImpl extends TestCase {
 
     /**
@@ -57,8 +56,8 @@
                                  criteria);
     }
     
-    public static JoinImpl example(JoinType type) throws Exception {
-        return (JoinImpl)TstLanguageBridgeFactory.factory.translate(helpExample(type));
+    public static Join example(JoinType type) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(type));
     }
 
     public void testGetLeftItem() throws Exception {
@@ -70,20 +69,16 @@
     }
 
     public void testGetJoinType() throws Exception {
-        assertEquals(org.teiid.connector.language.IJoin.JoinType.CROSS_JOIN, example(JoinType.JOIN_CROSS).getJoinType());
-        assertEquals(org.teiid.connector.language.IJoin.JoinType.FULL_OUTER_JOIN, example(JoinType.JOIN_FULL_OUTER).getJoinType());
-        assertEquals(org.teiid.connector.language.IJoin.JoinType.INNER_JOIN, example(JoinType.JOIN_INNER).getJoinType());
-        assertEquals(org.teiid.connector.language.IJoin.JoinType.LEFT_OUTER_JOIN, example(JoinType.JOIN_LEFT_OUTER).getJoinType());
-        assertEquals(org.teiid.connector.language.IJoin.JoinType.RIGHT_OUTER_JOIN, example(JoinType.JOIN_RIGHT_OUTER).getJoinType());
+        assertEquals(Join.JoinType.CROSS_JOIN, example(JoinType.JOIN_CROSS).getJoinType());
+        assertEquals(Join.JoinType.FULL_OUTER_JOIN, example(JoinType.JOIN_FULL_OUTER).getJoinType());
+        assertEquals(Join.JoinType.INNER_JOIN, example(JoinType.JOIN_INNER).getJoinType());
+        assertEquals(Join.JoinType.LEFT_OUTER_JOIN, example(JoinType.JOIN_LEFT_OUTER).getJoinType());
+        assertEquals(Join.JoinType.RIGHT_OUTER_JOIN, example(JoinType.JOIN_RIGHT_OUTER).getJoinType());
     }
 
     public void testGetCriteria() throws Exception {
-        JoinImpl join = example(JoinType.JOIN_INNER);
-        assertNotNull(join.getCriteria());
-        assertEquals(1, join.getCriteria().size());
-        for (Iterator i = join.getCriteria().iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof ICriteria);
-        }
+        Join join = example(JoinType.JOIN_INNER);
+        assertTrue(join.getCondition() instanceof Comparison);
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,8 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.connector.language.ILiteral;
-import org.teiid.dqp.internal.datamgr.language.LikeCriteriaImpl;
+import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.Like;
 
 import com.metamatrix.query.sql.lang.MatchCriteria;
 import com.metamatrix.query.sql.symbol.Constant;
@@ -48,8 +48,8 @@
         return match;
     }
     
-    public static LikeCriteriaImpl example(String right, char escape, boolean negated) throws Exception {
-        return (LikeCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample(right, escape, negated));
+    public static Like example(String right, char escape, boolean negated) throws Exception {
+        return (Like)TstLanguageBridgeFactory.factory.translate(helpExample(right, escape, negated));
     }
 
     public void testGetLeftExpression() throws Exception {
@@ -57,10 +57,10 @@
     }
 
     public void testGetRightExpression() throws Exception {
-        LikeCriteriaImpl like = example("abc", '.', false); //$NON-NLS-1$
+        Like like = example("abc", '.', false); //$NON-NLS-1$
         assertNotNull(like.getRightExpression());
-        assertTrue(like.getRightExpression() instanceof ILiteral);
-        assertEquals("abc", ((ILiteral)like.getRightExpression()).getValue()); //$NON-NLS-1$
+        assertTrue(like.getRightExpression() instanceof Literal);
+        assertEquals("abc", ((Literal)like.getRightExpression()).getValue()); //$NON-NLS-1$
     }
 
     public void testGetEscapeCharacter() throws Exception {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.LiteralImpl;
 
+import org.teiid.connector.language.Literal;
+
 import com.metamatrix.query.sql.symbol.Constant;
 
 import junit.framework.TestCase;
@@ -46,14 +47,14 @@
         return new Constant(val);
     }
     
-    public static LiteralImpl example(int val) {
+    public static Literal example(int val) {
         Constant c = helpExample(val);
-        return new LiteralImpl(c.getValue(), c.getType());
+        return new Literal(c.getValue(), c.getType());
     }
 
-    public static LiteralImpl example(Object val) {
+    public static Literal example(Object val) {
         Constant c = helpExample(val);
-        return new LiteralImpl(c.getValue(), c.getType());
+        return new Literal(c.getValue(), c.getType());
     }
 
     public void testGetValue() {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.NotCriteriaImpl;
 
+import org.teiid.connector.language.Not;
+
 import com.metamatrix.query.sql.lang.CompareCriteria;
 import com.metamatrix.query.sql.lang.NotCriteria;
 
@@ -43,8 +44,8 @@
         return new NotCriteria(TestCompareCriteriaImpl.helpExample(CompareCriteria.GE, 100, 200));
     }
     
-    public static NotCriteriaImpl example() throws Exception {
-        return (NotCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static Not example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetCriteria() throws Exception {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -26,13 +26,11 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.dqp.internal.datamgr.language.OrderByImpl;
-
-import com.metamatrix.query.sql.lang.OrderBy;
-
 import junit.framework.TestCase;
 
+import org.teiid.connector.language.OrderBy;
+import org.teiid.connector.language.SortSpecification;
+
 public class TestOrderByImpl extends TestCase {
 
     /**
@@ -43,7 +41,7 @@
         super(name);
     }
 
-    public static OrderBy helpExample() {
+    public static com.metamatrix.query.sql.lang.OrderBy helpExample() {
         ArrayList elements = new ArrayList();
         elements.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
         elements.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -55,19 +53,19 @@
         types.add(Boolean.FALSE);
         types.add(Boolean.TRUE);
         types.add(Boolean.FALSE);
-        return new OrderBy(elements, types);
+        return new com.metamatrix.query.sql.lang.OrderBy(elements, types);
     }
     
-    public static OrderByImpl example() throws Exception {
-        return (OrderByImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static OrderBy example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetItems() throws Exception {
-        List items = example().getItems();
+        List items = example().getSortSpecifications();
         assertNotNull(items);
         assertEquals(4, items.size());
         for (Iterator i = items.iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof IOrderByItem);
+            assertTrue(i.next() instanceof SortSpecification);
         }
         
     }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,15 +22,12 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import java.sql.ResultSet;
-
-import org.teiid.connector.language.IParameter.Direction;
-import org.teiid.dqp.internal.datamgr.language.ParameterImpl;
-import org.teiid.dqp.internal.datamgr.language.ProcedureImpl;
-
-
 import junit.framework.TestCase;
 
+import org.teiid.connector.language.Argument;
+import org.teiid.connector.language.Call;
+import org.teiid.connector.language.Argument.Direction;
+
 public class TestParameterImpl extends TestCase {
 
     /**
@@ -41,48 +38,24 @@
         super(name);
     }
 
-    public static ParameterImpl example(int index) throws Exception {
-        ProcedureImpl procImpl = TestProcedureImpl.example();
-        return (ParameterImpl) procImpl.getParameters().get(index);
+    public static Argument example(int index) throws Exception {
+        Call procImpl = TestProcedureImpl.example();
+        return procImpl.getArguments().get(index);
     }
 
-    public void testGetIndex() throws Exception {
-        assertEquals(2, example(1).getIndex());
-    }
-
     public void testGetDirection() throws Exception {
-        assertEquals(Direction.RESULT_SET, example(0).getDirection());
+        assertEquals(Direction.IN, example(0).getDirection());
         assertEquals(Direction.IN, example(1).getDirection());
-        assertEquals(Direction.IN, example(2).getDirection());
     }
 
     public void testGetType() throws Exception {
-        assertTrue(example(0).getType().equals(ResultSet.class));
-        assertTrue(example(1).getType().equals(String.class));
-        assertTrue(example(2).getType().equals(Integer.class));
+        assertTrue(example(0).getType().equals(String.class));
+        assertTrue(example(1).getType().equals(Integer.class));
     }
 
     public void testGetValue() throws Exception {
-        assertEquals("x", example(1).getValue()); //$NON-NLS-1$
-        assertEquals(new Integer(1), example(2).getValue());
+        assertEquals("x", example(0).getArgumentValue().getValue()); //$NON-NLS-1$
+        assertEquals(new Integer(1), example(1).getArgumentValue().getValue());
     }
     
-    public void testGetValueSpecified() throws Exception {
-        assertEquals(false, example(0).getValueSpecified());
-        
-        ParameterImpl param = new ParameterImpl(1, Direction.IN, null, String.class, null);
-        // Test construction state (null value)
-        assertEquals(false, param.getValueSpecified());
-        // Test value specified not set on null
-        param.setValue(null);
-        assertEquals(false, param.getValueSpecified());        
-        // Test value specified is set on actual value
-        param.setValue("RINGTAIL LEMUR"); //$NON-NLS-1$
-        assertEquals(true, param.getValueSpecified());
-        // Test value specified override
-        param.setValueSpecified(false); 
-        assertEquals(false, param.getValueSpecified());
-    }
-    
-
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,18 +22,15 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import java.util.Collections;
-import java.util.Iterator;
+import junit.framework.TestCase;
 
-import org.teiid.connector.language.IParameter;
-import org.teiid.dqp.internal.datamgr.language.ProcedureImpl;
+import org.teiid.connector.language.Call;
 
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.*;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.StoredProcedure;
 
-import junit.framework.TestCase;
-
 public class TestProcedureImpl extends TestCase {
 
     /**
@@ -42,14 +39,13 @@
      */
     public TestProcedureImpl(String name) {
         super(name);
-        System.setProperty("metamatrix.config.none", "true");
     }
 
-    public static ProcedureImpl example() throws Exception {
+    public static Call example() throws Exception {
         String sql = "EXEC pm1.sq3('x', 1)"; //$NON-NLS-1$
         Command command = new QueryParser().parseCommand(sql);
         QueryResolver.resolveCommand(command, TstLanguageBridgeFactory.metadata);                
-        return (ProcedureImpl)TstLanguageBridgeFactory.factory.translate((StoredProcedure)command);
+        return TstLanguageBridgeFactory.factory.translate((StoredProcedure)command);
     }
     
     public void testGetProcedureName() throws Exception {
@@ -57,24 +53,9 @@
     }
 
     public void testGetParameters() throws Exception {
-        ProcedureImpl exec = example();
-        assertNotNull(exec.getParameters());
-        assertEquals(3, exec.getParameters().size());
-        for (Iterator i = exec.getParameters().iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof IParameter);
-        }
+        Call exec = example();
+        assertNotNull(exec.getArguments());
+        assertEquals(2, exec.getArguments().size());
     }
     
-    public void testEquals1() {
-        ProcedureImpl proc1 = new ProcedureImpl("proc1", Collections.EMPTY_LIST, null); //$NON-NLS-1$
-        ProcedureImpl proc2 = new ProcedureImpl("proc1", Collections.EMPTY_LIST, null); //$NON-NLS-1$
-        assertEquals(proc1, proc2);        
-    }
-
-    public void testEquals2() {
-        ProcedureImpl proc1 = new ProcedureImpl("proc1", Collections.EMPTY_LIST, null); //$NON-NLS-1$
-        ProcedureImpl proc2 = new ProcedureImpl("proc2", Collections.EMPTY_LIST, null); //$NON-NLS-1$
-        assertTrue(! proc1.equals(proc2));        
-    }
-    
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,14 +22,22 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.QueryImpl;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.Select;
+
 import com.metamatrix.core.util.EquivalenceUtil;
 import com.metamatrix.query.sql.lang.CompoundCriteria;
 import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.UnaryFromClause;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
 
-import junit.framework.TestCase;
-
 public class TestQueryImpl extends TestCase {
 
     /**
@@ -39,10 +47,21 @@
     public TestQueryImpl(String name) {
         super(name);
     }
+    
+    public static com.metamatrix.query.sql.lang.Select helpExampleSelect(boolean distinct) {
+        ArrayList<ElementSymbol> symbols = new ArrayList<ElementSymbol>();
+        symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
+        symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
+        symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
+        symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
+        com.metamatrix.query.sql.lang.Select sel = new com.metamatrix.query.sql.lang.Select(symbols);
+        sel.setDistinct(distinct);
+        return sel;
+    }
 
-    public static Query helpExample() {
-        return new Query(TestSelectImpl.helpExample(true),
-                         TestFromImpl.helpExample(),
+    public static Query helpExample(boolean distinct) {
+        return new Query(helpExampleSelect(distinct),
+                         TestQueryImpl.helpExampleFrom(),
                          TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
                          TestGroupByImpl.helpExample(),
                          TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
@@ -50,44 +69,67 @@
                          null);
     }
     
-    public static QueryImpl example() throws Exception {
-        return (QueryImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static Select example(boolean distinct) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(distinct));
     }
 
     public void testGetSelect() throws Exception {
-        assertNotNull(example().getSelect());
+        assertNotNull(example(true).getDerivedColumns());
     }
 
     public void testGetFrom() throws Exception {
-        assertNotNull(example().getFrom());
+        assertNotNull(example(true).getFrom());
     }
 
     public void testGetWhere() throws Exception {
-        assertNotNull(example().getWhere());
+        assertNotNull(example(true).getWhere());
     }
 
     public void testGetGroupBy() throws Exception {
-        assertNotNull(example().getGroupBy());
+        assertNotNull(example(true).getGroupBy());
     }
 
     public void testGetHaving() throws Exception {
-        assertNotNull(example().getHaving());
+        assertNotNull(example(true).getHaving());
     }
 
     public void testGetOrderBy() throws Exception {
-        assertNotNull(example().getOrderBy());
+        assertNotNull(example(true).getOrderBy());
     }
     
     public void testGetColumnNames() throws Exception {
-        String[] expected = {"e1", "e2", "e3", "e4"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        String[] names = example().getColumnNames();
+        String[] expected = new String[4]; 
+        String[] names = example(true).getColumnNames();
         assertTrue(EquivalenceUtil.areEquivalent(expected, names));
     }
     
     public void testGetColumnTypes() throws Exception {
         Class[] expected = {String.class, String.class, String.class, String.class};
-        Class[] types = example().getColumnTypes();
+        Class[] types = example(true).getColumnTypes();
         assertTrue(EquivalenceUtil.areEquivalent(expected, types));
     }
 
+	public static com.metamatrix.query.sql.lang.From helpExampleFrom() {
+	    List<UnaryFromClause> clauses = new ArrayList<UnaryFromClause>();
+	    clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g1"))); //$NON-NLS-1$
+	    clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("myAlias", "vm1.g2"))); //$NON-NLS-1$ //$NON-NLS-2$
+	    clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g3"))); //$NON-NLS-1$
+	    clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g4"))); //$NON-NLS-1$
+	    return new com.metamatrix.query.sql.lang.From(clauses);
+	}
+	
+    public void testGetSelectSymbols() throws Exception {
+        List symbols = example(false).getDerivedColumns();
+        assertNotNull(symbols);
+        assertEquals(4, symbols.size());
+        for (Iterator i = symbols.iterator(); i.hasNext();) {
+            assertTrue(i.next() instanceof DerivedColumn);
+        }
+    }
+
+    public void testIsDistinct() throws Exception {
+        assertTrue(example(true).isDistinct());
+        assertFalse(example(false).isDistinct());
+    }
+
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,14 +22,12 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.dqp.internal.datamgr.language.ScalarSubqueryImpl;
-
 import junit.framework.TestCase;
 
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.ScalarSubquery;
+
 import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
 import com.metamatrix.query.sql.symbol.SingleElementSymbol;
 
 /**
@@ -44,24 +42,23 @@
         super(name);
     }
 
-    public static ScalarSubquery helpExample() {
-        Query query = TestQueryImpl.helpExample();
-        ScalarSubquery ss = new ScalarSubquery(query);
+    public static com.metamatrix.query.sql.symbol.ScalarSubquery helpExample() {
+        Query query = TestQueryImpl.helpExample(true);
+        com.metamatrix.query.sql.symbol.ScalarSubquery ss = new com.metamatrix.query.sql.symbol.ScalarSubquery(query);
         ss.setType(((SingleElementSymbol)query.getProjectedSymbols().get(0)).getType());
         return ss;
     }
     
-    public static ScalarSubqueryImpl example() throws Exception {
-        return (ScalarSubqueryImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static ScalarSubquery example() throws Exception {
+        return (ScalarSubquery)TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetQuery() throws Exception {
-        assertNotNull(example().getQuery());    }
+        assertNotNull(example().getSubquery());    }
     
     public void testGetType() throws Exception {
-        IQuery query = TstLanguageBridgeFactory.factory.translate(TestQueryImpl.helpExample());
-        Class firstSymbolType = ((ISelectSymbol) query.getSelect().getSelectSymbols().get(0)).getExpression().getType();
-                
+        Select query = TstLanguageBridgeFactory.factory.translate(TestQueryImpl.helpExample(true));
+        Class<?> firstSymbolType = query.getDerivedColumns().get(0).getExpression().getType();
         assertEquals("Got incorrect type", firstSymbolType, example().getType()); //$NON-NLS-1$
     }
     

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,8 +25,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.teiid.dqp.internal.datamgr.language.SearchedCaseExpressionImpl;
+import org.teiid.connector.language.SearchedCase;
 
+
 import com.metamatrix.query.sql.lang.CompareCriteria;
 import com.metamatrix.query.sql.symbol.Constant;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -60,8 +61,8 @@
         return caseExpr;
     }
     
-    public static SearchedCaseExpressionImpl example() throws Exception {
-        return (SearchedCaseExpressionImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static SearchedCase example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetElseExpression() throws Exception {
@@ -72,19 +73,19 @@
     }
 
     public void testGetThenExpression() throws Exception {
-        assertNotNull(example().getThenExpression(0));
-        assertNotNull(example().getThenExpression(1));
-        assertNotNull(example().getThenExpression(2));
+        assertNotNull(example().getCases().get(0));
+        assertNotNull(example().getCases().get(1));
+        assertNotNull(example().getCases().get(2));
     }
 
     public void testGetWhenCount() throws Exception {
-        assertEquals(3, example().getWhenCount());
+        assertEquals(3, example().getCases().size());
     }
 
     public void testGetWhenCriteria() throws Exception {
-        assertNotNull(example().getWhenCriteria(0));
-        assertNotNull(example().getWhenCriteria(1));
-        assertNotNull(example().getWhenCriteria(2));
+        assertNotNull(example().getCases().get(0));
+        assertNotNull(example().getCases().get(1));
+        assertNotNull(example().getCases().get(2));
     }
 
 }

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.dqp.internal.datamgr.language.SelectImpl;
-
-import com.metamatrix.query.sql.lang.Select;
-
-import junit.framework.TestCase;
-
-public class TestSelectImpl extends TestCase {
-
-    /**
-     * Constructor for TestSelectImpl.
-     * @param name
-     */
-    public TestSelectImpl(String name) {
-        super(name);
-    }
-
-    public static Select helpExample(boolean distinct) {
-        ArrayList symbols = new ArrayList();
-        symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
-        symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
-        symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
-        symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
-        Select sel = new Select(symbols);
-        sel.setDistinct(distinct);
-        return sel;
-    }
-    
-    public static SelectImpl example(boolean distinct) throws Exception {
-        return (SelectImpl)TstLanguageBridgeFactory.factory.translate(helpExample(distinct));
-    }
-
-    public void testGetSelectSymbols() throws Exception {
-        List symbols = example(false).getSelectSymbols();
-        assertNotNull(symbols);
-        assertEquals(4, symbols.size());
-        for (Iterator i = symbols.iterator(); i.hasNext();) {
-            assertTrue(i.next() instanceof ISelectSymbol);
-        }
-    }
-
-    public void testIsDistinct() throws Exception {
-        assertTrue(example(true).isDistinct());
-        assertFalse(example(false).isDistinct());
-    }
-
-}

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,12 +22,12 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.connector.language.IExpression;
-import org.teiid.dqp.internal.datamgr.language.SelectSymbolImpl;
+import junit.framework.TestCase;
 
-import com.metamatrix.query.sql.symbol.*;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.DerivedColumn;
 
-import junit.framework.TestCase;
+import com.metamatrix.common.types.DataTypeManager;
 
 public class TestSelectSymbolImpl extends TestCase {
 
@@ -39,39 +39,18 @@
         super(name);
     }
 
-    public static Expression helpExample(String name, String alias) {
-        SingleElementSymbol symbol = TestElementImpl.helpExample("vm1.g1", name); //$NON-NLS-1$
-
-        if (alias != null) {
-            return new AliasSymbol(alias, symbol);
-        }
-        return symbol;
-    }
-    
-    public static SelectSymbolImpl example(String symbolName, String alias) throws Exception {
-        Expression expr = helpExample(symbolName, alias);
-        IExpression iExp = TstLanguageBridgeFactory.factory.translate(expr);
-        String name = null;
-        if (expr instanceof Function) {
-            name = ((Function)expr).getName();
-        }else if (expr instanceof SingleElementSymbol) {
-            name = ((SingleElementSymbol)expr).getName();
-        }
-        SelectSymbolImpl selectSymbol = new SelectSymbolImpl(name, iExp);
-        if(expr instanceof AliasSymbol){
-            selectSymbol.setAlias(true);
-        }
+    public static DerivedColumn example(String symbolName, String alias) throws Exception {
+        DerivedColumn selectSymbol = new DerivedColumn(alias, new ColumnReference(null, symbolName, null, DataTypeManager.DefaultDataClasses.INTEGER));
         return selectSymbol;
     }
 
     public void testHasAlias() throws Exception {
-        assertTrue(example("testName", "testAlias").hasAlias()); //$NON-NLS-1$ //$NON-NLS-2$
-        assertFalse(example("testName", null).hasAlias()); //$NON-NLS-1$
+        assertNotNull(example("testName", "testAlias").getAlias()); //$NON-NLS-1$ //$NON-NLS-2$
+        assertNull(example("testName", null).getAlias()); //$NON-NLS-1$
     }
 
     public void testGetOutputName() throws Exception {
-        assertEquals("testName", example("testName", null).getOutputName()); //$NON-NLS-1$ //$NON-NLS-2$
-        assertEquals("testAlias", example("testName", "testAlias").getOutputName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        assertEquals("testAlias", example("testName", "testAlias").getAlias()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testGetExpression() throws Exception {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,27 +25,17 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.teiid.connector.language.IElement;
-import org.teiid.connector.language.IGroup;
-import org.teiid.connector.language.IOrderByItem;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISetQuery;
-import org.teiid.dqp.internal.datamgr.language.ElementImpl;
-import org.teiid.dqp.internal.datamgr.language.FromImpl;
-import org.teiid.dqp.internal.datamgr.language.GroupImpl;
-import org.teiid.dqp.internal.datamgr.language.OrderByImpl;
-import org.teiid.dqp.internal.datamgr.language.OrderByItemImpl;
-import org.teiid.dqp.internal.datamgr.language.QueryImpl;
-import org.teiid.dqp.internal.datamgr.language.SelectImpl;
-import org.teiid.dqp.internal.datamgr.language.SelectSymbolImpl;
-import org.teiid.dqp.internal.datamgr.language.SetQueryImpl;
-
 import junit.framework.TestCase;
 
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SetQuery;
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.OrderBy;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.SetQuery;
+import org.teiid.connector.language.SortSpecification;
+import org.teiid.connector.language.SortSpecification.Ordering;
+
 import com.metamatrix.query.sql.lang.SetQuery.Operation;
 
 
@@ -54,57 +44,43 @@
  */
 public class TestSetQueryImpl extends TestCase {
 
-    public static Query helpExampleQuery() {
-        return new Query(TestSelectImpl.helpExample(true),
-                         TestFromImpl.helpExample(),
-                         TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
-                         TestGroupByImpl.helpExample(),
-                         TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
-                         TestOrderByImpl.helpExample(),
-                         null);
-    }
-    
-    public static SetQuery helpExampleSetQuery() {
-        SetQuery setQuery = new SetQuery(Operation.UNION);
+    public static com.metamatrix.query.sql.lang.SetQuery helpExampleSetQuery() {
+        com.metamatrix.query.sql.lang.SetQuery setQuery = new com.metamatrix.query.sql.lang.SetQuery(Operation.UNION);
         setQuery.setAll(false);
-        setQuery.setLeftQuery(helpExampleQuery());
-        setQuery.setRightQuery(helpExampleQuery());
+        setQuery.setLeftQuery(TestQueryImpl.helpExample(true));
+        setQuery.setRightQuery(TestQueryImpl.helpExample(true));
         setQuery.setOrderBy(TestOrderByImpl.helpExample());
         return setQuery;
     }
         
-    public static SetQueryImpl example() throws Exception {
-        return (SetQueryImpl)TstLanguageBridgeFactory.factory.translate(helpExampleSetQuery());
+    public static SetQuery example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExampleSetQuery());
     }
     
-    public static ISetQuery example2() throws Exception {
-        IGroup group = new GroupImpl("ted", null, null); //$NON-NLS-1$
-        IElement element = new ElementImpl(group, "nugent", null, String.class); //$NON-NLS-1$
-        ISelectSymbol symbol = new SelectSymbolImpl("nugent",element); //$NON-NLS-1$
+    public static SetQuery example2() throws Exception {
+        NamedTable group = new NamedTable("ted", null, null); //$NON-NLS-1$
+        ColumnReference element = new ColumnReference(group, "nugent", null, String.class); //$NON-NLS-1$
+        DerivedColumn symbol = new DerivedColumn("nugent",element); //$NON-NLS-1$
         List symbols = new ArrayList();
         symbols.add(symbol);
-        SelectImpl select = new SelectImpl(symbols, false);        
         List items = new ArrayList();
         items.add(group);
-        FromImpl from = new FromImpl(items);
         
-        IGroup group2 = new GroupImpl("dave", null, null); //$NON-NLS-1$
-        IElement element2 = new ElementImpl(group2, "barry", null, String.class); //$NON-NLS-1$
-        ISelectSymbol symbol2 = new SelectSymbolImpl("barry", element2); //$NON-NLS-1$
+        NamedTable group2 = new NamedTable("dave", null, null); //$NON-NLS-1$
+        ColumnReference element2 = new ColumnReference(group2, "barry", null, String.class); //$NON-NLS-1$
+        DerivedColumn symbol2 = new DerivedColumn("barry", element2); //$NON-NLS-1$
         List symbols2 = new ArrayList();
         symbols2.add(symbol2);
-        SelectImpl select2 = new SelectImpl(symbols2, false);
         
         List items2 = new ArrayList();
         items2.add(group2);
-        FromImpl from2 = new FromImpl(items2);
         
-        IQuery secondQuery = new QueryImpl(select2, from2, null, null, null, null);
+        Select secondQuery = new Select(symbols2, false, items2, null, null, null, null);
         
-        IQuery query = new QueryImpl(select, from, null, null, null, null);
+        Select query = new Select(symbols, false, items, null, null, null, null);
         
-        ISetQuery setQuery = new SetQueryImpl();
-        setQuery.setOperation(ISetQuery.Operation.UNION);
+        SetQuery setQuery = new SetQuery();
+        setQuery.setOperation(SetQuery.Operation.UNION);
         setQuery.setAll(true);
         setQuery.setLeftQuery(query);
         setQuery.setRightQuery(secondQuery);
@@ -112,27 +88,28 @@
         return setQuery;
     }
     
-    public static ISetQuery example3() throws Exception {
-        ISetQuery union = example2();
+    public static SetQuery example3() throws Exception {
+        SetQuery union = example2();
         
-        List items = new ArrayList();
-        IElement element = (IElement) ((ISelectSymbol) union.getProjectedQuery().getSelect().getSelectSymbols().get(0)).getExpression();
-        items.add(new OrderByItemImpl("ted.nugent", IOrderByItem.ASC, element)); //$NON-NLS-1$
-        OrderByImpl orderBy = new OrderByImpl(items);
+        List<SortSpecification> items = new ArrayList<SortSpecification>();
+        ColumnReference element = (ColumnReference) (union.getProjectedQuery().getDerivedColumns().get(0)).getExpression();
+        items.add(new SortSpecification(Ordering.ASC, element));
+        OrderBy orderBy = new OrderBy(items);
         
         union.setOrderBy(orderBy);
         return union;
     }
     
     public void testNestedSetQuery() throws Exception {
-        SetQuery query = new SetQuery(SetQuery.Operation.EXCEPT, true, helpExampleQuery(), helpExampleQuery());
+        com.metamatrix.query.sql.lang.SetQuery query = new com.metamatrix.query.sql.lang.SetQuery(com.metamatrix.query.sql.lang.SetQuery.Operation.EXCEPT, true, helpExampleSetQuery(), helpExampleSetQuery());
         
-        ISetQuery setQuery = TstLanguageBridgeFactory.factory.translate(query);
-        
+        SetQuery setQuery = TstLanguageBridgeFactory.factory.translate(query);
+        assertTrue(setQuery.getLeftQuery() instanceof SetQuery);
+        assertTrue(setQuery.getRightQuery() instanceof SetQuery);
     }
     
     public void testGetSelect() throws Exception {
-        assertNotNull(example().getProjectedQuery().getSelect());
+        assertNotNull(example().getProjectedQuery().getDerivedColumns());
     }
 
     public void testGetFrom() throws Exception {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,13 +22,13 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ISubqueryCompareCriteria.Quantifier;
-import org.teiid.dqp.internal.datamgr.language.SubqueryCompareCriteriaImpl;
-
 import junit.framework.TestCase;
 
-import com.metamatrix.query.sql.lang.CompareCriteria;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.SubqueryComparison;
+import org.teiid.connector.language.SubqueryComparison.Quantifier;
+
+import com.metamatrix.query.sql.lang.AbstractCompareCriteria;
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -47,13 +47,13 @@
 
     public static SubqueryCompareCriteria helpExample() {
         ElementSymbol element = TestElementImpl.helpExample("g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
-        Query query = TestQueryImpl.helpExample();
-        SubqueryCompareCriteria scc = new SubqueryCompareCriteria(element, query, CompareCriteria.GT, SubqueryCompareCriteria.ANY);
+        Query query = TestQueryImpl.helpExample(true);
+        SubqueryCompareCriteria scc = new SubqueryCompareCriteria(element, query, AbstractCompareCriteria.GT, SubqueryCompareCriteria.ANY);
         return scc;
     }
     
-    public static SubqueryCompareCriteriaImpl example() throws Exception {
-        return (SubqueryCompareCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static SubqueryComparison example() throws Exception {
+        return (SubqueryComparison)TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetExpression() throws Exception {
@@ -61,11 +61,11 @@
     }
 
     public void testGetQuery() throws Exception {
-        assertNotNull(example().getQuery());
+        assertNotNull(example().getSubquery());
     }
     
     public void testOperator() throws Exception {
-        assertEquals("Wrong operator", ICompareCriteria.Operator.GT, example().getOperator()); //$NON-NLS-1$
+        assertEquals("Wrong operator", Comparison.Operator.GT, example().getOperator()); //$NON-NLS-1$
     }
 
     public void testQuantifier() throws Exception {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,8 +22,9 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.SubqueryInCriteriaImpl;
 
+import org.teiid.connector.language.SubqueryIn;
+
 import junit.framework.TestCase;
 
 import com.metamatrix.query.sql.lang.Query;
@@ -44,14 +45,14 @@
 
     public static SubquerySetCriteria helpExample() {
         ElementSymbol element = TestElementImpl.helpExample("g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
-        Query query = TestQueryImpl.helpExample();
+        Query query = TestQueryImpl.helpExample(true);
         SubquerySetCriteria ssc = new SubquerySetCriteria(element, query);
         ssc.setNegated(true);
         return ssc;
     }
     
-    public static SubqueryInCriteriaImpl example() throws Exception {
-        return (SubqueryInCriteriaImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static SubqueryIn example() throws Exception {
+        return (SubqueryIn)TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetExpression() throws Exception {
@@ -59,7 +60,7 @@
     }
 
     public void testGetQuery() throws Exception {
-        assertNotNull(example().getQuery());
+        assertNotNull(example().getSubquery());
     }
     
     public void testIsNegated() throws Exception {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -24,12 +24,11 @@
 
 import java.util.List;
 
-import org.teiid.dqp.internal.datamgr.language.UpdateImpl;
-
 import junit.framework.TestCase;
 
+import org.teiid.connector.language.Update;
+
 import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Update;
 import com.metamatrix.query.sql.symbol.Constant;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 
@@ -43,9 +42,9 @@
         super(name);
     }
     
-    public static Update helpExample() {
+    public static com.metamatrix.query.sql.lang.Update helpExample() {
         GroupSymbol group = TestGroupImpl.helpExample("vm1.g1"); //$NON-NLS-1$
-        Update result = new Update();
+        com.metamatrix.query.sql.lang.Update result = new com.metamatrix.query.sql.lang.Update();
         result.setGroup(group);
         result.addChange(TestElementImpl.helpExample("vm1.g1", "e1"), new Constant(new Integer(1)));
         result.addChange(TestElementImpl.helpExample("vm1.g1", "e2"), new Constant(new Integer(1)));
@@ -55,22 +54,22 @@
         return result;
     }
     
-    public static UpdateImpl example() throws Exception {
-        return (UpdateImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
+    public static Update example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
     }
 
     public void testGetGroup() throws Exception {
-        assertNotNull(example().getGroup());
+        assertNotNull(example().getTable());
     }
 
     public void testGetChanges() throws Exception {
-        List changes = example().getChanges().getClauses();
+        List changes = example().getChanges();
         assertNotNull(changes);
         assertEquals(4, changes.size());
     }
 
     public void testGetCriteria() throws Exception {
-        assertNotNull(example().getCriteria());
+        assertNotNull(example().getWhere());
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,7 +22,6 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
-import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
 import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
 
 import com.metamatrix.query.unittest.FakeMetadataFacade;

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -37,7 +37,6 @@
 public class TestMetadataFactory  extends TestCase {
     private RuntimeMetadataImpl metadataFactory;
     private FakeMetadataObject pm1g1;
-    private FakeMetadataObject pm1g1e1;
     
     public TestMetadataFactory(String name) {
         super(name);
@@ -49,38 +48,11 @@
         List pm1g1e = FakeMetadataFactory.createElements(pm1g1, 
             new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
             new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
-        pm1g1e1 = (FakeMetadataObject)pm1g1e.get(0);
         store.addObject(pm1g1);
         store.addObjects(pm1g1e);
         metadataFactory = new RuntimeMetadataImpl(new FakeMetadataFacade(store));
     }
     
-    //tests
-    
-    public void testCreateMetadataID() throws Exception {        
-        //test create MetadataID for Group
-        GroupImpl gID = metadataFactory.getGroup(pm1g1);
-        assertEquals(gID.getActualID(), pm1g1);
-        assertEquals(((ElementImpl)gID.getChildren().get(0)).getActualID(), pm1g1e1);
-        
-        //test create MetadataID for Element
-        ElementImpl eID = metadataFactory.getElement(pm1g1e1);
-        assertEquals(eID.getActualID(), pm1g1e1);
-        assertEquals(((GroupImpl)eID.getParent()).getActualID(), pm1g1);
-    }
-    
-    public void testRuntimeMetadata() throws Exception {
-        GroupImpl group = metadataFactory.getGroup(pm1g1);
-        assertEquals(group.getNameInSource(), "g1"); //$NON-NLS-1$
-        assertEquals(group.getActualID(), pm1g1);
-
-        ElementImpl element = metadataFactory.getElement(pm1g1e1);
-        assertEquals(element.getLength(), 100);
-        assertEquals(element.getJavaType(), DataTypeManager.DefaultDataClasses.STRING);
-        assertEquals("e1", element.getNameInSource()); //$NON-NLS-1$
-        assertEquals(element.getActualID(), pm1g1e1);
-    }
-    
     public void testGetVDBResourcePaths() throws Exception {
         String[] expectedPaths = new String[] {"my/resource/path"}; //$NON-NLS-1$
         String[] mfPaths = metadataFactory.getVDBResourcePaths();

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.dqp.internal.pooling.connector;
-
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.Execution;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.basic.BasicConnection;
-import org.teiid.connector.basic.BasicConnector;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-
-/**
- */
-public class FakeSourceConnectionFactory extends BasicConnector {
-    static int connCnt;
-    
-    static boolean alive = true;
-    
-    class FakeSourceConnection extends BasicConnection {
-        int id;
-        
-        FakeSourceConnection(int id){
-            FakeSourceConnection.this.id = id;
-        }
-        
-        public boolean isAlive() {
-            return alive;
-        }
-        
-        public boolean equals(Object other){
-            return this.id == ((FakeSourceConnection)other).id;
-        }
-        
-        public String toString(){
-            return "Connection " + id; //$NON-NLS-1$
-        }
-
-		@Override
-		public Execution createExecution(ICommand command,
-				ExecutionContext executionContext, RuntimeMetadata metadata)
-				throws ConnectorException {
-			return null;
-		}
-
-		@Override
-		public ConnectorCapabilities getCapabilities() {
-			return null;
-		}
-
-		@Override
-		public void close() {
-			
-		}
-		
-    }
-
-	@Override
-	public Connection getConnection(ExecutionContext context)
-			throws ConnectorException {
-		return new FakeSourceConnection(connCnt++);
-	}
-
-	@Override
-	public void start(ConnectorEnvironment environment) throws ConnectorException {
-	}
-
-	@Override
-	public void stop() {
-	}
-	
-	@Override
-	public ConnectorCapabilities getCapabilities() {
-		return null;
-	}
-
-}

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.dqp.internal.pooling.connector;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorIdentity;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MappedUserIdentity;
-
-/**
- */
-public class FakeUserIdentityConnectionFactory extends FakeSourceConnectionFactory {
-
-    /* 
-     * @see com.metamatrix.data.pool.SourceConnectionFactory#createIdentity(com.metamatrix.data.SecurityContext)
-     */
-    public ConnectorIdentity createIdentity(ExecutionContext context) throws ConnectorException {
-        if (context == null) {
-        	return null;
-        }
-    	//use user name for now
-        return new MappedUserIdentity(context.getUser(), null, null);
-    }
-    
-}

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,389 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.pooling.connector;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MappedUserIdentity;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.common.queue.WorkerPoolFactory;
-
-
-public class TestConnectionPool {
-    private ConnectionPool userIDPool;
-    private ConnectionPool singleIDPool;
-    private static ArrayList<Exception> EXCEPTIONS = new ArrayList<Exception>();
-    private static WorkerPool pool = WorkerPoolFactory.newWorkerPool(TestConnectionPool.class.getSimpleName(), 1);
-    
-    @AfterClass public static void tearDownOnce() {
-    	pool.shutdownNow();
-    }
-    
-    @Before public void setUp() throws Exception{
-        FakeSourceConnectionFactory.alive = true;        
-        
-        singleIDPool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
-        userIDPool = new ConnectionPool(new ConnectorWrapper(new FakeUserIdentityConnectionFactory()));
-        
-        Properties poolProperties = new Properties();
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "10"); //$NON-NLS-1$ 
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "5"); //$NON-NLS-1$ 
-        poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "500"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
-        ConnectorEnvironment env = createConnectorEnvironment(poolProperties);
-        singleIDPool.initialize(env);
-        userIDPool.initialize(env);
-    }
-
-	private ConnectorEnvironment createConnectorEnvironment(
-			Properties poolProperties) {
-		ConnectorEnvironment env = new ConnectorEnvironmentImpl(poolProperties, Mockito.mock(ConnectorLogger.class), new ApplicationEnvironment(), pool);
-		return env;
-	}
-    
-    public void tearDown() throws Exception{
-        singleIDPool.shutDown();
-        userIDPool.shutDown();
-    }
-        
-    public static ExecutionContext createContext(final String user, boolean userIdentity) {
-    	ExecutionContextImpl context = new ExecutionContextImpl(null, null, user, null, null, null, null, null, null, null);
-    	if (userIdentity) {
-    		context.setConnectorIdentity(new MappedUserIdentity(context.getUser(), null, null));
-    	}
-    	return context;
-    }
-    
-    //=== tests ===//
-    @Test public void testPoolUsingSingleIdentity() throws Exception {
-        ExecutionContext context = createContext("x", false);//$NON-NLS-1$
-
-        ConnectionWrapper conn1 = singleIDPool.obtain(context);
-        ConnectionWrapper conn2 = singleIDPool.obtain(context);
-        ConnectionWrapper conn3 = singleIDPool.obtain(context);
-        ConnectionWrapper conn4 = singleIDPool.obtain(context);   
-        
-        assertEquals(4, singleIDPool.getTotalCreatedConnectionCount());
-        assertEquals(4, singleIDPool.getTotalConnectionCount());
-        assertEquals(4, singleIDPool.getNumberOfConnectionsInUse());
-        assertEquals(0, singleIDPool.getNumberOfConnectinsWaiting());
-        assertEquals(0, singleIDPool.getTotalDestroyedConnectionCount());
-
-     
-
-        
-        singleIDPool.release(conn2, false);
-        singleIDPool.release(conn4, true);
-        
-        // only 1 has been closed/destroyed  #4
-        assertEquals(3, singleIDPool.getTotalConnectionCount());
-        assertEquals(1, singleIDPool.getTotalDestroyedConnectionCount());
-        assertEquals(1, singleIDPool.getNumberOfConnectinsWaiting());
-        assertEquals(4, singleIDPool.getTotalCreatedConnectionCount());
-        assertEquals(2, singleIDPool.getNumberOfConnectionsInUse());
-
-        
-        List unusedConns = singleIDPool.getUnusedConnections(conn1);
-        assertEquals(1, unusedConns.size());
-        assertTrue(unusedConns.contains(conn2));
-        List usedConns = singleIDPool.getUsedConnections(conn2);
-        assertEquals(2, usedConns.size());
-        assertTrue(usedConns.contains(conn1));
-        assertTrue(usedConns.contains(conn3));    
-        assertEquals(3, singleIDPool.getTotalConnectionCount());  
-    }
-
-    @Test public void testMaxConnectionTest() throws Exception {
-        ConnectionPool pool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
-        
-        Properties poolProperties = new Properties();
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "0"); //$NON-NLS-1$ 
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "5"); //$NON-NLS-1$ 
-        poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "500"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
-        
-        try {
-            pool.initialize(createConnectorEnvironment(poolProperties));
-            fail("should have failed to use 0 as max connections"); //$NON-NLS-1$
-        }catch (ConnectionPoolException e) {
-            // pass
-        }
-    }
-    
-    @Test public void testMaxConnectionTest1() throws Exception {
-        ConnectionPool pool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
-        
-        Properties poolProperties = new Properties();
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "-1"); //$NON-NLS-1$ 
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "5"); //$NON-NLS-1$ 
-        poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "500"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
-        
-        try {
-            pool.initialize(createConnectorEnvironment(poolProperties));
-            fail("should have failed to use 0 as max connections"); //$NON-NLS-1$
-        }catch (ConnectionPoolException e) {
-            // pass
-        }
-    }
-    
-    @Test public void testMaxConnectionTest2() throws Exception {
-        ConnectionPool pool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
-        
-        Properties poolProperties = new Properties();
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "10"); //$NON-NLS-1$ 
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "0"); //$NON-NLS-1$ 
-        poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "500"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
-        
-        try {
-            pool.initialize(createConnectorEnvironment(poolProperties));
-            fail("should have failed to use 0 as max connections"); //$NON-NLS-1$
-        }catch (ConnectionPoolException e) {
-            // pass
-        }
-    }
-
-    @Test public void testMessageWhenPoolMaxedOutPerIdentity() throws Exception {
-        ExecutionContext context = createContext("x", false);//$NON-NLS-1$
-
-        // Max out the pool - 5 connections for same ID
-        for(int i=0; i<5; i++) {
-            singleIDPool.obtain(context);
-        }
-        
-        // Ask for one more - this should time out
-        try {
-            singleIDPool.obtain(context);
-            fail("No exception received when maxing out the pool"); //$NON-NLS-1$
-        } catch(ConnectionPoolException e) {
-            assertEquals("The connection pool for identity \"SingleIdentity\" is at the maximum connection count \"5\" and no connection became available in the timeout period.  Consider increasing the number of connections allowed per identity or the wait time.", e.getMessage()); //$NON-NLS-1$
-        }
-    }
-    
-    @Test public void testMessageWhenPoolTimedOut() throws Exception {
-        FakeSourceConnectionFactory.alive = true;        
-        
-        singleIDPool = new ConnectionPool(new ConnectorWrapper(new FakeSourceConnectionFactory()));
-        Properties poolProperties = new Properties();
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.ENABLE_SHRINKING, Boolean.FALSE.toString());
-        poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
-        singleIDPool.initialize(createConnectorEnvironment(poolProperties));
-        
-        ExecutionContext context = createContext("x", false);//$NON-NLS-1$
-
-        singleIDPool.obtain(context);
-        
-        try {            
-            // Ask for a connection... should time out.
-            singleIDPool.obtain(context);
-            
-            fail("No exception received on pool timeout"); //$NON-NLS-1$           
-        } catch (ConnectionPoolException e) {
-            assertEquals("The connection pool for identity \"SingleIdentity\" exceeded wait time for connection, \"1\" ms, and no connection became available in the timeout period.  Consider increasing the number of connections allowed per identity or the wait time.", e.getMessage()); //$NON-NLS-1$
-        }
-    }
-
-    @Test public void testPoolUsingUserIdentity() throws Exception {
-        ExecutionContext context1 = createContext("Jack", true); //$NON-NLS-1$
-        ExecutionContext context2 = createContext("Tom", true); //$NON-NLS-1$
-        userIDPool.obtain(context1);
-        ConnectionWrapper conn2 = userIDPool.obtain(context1);
-        ConnectionWrapper conn3 = userIDPool.obtain(context2);
-        ConnectionWrapper conn4 = userIDPool.obtain(context2);      
-        
-        assertEquals(4, userIDPool.getTotalCreatedConnectionCount());
-        assertEquals(4, userIDPool.getTotalConnectionCount());
-        assertEquals(4, userIDPool.getNumberOfConnectionsInUse());
-        assertEquals(0, userIDPool.getNumberOfConnectinsWaiting());
-        assertEquals(0, userIDPool.getTotalDestroyedConnectionCount());
-        
-        
-        
-        userIDPool.release(conn2, false);
-        userIDPool.release(conn4, true);
-        
-        // only 1 has been closed/destroyed  #4
-        assertEquals(3, userIDPool.getTotalConnectionCount());
-        assertEquals(1, userIDPool.getTotalDestroyedConnectionCount());
-        assertEquals(1, userIDPool.getNumberOfConnectinsWaiting());
-        assertEquals(4, userIDPool.getTotalCreatedConnectionCount());
-        assertEquals(2, userIDPool.getNumberOfConnectionsInUse());
-        
-        
-        List unusedConns = userIDPool.getUnusedConnections(conn2);
-        assertEquals(1, unusedConns.size());
-        assertTrue(unusedConns.contains(conn2));
-        List usedConns = userIDPool.getUsedConnections(conn3);
-        assertEquals(1, usedConns.size());
-        assertTrue(usedConns.contains(conn3));    
-        assertEquals(3, userIDPool.getTotalConnectionCount());        
-    }
-    
-    @Test public void testPoolCleanUp() throws Exception {
-        ExecutionContext context = createContext("x", false);       //$NON-NLS-1$ 
-
-        ConnectionWrapper conn1 = singleIDPool.obtain(context);
-        ConnectionWrapper conn2 = singleIDPool.obtain(context);
-        ConnectionWrapper conn3 = singleIDPool.obtain(context);
-        ConnectionWrapper conn4 = singleIDPool.obtain(context);         
-        singleIDPool.release(conn2, false);
-        singleIDPool.release(conn4, true);
-        
-        try {
-            Thread.sleep(3000);
-        } catch (InterruptedException e1) {
-        }
-        
-        List unusedConns = singleIDPool.getUnusedConnections(conn1);
-        assertEquals(0, unusedConns.size());
-        List usedConns = singleIDPool.getUsedConnections(conn1);
-        assertEquals(2, usedConns.size());
-        assertTrue(usedConns.contains(conn1));
-        assertTrue(usedConns.contains(conn3));   
-        assertEquals(2, singleIDPool.getTotalConnectionCount());           
-    }
-    
-    @Test public void testMultiThreading() throws Exception {
-    	EXCEPTIONS.clear();
-        int runnerNumber = 20;
-        int connPerRunner = 20;
-
-        LoadRunner runner[] = new LoadRunner[runnerNumber];
-        for(int i=0; i< runnerNumber; i++){
-            runner[i] = new LoadRunner(userIDPool, connPerRunner);
-        }
-        
-        for(int i=0; i< runnerNumber; i++){
-            runner[i].start();
-        }
-        
-        for(int i=0; i< runnerNumber; i++){
-            try {
-                runner[i].join();
-            } catch (InterruptedException e) {
-            }
-        }
-        
-        assertEquals(EXCEPTIONS.toString(), 0, EXCEPTIONS.size());
-        
-        ExecutionContext context1 = createContext("Jack", true); //$NON-NLS-1$
-        ExecutionContext context2 = createContext("Tom", true); //$NON-NLS-1$
-
-        //List unusedConns1 = pool.getUnusedConneections(id1);
-        List usedConns1 = userIDPool.getUsedConnections(userIDPool.obtain(context1));
-
-        assertEquals(1, usedConns1.size());
-        //List unusedConns2 = pool.getUnusedConneections(id2);
-        List usedConns2 = userIDPool.getUsedConnections(userIDPool.obtain(context2));
-        assertEquals(1, usedConns2.size()); 
-    }
-    
-    static class LoadRunner extends Thread {        
-    	ConnectionPool pool;
-        private int n;
-        
-        LoadRunner(ConnectionPool pool, int connPerRunner){
-            n = connPerRunner;
-            this.pool = pool;
-        }
-        
-        public void run(){
-            ExecutionContext context1 = createContext("Jack", true); //$NON-NLS-1$
-            ExecutionContext context2 = createContext("Tom", true); //$NON-NLS-1$
-            try {
-            	ConnectionWrapper conn = null;
-                
-                for(int i=0; i<n; i++) {
-                	if(Math.random() < .5) {
-                    	conn = pool.obtain(context1);
-                    } else {
-                        conn = pool.obtain(context2);
-                    }
-                    try {
-    					Thread.sleep(5);
-    				} catch (InterruptedException e) {
-    					//ignore
-    				}
-                    pool.release(conn, false);
-                }    
-            } catch (ConnectionPoolException e) {
-                TestConnectionPool.EXCEPTIONS.add(e);
-            }
-        }
-    }
-    
-    @Test public void testMaxWithUserPool() throws Exception {
-        userIDPool = new ConnectionPool(new ConnectorWrapper(new FakeUserIdentityConnectionFactory()));   
-        Properties poolProperties = new Properties();
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.MAX_CONNECTIONS_FOR_EACH_ID, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.LIVE_AND_UNUSED_TIME, "1000"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.WAIT_FOR_SOURCE_TIME, "1"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.CLEANING_INTERVAL, "1000"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.ENABLE_SHRINKING, "false"); //$NON-NLS-1$
-        poolProperties.put(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, "-1"); //$NON-NLS-1$
-        userIDPool.initialize(createConnectorEnvironment(poolProperties));
-        
-        ConnectionWrapper conn = userIDPool.obtain(createContext("x", true)); //$NON-NLS-1$
-        userIDPool.release(conn,false);
-
-        assertEquals(1, userIDPool.getTotalConnectionCount());
-        
-        userIDPool.obtain(createContext("y", true)); //$NON-NLS-1$
-
-        assertEquals(1, userIDPool.getTotalConnectionCount());
-    }
-        
-}

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -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 org.teiid.dqp.internal.pooling.connector;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-import org.teiid.connector.basic.BasicConnection;
-import org.teiid.dqp.internal.pooling.connector.ConnectionPool;
-import org.teiid.dqp.internal.pooling.connector.ConnectionWrapper;
-
-
-public class TestConnectionWrapper extends TestCase {
-
-	public void testIdleTime() throws Exception {
-		ConnectionWrapper wrapper = new ConnectionWrapper(Mockito.mock(BasicConnection.class), Mockito.mock(ConnectionPool.class), 1);
-		long time = wrapper.getTimeReturnedToPool();
-		Thread.sleep(50);
-		wrapper.close();
-		assertTrue(wrapper.getTimeReturnedToPool() - time > 0);
-	}
-	
-	public void testIsAliveTestInterval() throws Exception {
-		BasicConnection connection = Mockito.mock(BasicConnection.class);
-		Mockito.stub(connection.isAlive()).toReturn(Boolean.TRUE);
-		ConnectionWrapper wrapper = new ConnectionWrapper(connection, Mockito.mock(ConnectionPool.class), 1);
-		wrapper.setTestInterval(-1); //trigger an actual call.
-		for (int i = 0; i < 10; i++) {
-			wrapper.isAlive();
-			wrapper.setTestInterval(60000);
-		}
-		Mockito.verify(connection, Mockito.times(1)).isAlive();
-	}
-}

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.pooling.connector;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.Connector;
-import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ConnectorPropertyNames;
-import org.teiid.connector.api.CredentialMap;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MappedUserIdentity;
-import org.teiid.connector.basic.BasicConnector;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-
-import com.metamatrix.common.application.ApplicationEnvironment;
-
-/**
- */
-public class TestPerUserPool extends TestCase {
-	
-    public TestPerUserPool(String name) {
-        super(name);
-    }
-    
-    private Connector getTestConnector(ConnectorEnvironment env) throws ConnectorException {
-    	BasicConnector con = new BasicConnector() {
-
-			@Override
-			public ConnectorCapabilities getCapabilities() {
-				return null;
-			}
-
-			@Override
-			public Connection getConnection(ExecutionContext context)
-					throws ConnectorException {
-				assertTrue(context.getConnectorIdentity() instanceof MappedUserIdentity);
-				return null;
-			}
-
-			@Override
-			public void start(ConnectorEnvironment environment)
-					throws ConnectorException {
-				
-			}
-
-			@Override
-			public void stop() {
-				
-			}
-    		
-    	};
-    	con.setUseCredentialMap(true);
-    	con.setAdminConnectionsAllowed(false);
-    	con.setConnectorName("oracle system");
-    	con.start(env);
-    	return con;
-    }
-    
-    public void testWrongCredentials() throws Exception {
-        ConnectorEnvironment env = initConnectorEnvironment();
-        Connector factory = getTestConnector(env);
-        try {
-            ExecutionContext ctx = createSecurityContext("pw1", false, factory); //$NON-NLS-1$
-			factory.getConnection(ctx);
-			fail("expected failure"); //$NON-NLS-1$
-		} catch (ConnectorException e) {
-			assertEquals("Unable to extract credentials from command payload or trusted session payload for per-user connection.", e.getMessage()); //$NON-NLS-1$
-		}
-    }
-    
-    private ConnectorEnvironment initConnectorEnvironment() throws Exception {
-        final Properties connProps = new Properties();
-        connProps.put(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, "oracle system"); //$NON-NLS-1$
-        return new ConnectorEnvironmentImpl(connProps, Mockito.mock(ConnectorLogger.class), new ApplicationEnvironment());
-    }
-    
-    private ExecutionContext createSecurityContext(String credentialsStr, boolean useMap, Connector factory) throws Exception {
-        Serializable credentials = credentialsStr;
-    	if (useMap) {
-    		credentials = CredentialMap.parseCredentials(credentialsStr);
-        }
-    	
-        // session payload
-        ExecutionContextImpl impl = new ExecutionContextImpl(null, null, null, credentials, null, null, null, null, null, null);
-        impl.setConnectorIdentity(factory.createIdentity(impl));
-        return impl;
-    }
-    
-    public void testCredentialMapInSessionPayload() throws Exception {
-        ConnectorEnvironment env = initConnectorEnvironment();
-        Connector factory = getTestConnector(env);
-        ExecutionContext ctx = createSecurityContext("(system=oracle system,user=bqt2,password=mm)", true, factory); //$NON-NLS-1$
-        factory.getConnection(ctx);
-    }
-    
-    public void testCredentialMapMissingSystem() throws Exception {
-        ConnectorEnvironment env = initConnectorEnvironment();
-        Connector factory = getTestConnector(env);
-
-        // Set system to "x" instead of "oracle system" which will cause no credentials to be found
-        try {
-            ExecutionContext ctx = createSecurityContext("(system=x,user=bqt2,password=mm)", true, factory); //$NON-NLS-1$
-            factory.getConnection(ctx);
-            fail("Expected exception when creating connection with missing system credentials"); //$NON-NLS-1$
-        } catch(Exception e) {
-            // expected
-            assertEquals("Payload missing credentials for oracle system", e.getMessage()); //$NON-NLS-1$
-        }
-    }
-
-}

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.pooling.connector;
-
-import static org.junit.Assert.*;
-
-import java.util.List;
-import java.util.Properties;
-
-import javax.transaction.Transaction;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.connector.xa.api.XAConnector;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
-
-import com.metamatrix.admin.objects.MMConnectionPool;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.dqp.service.TransactionService;
-
-public class TestPooledConnector {
-	
-	@Test public void testGetXAConnection() throws Exception {
-		XAConnector connector = Mockito.mock(XAConnector.class);
-		PooledConnector pc = new PooledConnector("foo", connector, Mockito.mock(TransactionService.class)); //$NON-NLS-1$
-		pc.start(new ConnectorEnvironmentImpl(new Properties(), Mockito.mock(ConnectorLogger.class), new ApplicationEnvironment()));
-		TransactionContext tc = Mockito.mock(TransactionContext.class);
-		Mockito.stub(tc.getTransaction()).toReturn(Mockito.mock(Transaction.class));
-		Mockito.stub(tc.getTxnID()).toReturn("1"); //$NON-NLS-1$
-		Connection conn = pc.getConnection(Mockito.mock(ExecutionContext.class), tc);
-		conn.close();
-		Connection conn1 = pc.getConnection(Mockito.mock(ExecutionContext.class), tc);
-		assertSame(conn, conn1);
-		
-		List<MMConnectionPool> stats = pc.getConnectionPoolStats();
-		assertEquals(2, stats.size());
-		assertEquals(1, stats.get(1).getConnectionsCreated());
-		conn1.close(); //this is still in a txn so it should still be in use
-		
-		stats = pc.getConnectionPoolStats();
-		assertEquals(1, stats.get(1).getConnectionsInuse());
-		
-		pc.stop();
-	}
-
-}

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -39,7 +39,7 @@
 		String sql = "{? = call pm4.spTest9()}"; //$NON-NLS-1$
 
 		try {
-			TestPreparedStatement.helpTestProcessing(sql, Collections.EMPTY_LIST, null, new HardcodedDataManager(), FakeMetadataFactory.exampleBQTCached(), true);
+			TestPreparedStatement.helpTestProcessing(sql, Collections.EMPTY_LIST, null, new HardcodedDataManager(), FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
 			fail();
 		} catch (QueryResolverException e) {
 			assertEquals("Required parameter 'PM4.SPTEST9.INKEY' has no value was set or is an invalid parameter.", e.getMessage()); //$NON-NLS-1$
@@ -58,7 +58,7 @@
 		HardcodedDataManager dataManager = new HardcodedDataManager();
 		dataManager.addData("EXEC pm4.spTest9(1)", expected);
 		
-		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
 	}
 	
 	/**
@@ -77,7 +77,7 @@
 		HardcodedDataManager dataManager = new HardcodedDataManager();
 		dataManager.addData("EXEC pm4.spTest9(1)", expected);
 		
-		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
 	}
 		
 	public void testOutParameter() throws Exception {
@@ -92,7 +92,7 @@
 		HardcodedDataManager dataManager = new HardcodedDataManager();
 		dataManager.addData("EXEC pm2.spTest8(2)", expected);
 		
-		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
 	}
 	
 	public void testInputExpression() throws Exception {
@@ -104,7 +104,7 @@
 		HardcodedDataManager dataManager = new HardcodedDataManager();
 		dataManager.addData("EXEC pm2.spTest8(1)", expected);
 		
-		TestPreparedStatement.helpTestProcessing(sql, null, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+		TestPreparedStatement.helpTestProcessing(sql, null, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
 	}
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -39,8 +39,8 @@
  */
 public class TestCodeTableCache extends TestCase {
 
-	private static CommandContext TEST_CONTEXT = new CommandContext("pid", "1", null, "test",  "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$  
-	private static CommandContext TEST_CONTEXT_1 = new CommandContext("pid", "1", null, "test",  "2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+	private static CommandContext TEST_CONTEXT = new CommandContext("pid", "1", null, "test",  1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$  
+	private static CommandContext TEST_CONTEXT_1 = new CommandContext("pid", "1", null, "test", 2); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 	
 	public TestCodeTableCache(String name) {
 		super(name);

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.process;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-
-/**
- */
-public class TestConnectorCapabilitiesFinder extends TestCase {
-
-    /**
-     * Constructor for TestConnectorCapabilitiesFinder.
-     * @param name
-     */
-    public TestConnectorCapabilitiesFinder(String name) {
-        super(name);
-    }
-
-    public void testFind() throws Exception {
-        String vdbName = "myvdb"; //$NON-NLS-1$
-        String vdbVersion = "1"; //$NON-NLS-1$
-        String modelName = "model"; //$NON-NLS-1$
-        String functionName = "fakeFunction"; //$NON-NLS-1$
-        
-        BasicSourceCapabilities caps = new BasicSourceCapabilities();
-        caps.setFunctionSupport("fakeFunction", true); //$NON-NLS-1$
-        RequestMessage request = new RequestMessage(null);
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName(vdbName);
-        workContext.setVdbVersion(vdbVersion);
-        
-        VDBService vdbService = Mockito.mock(VDBService.class); 
-        Mockito.stub(vdbService.getConnectorBindingNames(vdbName, vdbVersion, modelName)).toReturn(Arrays.asList(modelName));
-        DataService dataService = Mockito.mock(DataService.class);
-        BasicSourceCapabilities basicSourceCapabilities = new BasicSourceCapabilities();
-        basicSourceCapabilities.setFunctionSupport(functionName, true);
-        Mockito.stub(dataService.getCapabilities(request, workContext, modelName)).toReturn(basicSourceCapabilities);
-        
-        CachedFinder finder = new CachedFinder(dataService, request, workContext);
-        
-        // Test
-        SourceCapabilities actual = finder.findCapabilities(modelName);
-        assertEquals("Did not get expected capabilities", true, actual.supportsFunction(functionName)); //$NON-NLS-1$
-    }
-
-}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java (from rev 1900, branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+
+/**
+ */
+public class TestConnectorCapabilitiesFinder extends TestCase {
+
+    /**
+     * Constructor for TestConnectorCapabilitiesFinder.
+     * @param name
+     */
+    public TestConnectorCapabilitiesFinder(String name) {
+        super(name);
+    }
+
+    public void testFind() throws Exception {
+        String modelName = "model"; //$NON-NLS-1$
+        String functionName = "fakeFunction"; //$NON-NLS-1$
+        
+        BasicSourceCapabilities caps = new BasicSourceCapabilities();
+        caps.setFunctionSupport("fakeFunction", true); //$NON-NLS-1$
+       
+        ArrayList<String> bindings = new ArrayList<String>();
+        bindings.add(modelName);
+        
+        VDBMetaData vdb = Mockito.mock(VDBMetaData.class); 
+        ModelMetaData model = Mockito.mock(ModelMetaData.class); 
+        Mockito.stub(vdb.getModel(modelName)).toReturn(model);
+        Mockito.stub(model.getSourceNames()).toReturn(bindings);
+        
+        BasicSourceCapabilities basicSourceCapabilities = new BasicSourceCapabilities();
+        basicSourceCapabilities.setFunctionSupport(functionName, true);
+
+        ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+        ConnectorManager cm = Mockito.mock(ConnectorManager.class);
+        Mockito.stub(cm.getCapabilities()).toReturn(basicSourceCapabilities);
+        Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(cm);
+        
+        CachedFinder finder = new CachedFinder(repo, vdb);
+        
+        // Test
+        SourceCapabilities actual = finder.findCapabilities(modelName);
+        assertEquals("Did not get expected capabilities", true, actual.supportsFunction(functionName)); //$NON-NLS-1$
+    }
+
+}

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -25,7 +25,6 @@
 import static org.junit.Assert.*;
 
 import java.sql.ResultSet;
-import java.util.Properties;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -33,56 +32,38 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
 
 import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.common.queue.FakeWorkManager;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.ResultsMessage;
 import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.DQPServiceNames;
 import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.dqp.service.FakeVDBService;
 import com.metamatrix.jdbc.api.ExecutionProperties;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
 import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.unittest.FakeMetadataFactory;
 
-
 public class TestDQPCore {
 
     private DQPCore core;
 
     @Before public void setUp() throws Exception {
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName("bqt"); //$NON-NLS-1$
-        workContext.setVdbVersion("1"); //$NON-NLS-1$
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
-        DQPWorkContext.setWorkContext(workContext);
-        
-        String vdbName = "bqt"; //$NON-NLS-1$
-		String vdbVersion = "1"; //$NON-NLS-1$
-    	
-    	final ApplicationEnvironment env = new ApplicationEnvironment();
-        env.bindService(DQPServiceNames.BUFFER_SERVICE, new FakeBufferService());
-        FakeMetadataService mdSvc = new FakeMetadataService();
-		mdSvc.addVdb(vdbName, vdbVersion, FakeMetadataFactory.exampleBQTCached()); 
-        env.bindService(DQPServiceNames.METADATA_SERVICE, mdSvc);
-        env.bindService(DQPServiceNames.DATA_SERVICE, new AutoGenDataService());
-        env.bindService(DQPServiceNames.TRANSACTION_SERVICE, new FakeTransactionService());
-        FakeVDBService vdbService = new FakeVDBService();
-        vdbService.setDefaultPrivate(true);
-        vdbService.addBinding(vdbName, vdbVersion, "BQT1", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
-        vdbService.addBinding(vdbName, vdbVersion, "BQT3", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
-        vdbService.addModel(vdbName, vdbVersion, "BQT3", ModelInfo.PRIVATE, false); //$NON-NLS-1$
-        env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
+        DQPWorkContext context = FakeMetadataFactory.buildWorkContext(FakeMetadataFactory.exampleBQTCached(), FakeMetadataFactory.exampleBQTVDB());
+        context.getVDB().getModel("BQT3").setVisible(false); //$NON-NLS-1$
 
+        ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+        Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
+        
         core = new DQPCore();
-        core.setEnvironment(env);
-        core.start(new Properties());
+        core.setWorkManager(new FakeWorkManager());
+        core.setBufferService(new FakeBufferService());
+        core.setConnectorManagerRepository(repo);
+        core.setTransactionService(new FakeTransactionService());
+        
+        core.start(new DQPConfiguration());
     }
     
     @After public void tearDown() throws Exception {
@@ -92,7 +73,6 @@
 
     public RequestMessage exampleRequestMessage(String sql) {
         RequestMessage msg = new RequestMessage(sql);
-        msg.setCallableStatement(false);
         msg.setCursorType(ResultSet.TYPE_SCROLL_INSENSITIVE);
         msg.setFetchSize(10);
         msg.setPartialResults(false);
@@ -204,14 +184,14 @@
 	}
 	
 	@Test public void testCancel() throws Exception {
-		assertFalse(this.core.cancelRequest(new RequestID(1)));
+		assertFalse(this.core.cancelRequest(1L));
 	}
     
 	public void helpTestVisibilityFails(String sql) throws Exception {
         RequestMessage reqMsg = exampleRequestMessage(sql); 
         reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_OFF);
         Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
-        ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
+        ResultsMessage results = message.get(5000, TimeUnit.MILLISECONDS);
         assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString()); //$NON-NLS-1$
 	}
 
@@ -233,13 +213,13 @@
 
     private ResultsMessage helpExecute(String sql, String userName, int sessionid, boolean txnAutoWrap) throws Exception {
         RequestMessage reqMsg = exampleRequestMessage(sql);
-        DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new MetaMatrixSessionID(sessionid), userName));
+        DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(sessionid, userName));
         if (txnAutoWrap) {
         	reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_ON);
         }
 
         Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
-        ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
+        ResultsMessage results = message.get(5000, TimeUnit.MILLISECONDS);
         if (results.getException() != null) {
         	throw results.getException();
         }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -28,33 +28,32 @@
 
 import junit.framework.TestCase;
 
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
 import org.teiid.dqp.internal.process.DQPCore.ClientState;
 
 import com.metamatrix.api.exception.MetaMatrixException;
 import com.metamatrix.dqp.exception.SourceWarning;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
 import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.server.serverapi.RequestInfo;
 
 /**
  */
 public class TestDQPCoreRequestHandling extends TestCase {
 
-	private static final String SESSION_STRING = new MetaMatrixSessionID(2).toString();
+	private static final String SESSION_STRING = "2";
 	
     public TestDQPCoreRequestHandling(String name) {
         super(name);
     }
 
-    private void compareReqInfos(Collection<RequestID> reqs1, Collection<RequestInfo> reqs2) {
+    private void compareReqInfos(Collection<RequestID> reqs1, Collection<RequestMetadata> reqs2) {
         Set reqIDs2 = new HashSet();
-        for (RequestInfo requestInfo : reqs2) {
-            reqIDs2.add(requestInfo.getRequestID());
+        for (RequestMetadata requestInfo : reqs2) {
+            reqIDs2.add(new RequestID(requestInfo.getSessionId(), requestInfo.getExecutionId()));
         }
         
         assertEquals("Collections of request infos are not the same: ", new HashSet(reqs1), reqIDs2); //$NON-NLS-1$
@@ -66,7 +65,7 @@
     public void testGetRequestsSessionToken1() {
         DQPCore rm = new DQPCore();
         Set reqs = new HashSet();                
-        Collection actualReqs = rm.getRequestsByClient("foo");
+        Collection actualReqs = rm.getRequestsForSession(2);
         compareReqInfos(reqs, actualReqs);
     }
 
@@ -75,11 +74,12 @@
      */
     public void testGetRequestsSessionToken2() {
     	DQPCore rm = new DQPCore();
+    	rm.setTransactionService(new FakeTransactionService());
     	Set reqs = new HashSet();
         RequestID id = addRequest(rm, SESSION_STRING, 1);
         reqs.add(id);
 
-        Collection<RequestInfo> actualReqs = rm.getRequestsByClient(SESSION_STRING);
+        Collection<RequestMetadata> actualReqs = rm.getRequestsForSession(2);
         compareReqInfos(reqs, actualReqs);
     }
 
@@ -95,13 +95,14 @@
      */
     public void testGetRequestsSessionToken3() {
         DQPCore rm = new DQPCore();
+        rm.setTransactionService(new FakeTransactionService());
         Set reqs = new HashSet();
          
         reqs.add(addRequest(rm, SESSION_STRING, 0));
         reqs.add(addRequest(rm, SESSION_STRING, 1));
         reqs.add(addRequest(rm, SESSION_STRING, 2));
                 
-        Collection actualReqs = rm.getRequestsByClient(SESSION_STRING);
+        Collection actualReqs = rm.getRequestsForSession(2);
         compareReqInfos(reqs, actualReqs);
     }
     
@@ -111,6 +112,7 @@
         
     public void testAddRequest() {
         DQPCore rm = new DQPCore();
+        rm.setTransactionService(new FakeTransactionService());
         RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
         RequestID requestID = new RequestID(SESSION_STRING, 1);
         addRequest(rm, r0, requestID, null, null);  
@@ -118,6 +120,7 @@
     
     public void testWarnings1() {
         DQPCore rm = new DQPCore();
+        rm.setTransactionService(new FakeTransactionService());
         RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
         RequestID requestID = new RequestID(SESSION_STRING, 1);
 
@@ -138,7 +141,7 @@
      
     	if (workContext == null) {
 	    	workContext = new DQPWorkContext();
-	    	workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(Long.valueOf(id.getConnectionID())), "foo")); //$NON-NLS-1$
+	    	workContext.setSessionToken(new SessionToken(Long.valueOf(id.getConnectionID()), "foo")); //$NON-NLS-1$
     	}
         RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id, workContext);
         workItem.setOriginalCommand(originalCommand);
@@ -149,12 +152,13 @@
     
     public void testGetConnectorInfo() {
         DQPCore rm = new DQPCore();
+        rm.setTransactionService(new FakeTransactionService());
         RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
         RequestID requestID = new RequestID(SESSION_STRING, 1);
         RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
         AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1);
 
-        DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, new ConnectorID("connID"), workItem); //$NON-NLS-1$
+        DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, "connID", workItem); //$NON-NLS-1$
         workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
         
         DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID());
@@ -163,12 +167,13 @@
     
     public void testRemoveConnectorInfo() {
         DQPCore rm = new DQPCore();
+        rm.setTransactionService(new FakeTransactionService());
         RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
         RequestID requestID = new RequestID(SESSION_STRING, 1);
         RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
         AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1);
 
-        DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, new ConnectorID("connID"), workItem); //$NON-NLS-1$
+        DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null,"connID", workItem); //$NON-NLS-1$
         workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
         
         workItem.closeAtomicRequest(atomicReq.getAtomicRequestID());

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,12 +22,9 @@
 
 package org.teiid.dqp.internal.process;
 
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
 import junit.framework.TestCase;
 
 import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
 import com.metamatrix.platform.security.api.SessionToken;
 
 public class TestDQPWorkContext extends TestCase {
@@ -43,11 +40,10 @@
 
 	public static DQPWorkContext example() {
 		DQPWorkContext message = new DQPWorkContext();
-		message.setTrustedPayload("myTrustedPayload"); //$NON-NLS-1$
 		message.setVdbName("vdbName"); //$NON-NLS-1$
-		message.setVdbVersion("vdbVersion"); //$NON-NLS-1$
+		message.setVdbVersion(1); //$NON-NLS-1$
 		message.setAppName("querybuilder"); //$NON-NLS-1$
-		message.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "userName")); //$NON-NLS-1$
+		message.setSessionToken(new SessionToken(5, "userName")); //$NON-NLS-1$
 		return message;
 	}
 
@@ -55,10 +51,9 @@
 		DQPWorkContext copy = UnitTestUtil.helpSerialize(example());
 
 		assertEquals("5", copy.getConnectionID()); //$NON-NLS-1$
-		assertEquals("myTrustedPayload", copy.getTrustedPayload()); //$NON-NLS-1$
 		assertEquals("userName", copy.getUserName()); //$NON-NLS-1$
 		assertEquals("vdbName", copy.getVdbName()); //$NON-NLS-1$
-		assertEquals("vdbVersion", copy.getVdbVersion()); //$NON-NLS-1$
+		assertEquals(1, copy.getVdbVersion()); //$NON-NLS-1$
 		assertEquals("querybuilder", copy.getAppName()); //$NON-NLS-1$
 	}
 

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,35 +22,27 @@
 
 package org.teiid.dqp.internal.process;
 
-import java.util.Collection;
 import java.util.List;
-import java.util.Properties;
 
+import javax.resource.spi.work.WorkManager;
+
 import junit.framework.TestCase;
 
-import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
 
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.common.queue.FakeWorkManager;
 import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.ConnectorStatus;
-import com.metamatrix.dqp.service.DataService;
 import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -71,7 +63,7 @@
     private Command command;
     private DataTierTupleSource info;
     private int executeRequestFailOnCall = 10000;
-    private FakeDataService dataService;
+    private FakeConnectorManager connectorManager;
     private RequestWorkItem workItem;
     
     public TestDataTierManager(String name) {
@@ -90,21 +82,22 @@
     
     private void helpSetup(String sql, int nodeId) throws Exception {
         QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+        DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.exampleBQTVDB());
         
-        dataService = new FakeDataService(executeRequestFailOnCall);
-//      dataService.addResults("SELECT StringKey, IntKey FROM BQT1.SmallA", helpCreateFakeCodeTableResults(1, 50)); //$NON-NLS-1$
+        connectorManager = new FakeConnectorManager("FakeConnectorID", executeRequestFailOnCall);
         rm = new DQPCore();
+        rm.setTransactionService(new FakeTransactionService());
         
-        FakeVDBService vdbService = new FakeVDBService();
-        vdbService.addBinding("MyVDB", "1", "BQT1", "mmuuid:binding", "bindingName"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-        
         FakeBufferService bs = new FakeBufferService();
+
+        ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+        Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(connectorManager);
         
+        
         dtm = new DataTierManagerImpl(rm,
-                                  dataService,
-                                  vdbService,
+                                  repo,
                                   bs,
-                                  new FakeMetadataService(),
+                                  new FakeWorkManager(),
                                   20,
                                   1000,
                                   1000);
@@ -113,24 +106,20 @@
         RequestMessage original = new RequestMessage();
         original.setExecutionId(1);
         
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName("MyVDB"); //$NON-NLS-1$
-        workContext.setVdbVersion("1"); //$NON-NLS-1$
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
         RequestID requestID = workContext.getRequestID(original.getExecutionId());
         
         context = new CommandContext();
         context.setProcessorID(requestID);
         context.setVdbName("test"); //$NON-NLS-1$
-        context.setVdbVersion("1"); //$NON-NLS-1$
+        context.setVdbVersion(1); //$NON-NLS-1$
         context.setQueryProcessorFactory(new SimpleQueryProcessorFactory(bs.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
         workItem = TestDQPCoreRequestHandling.addRequest(rm, original, requestID, null, workContext);
         
         request = new AtomicRequestMessage(original, workContext, nodeId);
         request.setCommand(command);
-        request.setConnectorID(new ConnectorID("FakeConnectorID")); //$NON-NLS-1$
+        request.setConnectorName("FakeConnectorID"); //$NON-NLS-1$
 
-        info = new DataTierTupleSource(command.getProjectedSymbols(), request, dtm, request.getConnectorID(), workItem);
+        info = new DataTierTupleSource(command.getProjectedSymbols(), request, dtm, request.getConnectorName(), workItem);
         workItem.addConnectorRequest(request.getAtomicRequestID(), info);
     }
     
@@ -215,7 +204,7 @@
         
         DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
         connRequest.closeSource();
-        assertFalse(this.dataService.closed);
+        assertFalse(this.connectorManager.closed);
         
         assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
         
@@ -244,7 +233,7 @@
 
         DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
         connRequest.closeSource();
-        assertTrue(this.dataService.closed);
+        assertTrue(this.connectorManager.closed);
         
         assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
         
@@ -262,14 +251,14 @@
         results.setSupportsImplicitClose(false);
         
         info.receiveResults(results);
-        assertFalse(this.dataService.closed);
+        assertFalse(this.connectorManager.closed);
         assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
         
         DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
         
         // now implicitly close the request then check to make sure it is not gone 
         connRequest.closeSource();
-        assertFalse(this.dataService.closed);        
+        assertFalse(this.connectorManager.closed);        
         assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
     }     
     
@@ -283,7 +272,7 @@
     
     public void testCodeTableResponseException() throws Exception {
     	helpSetup(3);
-    	this.dataService.throwExceptionOnExecute = true;
+    	this.connectorManager.throwExceptionOnExecute = true;
         
         try {
             dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -298,7 +287,7 @@
         
         AtomicResultsMessage results = helpSetup("SELECT * FROM BQT1.SmallA", true, false, -1); //$NON-NLS-1$
         
-        this.dataService.results = results;
+        this.connectorManager.results = results;
         
         try {
             dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -308,22 +297,22 @@
         }
     }
     
-    private static class FakeDataService implements DataService {
+    private static class FakeConnectorManager extends ConnectorManager {
         private int failOnCall = 10000;
         private int calls = 0;
         private boolean closed = false;
         boolean throwExceptionOnExecute;
         AtomicResultsMessage results;
         
-        private FakeDataService(int failOnCallNumber) {
+        private FakeConnectorManager(String name, int failOnCallNumber) {
+        	super(name);
             this.failOnCall = failOnCallNumber;
         }
-		public void executeRequest(AtomicRequestMessage request,
-				ConnectorID connector,
-				ResultsReceiver<AtomicResultsMessage> resultListener)
-				throws MetaMatrixComponentException {
+        @Override
+		public void executeRequest(WorkManager workManager, ResultsReceiver<AtomicResultsMessage> resultListener, AtomicRequestMessage request)
+				throws ConnectorException {
             if (closed) {
-                throw new MetaMatrixComponentException("Already closed"); //$NON-NLS-1$
+                throw new ConnectorException("Already closed"); //$NON-NLS-1$
             }
             if (throwExceptionOnExecute) {
             	resultListener.exceptionOccurred(new RuntimeException("Connector Exception")); //$NON-NLS-1$
@@ -331,50 +320,22 @@
             	resultListener.receiveResults(results);
             }
         }
-        public ConnectorID selectConnector(String connectorBindingID) {
-            if (connectorBindingID.equals("mmuuid:binding")) { //$NON-NLS-1$
-                return new ConnectorID("FakeConnectorID"); //$NON-NLS-1$
-            }
-            return null;
-        }
-        public void initialize(Properties props) throws ApplicationInitializationException {}
-        public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {}
-        public void stop() throws ApplicationLifecycleException {}
-        public void startConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
-        public void stopConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
-        public List getConnectorBindings() throws ComponentNotFoundException {return null;}
-        public ConnectorStatus getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {return null;}
-        public ConnectorBinding getConnectorBinding(String connectorBindingName) throws MetaMatrixComponentException {return null;}
-        public Collection getConnectorBindingStatistics(String connectorBindingName) throws MetaMatrixComponentException {return null;}
-        public Collection getConnectionPoolStatistics(String connectorBindingName) throws MetaMatrixComponentException { return null; }
-        
-        public void clearConnectorBindingCache(String connectorBindingName) throws MetaMatrixComponentException {}
-        
-		public void cancelRequest(AtomicRequestID request,
-				ConnectorID connectorId) throws MetaMatrixComponentException {
-		}
-		public void closeRequest(AtomicRequestID request,
-				ConnectorID connectorId) throws MetaMatrixComponentException {
+
+		@Override
+		public void closeRequest(AtomicRequestID request) {
 			closed = true;
 		}
+		
 		@Override
-		public SourceCapabilities getCapabilities(RequestMessage request,
-				DQPWorkContext dqpWorkContext, String modelName)
-				throws MetaMatrixComponentException {
+		public SourceCapabilities getCapabilities() throws ConnectorException{
 			return null;
 		}
-		public void requestBatch(AtomicRequestID request,
-				ConnectorID connectorId) throws MetaMatrixComponentException {
+		@Override
+		public void requstMore(AtomicRequestID requestId) throws ConnectorException {
             calls++;
             if (calls == failOnCall) {
-                throw new MetaMatrixComponentException("Force fail on executeRequest for call # " + calls); //$NON-NLS-1$
+                throw new ConnectorException("Force fail on executeRequest for call # " + calls); //$NON-NLS-1$
             }            
 		}
-		@Override
-		public MetadataStore getConnectorMetadata(String vdbName,
-				String vdbVersion, String modelName, Properties importProperties)
-				throws MetaMatrixComponentException {
-			throw new UnsupportedOperationException();
-		}
     }
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -29,20 +29,14 @@
 
 import junit.framework.TestCase;
 
-import org.mockito.Mockito;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
 
-import com.metamatrix.common.application.ApplicationEnvironment;
 import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
 import com.metamatrix.dqp.client.MetadataResult;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.parser.QueryParser;
@@ -58,92 +52,75 @@
         super(name);
     }
     
-    public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata) throws Exception {
+    public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata, VDBMetaData vdb) throws Exception {
         // Prepare sql 
         Command command = QueryParser.getQueryParser().parseCommand(sql);
         QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
         
         // Create components
-        MetadataService mdSvc = Mockito.mock(MetadataService.class);
-        Mockito.stub(mdSvc.lookupMetadata(Mockito.anyString(), Mockito.anyString())).toReturn(metadata);
         SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
         DQPCore requestMgr = new DQPCore();
+        requestMgr.setTransactionService(new FakeTransactionService());
 
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName("MyVDB"); //$NON-NLS-1$
-        workContext.setVdbVersion("1"); //$NON-NLS-1$
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
+        DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
 
         // Initialize components
         RequestID requestID = workContext.getRequestID(1);  
         RequestMessage requestMsg = new RequestMessage(sql);
         TestDQPCoreRequestHandling.addRequest(requestMgr, requestMsg, requestID, command, null); 
         
-        ApplicationEnvironment env = new ApplicationEnvironment();
-        FakeVDBService vdbService = new FakeVDBService();
-        env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
-        MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, requestMgr, prepPlanCache, env, "MyVDB", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        MetaDataProcessor mdProc = new MetaDataProcessor(requestMgr, prepPlanCache, "MyVDB", 1);
                      
         return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata();    
     }
     
     public void testSimpleQuery() throws Exception {
-        Map[] metadata = helpGetMetadata("SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+        Map[] metadata = helpGetMetadata("SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
         assertNotNull(metadata);
         assertEquals(1, metadata.length);
     }
 
     public void testSimpleUpdate() throws Exception {
-        Map[] metadata = helpGetMetadata("INSERT INTO pm1.g1 (e1) VALUES ('x')", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+        Map[] metadata = helpGetMetadata("INSERT INTO pm1.g1 (e1) VALUES ('x')", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
         assertNull(metadata);
         
-        metadata = helpGetMetadata("DELETE FROM pm1.g1 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+        metadata = helpGetMetadata("DELETE FROM pm1.g1 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
         assertNull(metadata);
         
-        metadata = helpGetMetadata("UPDATE pm1.g1 SET e1='y' WHERE e1 = 'x'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+        metadata = helpGetMetadata("UPDATE pm1.g1 SET e1='y' WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
         assertNull(metadata);
         
-        metadata = helpGetMetadata("SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+        metadata = helpGetMetadata("SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm1.g1", FakeMetadataFactory.example1Cached(),FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
         assertNull(metadata);
     }
     
     public void testElementLabel() throws Exception {
-    	Map[] metadata = helpGetMetadata("SELECT E2 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+    	Map[] metadata = helpGetMetadata("SELECT E2 FROM pm1.g1", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
         assertNotNull(metadata);
         assertEquals(1, metadata.length);
         assertEquals("E2", metadata[0].get(ResultsMetadataConstants.ELEMENT_NAME)); //$NON-NLS-1$
     }
     
     public void testSimpleExec() throws Exception {
-        Map[] metadata = helpGetMetadata("EXEC pm1.sq1()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+        Map[] metadata = helpGetMetadata("EXEC pm1.sq1()", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
         assertNotNull(metadata);
         assertEquals(2, metadata.length);        
     }
     
     public void testExecNoResultColumns() throws Exception {
-        Map[] metadata = helpGetMetadata("EXEC pm1.sp5()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+        Map[] metadata = helpGetMetadata("EXEC pm1.sp5()", FakeMetadataFactory.example1Cached(), FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
         assertNotNull(metadata);
         assertEquals(0, metadata.length);                
     }
     
-    private MetadataResult helpTestQuery(QueryMetadataInterface metadata, String sql) throws Exception {
-        FakeVDBService vdbService = new FakeVDBService();
-        vdbService.addModel("MyVDB", "1", "pm1", ModelInfo.PRIVATE, false);  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-        
+    private MetadataResult helpTestQuery(QueryMetadataInterface metadata, String sql, VDBMetaData vdb) throws Exception {
         // Create components
-        MetadataService mdSvc = Mockito.mock(MetadataService.class);
-        Mockito.stub(mdSvc.lookupMetadata(Mockito.anyString(), Mockito.anyString())).toReturn(metadata);
         SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
         
         // Initialize components
-        ApplicationEnvironment env = new ApplicationEnvironment();
-        env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
-        MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, new DQPCore(), prepPlanCache, env, "MyVDB", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        MetaDataProcessor mdProc = new MetaDataProcessor(new DQPCore(), prepPlanCache, "MyVDB", 1);
                      
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName("MyVDB"); //$NON-NLS-1$
-        workContext.setVdbVersion("1"); //$NON-NLS-1$
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "foo")); //$NON-NLS-1$
+        DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
         return mdProc.processMessage(workContext.getRequestID(1), workContext, sql, true);    
     }
 
@@ -159,7 +136,7 @@
         QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel(); 
         String sql = "SELECT e1 FROM pm1.g2"; //$NON-NLS-1$
         
-        MetadataResult response = helpTestQuery(metadata, sql);
+        MetadataResult response = helpTestQuery(metadata, sql, FakeMetadataFactory.examplePrivatePhysicalModelVDB());
         
         helpCheckNumericAttributes(response, 0, 21, 19, 4);
     }
@@ -168,7 +145,7 @@
         QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel(); 
         String sql = "SELECT min(e1), max(e1), sum(e1), avg(e1) FROM pm1.g2"; //$NON-NLS-1$
         
-        MetadataResult response = helpTestQuery(metadata, sql);
+        MetadataResult response = helpTestQuery(metadata, sql, FakeMetadataFactory.examplePrivatePhysicalModelVDB());
         helpCheckNumericAttributes(response, 0, 21, 19, 4);
         helpCheckNumericAttributes(response, 1, 21, 19, 4);
         helpCheckNumericAttributes(response, 2, 22, 20, 0);
@@ -182,7 +159,7 @@
         while(iter.hasNext()) {
             String type = (String) iter.next();
             Class typeClass = DataTypeManager.getDataTypeClass(type);
-            MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, "vdb", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+            MetaDataProcessor processor = new MetaDataProcessor(null, null, "vdb", 1);
             Map columnMetadata = processor.getDefaultColumn("t", "c", typeClass); //$NON-NLS-1$ //$NON-NLS-2$
             verifyColumn(columnMetadata, type);            
         }               
@@ -214,7 +191,7 @@
         verifyAttribute(column, ResultsMetadataConstants.SIGNED, false, Boolean.class, dataType);
 
         verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, false, String.class, dataType);
-        verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, false, String.class, dataType);
+        verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, false, Integer.class, dataType);
         verifyAttribute(column, ResultsMetadataConstants.WRITABLE, false, Boolean.class, dataType);
     }
     

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -49,9 +49,9 @@
 	
 	@BeforeClass public static void setUpOnce() {
 		token.setVdbName("foo"); //$NON-NLS-1$
-		token.setVdbVersion("1"); //$NON-NLS-1$
+		token.setVdbVersion(1); //$NON-NLS-1$
 		token2.setVdbName("foo"); //$NON-NLS-1$
-		token2.setVdbVersion("2"); //$NON-NLS-1$
+		token2.setVdbVersion(2); //$NON-NLS-1$
 	}
     
     //====Tests====//

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,14 +22,18 @@
 
 package org.teiid.dqp.internal.process;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 import org.junit.Test;
-import org.teiid.dqp.internal.process.TestRequest.FakeApplicationEnvironment;
+import org.mockito.Mockito;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryParserException;
@@ -38,7 +42,8 @@
 import com.metamatrix.api.exception.query.QueryValidatorException;
 import com.metamatrix.common.buffer.BufferManagerFactory;
 import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
+import com.metamatrix.dqp.service.AutoGenDataService;
 import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.TestOptimizer;
@@ -60,15 +65,16 @@
 	
 	private static boolean DEBUG = false;
 	
-    static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement) throws Exception { 
-    	helpTestProcessing(preparedSql, values, expected, dataManager, metadata, callableStatement, false);
+
+    static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement, VDBMetaData vdb) throws Exception { 
+    	helpTestProcessing(preparedSql, values, expected, dataManager, metadata, callableStatement, false, vdb);
     }
 
-    static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement, boolean isSessionSpecific) throws Exception { 
-        helpTestProcessing(preparedSql, values, expected, dataManager, (CapabilitiesFinder)null, metadata, null, callableStatement, isSessionSpecific, /* isAlreadyCached */false); 
+    static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement, boolean isSessionSpecific, VDBMetaData vdb) throws Exception { 
+        helpTestProcessing(preparedSql, values, expected, dataManager, (CapabilitiesFinder)null, metadata, null, callableStatement, isSessionSpecific, /* isAlreadyCached */false, vdb); 
     }
     
-    static public void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, boolean callableStatement, boolean isSessionSpecific, boolean isAlreadyCached) throws Exception { 
+    static public void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, boolean callableStatement, boolean isSessionSpecific, boolean isAlreadyCached, VDBMetaData vdb) throws Exception { 
         if ( dataManager == null ) {
             // Construct data manager with data
         	dataManager = new FakeDataManager();
@@ -98,13 +104,13 @@
         }
         
         //Create plan or used cache plan if isPlanCached
-        PreparedStatementRequest plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, SESSION_ID, callableStatement, false);
+        PreparedStatementRequest plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, SESSION_ID, callableStatement, false, vdb);
 
         // Run query
         TestProcessor.doProcess(plan.processPlan, dataManager, expected, plan.context);
         
         //test cached plan
-    	plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, SESSION_ID, callableStatement, false);
+    	plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, SESSION_ID, callableStatement, false,vdb);
     	
         //make sure the plan is only created once
         assertEquals("should reuse the plan", exHitCount, prepPlanCache.getCacheHitCount()); //$NON-NLS-1$
@@ -126,7 +132,7 @@
         }
         
         //get the plan again with a new connection
-        assertNotNull(TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, 7, callableStatement, false));
+        assertNotNull(TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, 7, callableStatement, false, vdb));
 
         /*
          * If the command is not specific to a session we expect
@@ -152,7 +158,7 @@
 		values.add(new Short((short)0));
 		FakeDataManager dataManager = new FakeDataManager();
         TestProcessor.sampleData1(dataManager);
-		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false);
+		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, FakeMetadataFactory.example1VDB());
 	}
     
     @Test public void testSessionSpecificFunction() throws Exception { 
@@ -169,7 +175,7 @@
 		values.add(new Short((short)0));
         FakeDataManager dataManager = new FakeDataManager();
         TestProcessor.sampleData1(dataManager);
-		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, true);
+		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, true, FakeMetadataFactory.example1VDB());
 	}
     
     @Test public void testFunctionWithReferencePushDown() throws Exception { 
@@ -197,7 +203,7 @@
         
         List values = Arrays.asList(0);
 
-        PreparedStatementRequest plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new SessionAwareCache<PreparedPlan>(), SESSION_ID, false, false);
+        PreparedStatementRequest plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new SessionAwareCache<PreparedPlan>(), SESSION_ID, false, false,FakeMetadataFactory.example1VDB());
         
         TestOptimizer.checkNodeTypes(plan.processPlan, TestOptimizer.FULL_PUSHDOWN);  
     }
@@ -206,7 +212,7 @@
 			throws MetaMatrixComponentException, QueryParserException,
 			QueryResolverException, QueryValidatorException,
 			QueryPlannerException {    	
-		return helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), prepPlanCache, SESSION_ID, false, false);
+		return helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), prepPlanCache, SESSION_ID, false, false, FakeMetadataFactory.example1VDB());
     }
 	
 	static public PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
@@ -216,31 +222,33 @@
 			QueryPlannerException {
 		return helpGetProcessorPlan(preparedSql, values,
 				new DefaultCapabilitiesFinder(), FakeMetadataFactory
-						.example1Cached(), prepPlanCache, conn, false, false);
+						.example1Cached(), prepPlanCache, conn, false, false, FakeMetadataFactory.example1VDB());
 	}
 
 	static PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
-			CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, int conn, boolean callableStatement, boolean limitResults)
+			CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, int conn, boolean callableStatement, boolean limitResults, VDBMetaData vdb)
 			throws MetaMatrixComponentException, QueryParserException,
 			QueryResolverException, QueryValidatorException,
 			QueryPlannerException {
         
         //Create Request
         RequestMessage request = new RequestMessage(preparedSql);
-        request.setPreparedStatement(true);
-        request.setCallableStatement(callableStatement);
+        if (callableStatement) {
+        	request.setStatementType(StatementType.CALLABLE);
+        } else {
+        	request.setStatementType(StatementType.PREPARED);
+        }
         request.setParameterValues(values);
 		if (values != null && values.size() > 0 && values.get(0) instanceof List) {
-			request.setPreparedBatchUpdate(true);
+			request.setBatchedUpdate(true);
 		}
         if (limitResults) {
         	request.setRowLimit(1);
         }
-
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName("example1"); //$NON-NLS-1$
-        workContext.setVdbVersion("1"); //$NON-NLS-1$
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(conn), "foo")); //$NON-NLS-1$        
+       
+        DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
+        workContext.setSessionToken(new SessionToken(conn, "foo")); //$NON-NLS-1$ 
+        
         PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache) {
         	@Override
         	protected void createProcessor(Command processingCommand)
@@ -248,8 +256,12 @@
         		
         	}
         };
-        FakeApplicationEnvironment env = new FakeApplicationEnvironment(metadata, "example1", "1", "pm1", "1", "BINDING"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-        serverRequest.initialize(request, env, BufferManagerFactory.getStandaloneBufferManager(), null, null, DEBUG, null, workContext, 101024);
+        
+        ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+        Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
+        
+        serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null,  null, null, DEBUG, null, workContext, 101024,repo);
+
         serverRequest.setMetadata(capFinder, metadata, null);
         serverRequest.processRequest();
         
@@ -367,9 +379,9 @@
         
         SessionAwareCache<PreparedPlan> planCache = new SessionAwareCache<PreparedPlan>();
         
-		helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true);
+		helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, FakeMetadataFactory.example1VDB());
 
-		helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true);
+		helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, FakeMetadataFactory.example1VDB());
 		//make sure the plan wasn't reused
 		assertEquals(0, planCache.getCacheHitCount());
     }
@@ -384,7 +396,7 @@
 		List<String> values = Arrays.asList("aa "); //$NON-NLS-1$
         FakeDataManager dataManager = new FakeDataManager();
         TestProcessor.sampleData2b(dataManager);
-		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false);
+		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false, FakeMetadataFactory.example1VDB());
     }
     
     @Test(expected=QueryValidatorException.class) public void testLimitValidation() throws Exception {
@@ -392,7 +404,7 @@
         
 		List values = Arrays.asList(-1);
         FakeDataManager dataManager = new FakeDataManager();
-		helpTestProcessing(preparedSql, values, null, dataManager, FakeMetadataFactory.example1Cached(), false, false);
+		helpTestProcessing(preparedSql, values, null, dataManager, FakeMetadataFactory.example1Cached(), false, false, FakeMetadataFactory.example1VDB());
     }
     
     @Test public void testExecParam() throws Exception {
@@ -405,7 +417,7 @@
         
         FakeDataManager dataManager = new FakeDataManager();
         TestProcessor.sampleData1(dataManager);
-		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false);
+		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false, FakeMetadataFactory.example1VDB());
     }
     
     @Test public void testLimitParam() throws Exception {
@@ -418,7 +430,7 @@
         
         FakeDataManager dataManager = new FakeDataManager();
         TestProcessor.sampleData1(dataManager);
-		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false);
+		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false,FakeMetadataFactory.example1VDB());
     }
     
     @Test public void testXQueryParam() throws Exception {
@@ -431,7 +443,7 @@
         
         FakeDataManager dataManager = new FakeDataManager();
         TestProcessor.sampleData1(dataManager);
-		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.exampleXQueryTransformations(), false, false);
+		helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.exampleXQueryTransformations(), false, false, FakeMetadataFactory.exampleXQueryTransformationsVDB());
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -73,7 +73,7 @@
         };
     	
     	// Create the plan and process the query
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false,FakeMetadataFactory.example1VDB());
     	Update update = (Update)dataManager.getCommandHistory().iterator().next();
     	assertTrue(((Constant)update.getChangeList().getClauses().get(0).getValue()).isMultiValued());
     }
@@ -147,7 +147,7 @@
    		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
     	
     	// Create the plan and process the query
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false,FakeMetadataFactory.example1VDB());
 
     	// Repeat with different number of commands in batch
     	// Create expected results
@@ -167,7 +167,7 @@
    		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 5")); //$NON-NLS-1$
     	
     	// Use the cached plan and process the query
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true,FakeMetadataFactory.example1VDB());
 
     	// Verify all the queries that were run
     	assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
@@ -241,7 +241,7 @@
    		finalQueryList.add(new String("UPDATE pm1.g1 SET e2 = 1 WHERE pm1.g1.e1 = 'b'")); //$NON-NLS-1$
     	
     	// Create the plan and process the query
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false, FakeMetadataFactory.example1VDB());
 
     	// Repeat
         expected = new List[] { 
@@ -259,7 +259,7 @@
    		finalQueryList.add(new String("UPDATE pm1.g1 SET e2 = 3 WHERE pm1.g1.e1 = 'd'")); //$NON-NLS-1$
     	
     	// Use the cached plan and process the query
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true,FakeMetadataFactory.example1VDB());
 
     	// Verify all the queries that were run
     	assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
@@ -336,7 +336,7 @@
    		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
     	
     	// Create the plan and process the query
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false, FakeMetadataFactory.example1VDB());
 
     	// Repeat with different number of commands in batch
     	// Create expected results
@@ -353,7 +353,7 @@
    		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE pm1.g1.e2 = 0")); //$NON-NLS-1$
     	
     	// Use the cached plan and process the query
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true, FakeMetadataFactory.example1VDB());
 
     	// Repeat with different number of commands in batch
 		// Create expected results
@@ -381,7 +381,7 @@
 		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'c', e3 = TRUE WHERE pm1.g1.e2 = 4")); //$NON-NLS-1$
 		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 5")); //$NON-NLS-1$
     	
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true, FakeMetadataFactory.example1VDB());
 
     	// Verify all the queries that were run
     	assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$
@@ -457,7 +457,7 @@
    		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'b', e3 = TRUE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
     	
     	// Create the plan and process the query
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, false, FakeMetadataFactory.example1VDB());
 
     	// Repeat with different number of commands in batch
         expected = new List[] { 
@@ -472,7 +472,7 @@
    		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'c', e3 = FALSE WHERE pm1.g1.e2 = 1")); //$NON-NLS-1$
     	
     	// Use the cached plan and process the query
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true, FakeMetadataFactory.example1VDB());
 
     	// Repeat with different number of commands in batch
         expected = new List[] { 
@@ -495,7 +495,7 @@
 		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'f', e3 = TRUE WHERE pm1.g1.e2 = 2")); //$NON-NLS-1$
 		finalQueryList.add(new String("UPDATE pm1.g1 SET e1 = 'g', e3 = TRUE WHERE pm1.g1.e2 = 3")); //$NON-NLS-1$
     	
-    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true);
+    	TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, FakeMetadataFactory.example1Cached(), prepPlanCache, false, false, true,FakeMetadataFactory.example1VDB());
 
     	// Verify all the queries that were run
     	assertEquals("Unexpected queries executed -", finalQueryList, dataManager.getQueries()); //$NON-NLS-1$

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -30,24 +30,17 @@
 import junit.framework.TestCase;
 
 import org.mockito.Mockito;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryParserException;
 import com.metamatrix.api.exception.query.QueryPlannerException;
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.ApplicationService;
 import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
 import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
 import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.FakeAuthorizationService;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.parser.QueryParser;
@@ -67,7 +60,7 @@
 
     private final static String QUERY = "SELECT * FROM pm1.g1";  //$NON-NLS-1$
     private final static String VDB = "VDB";  //$NON-NLS-1$
-    private final static String VDB_VERSION = "1";  //$NON-NLS-1$
+    private final static int VDB_VERSION = 1;  //$NON-NLS-1$
     private final static String MODEL = "pm1";  //$NON-NLS-1$
     private final static String BINDING_ID = "1";  //$NON-NLS-1$
     private final static String BINDING_NAME = "BINDING";  //$NON-NLS-1$
@@ -87,13 +80,8 @@
         doc1.putProperty(FakeMetadataObject.Props.XML_SCHEMAS, schemas);
         RequestMessage message = new RequestMessage("select * from xmltest.doc1"); //$NON-NLS-1$
         message.setValidationMode(true);
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName(VDB); 
-        workContext.setVdbVersion(VDB_VERSION); 
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
-        FakeApplicationEnvironment environment = 
-            new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);        
-        Request request = helpProcessMessage(environment, message, null, workContext);
+        DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
+        Request request = helpProcessMessage(message, null, workContext);
         assertEquals(schemas, request.schemas);
     }
 
@@ -113,15 +101,14 @@
         Command command = QueryParser.getQueryParser().parseCommand(QUERY);
         QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
         
+        ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+        Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
+        
+        
         RequestMessage message = new RequestMessage();
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName(VDB); 
-        workContext.setVdbVersion(VDB_VERSION); 
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
-        FakeApplicationEnvironment environment = 
-            new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);        
+        DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
         
-        request.initialize(message, environment, null, null, null, false, null, workContext, 101024);
+        request.initialize(message, null, null, null,null,false, null, workContext, 101024, repo);
         request.initMetadata();
         request.validateAccess(command);
     }
@@ -137,46 +124,32 @@
     public void testProcessRequest() throws Exception {
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         
-        FakeApplicationEnvironment environment = 
-            new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);        
-
-        
         //Try before plan is cached.
         //If this doesn't throw an exception, assume it was successful.
         RequestMessage message = new RequestMessage(QUERY);
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName(VDB); 
-        workContext.setVdbVersion(VDB_VERSION); 
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
+        DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
 
-        helpProcessMessage(environment, message, null, workContext);
+        helpProcessMessage(message, null, workContext);
         
         //Try again, now that plan is already cached.
         //If this doesn't throw an exception, assume it was successful.        
         message = new RequestMessage(QUERY);
-        helpProcessMessage(environment, message, null, workContext);
+        helpProcessMessage(message, null, workContext);
     }
     
     public void testCommandContext() throws Exception {
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         
-        FakeApplicationEnvironment environment = 
-            new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);        
-
-        
         //Try before plan is cached.
         //If this doesn't throw an exception, assume it was successful.
         RequestMessage message = new RequestMessage(QUERY);
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName(VDB); 
-        workContext.setVdbVersion(VDB_VERSION); 
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
-        Request request = helpProcessMessage(environment, message, null, workContext);
+        DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
+        
+        Request request = helpProcessMessage(message, null, workContext);
         assertEquals("5", request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID)); //$NON-NLS-1$
     }
 
-    private Request helpProcessMessage(FakeApplicationEnvironment environment,
-                                    RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws QueryValidatorException,
+    private Request helpProcessMessage(RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws QueryValidatorException,
                                                            QueryParserException,
                                                            QueryResolverException,
                                                            MetaMatrixComponentException,
@@ -187,10 +160,14 @@
         } else {
         	request = new Request();
         }
-        request.initialize(message, environment, Mockito.mock(BufferManager.class),
-				new FakeDataManager(), null, false, null, workContext,
-				101024);
         
+        ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
+        Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
+        
+        request.initialize(message, Mockito.mock(BufferManager.class),
+				new FakeDataManager(),  null, null, false, null, workContext,
+				101024, repo);
+        
         request.processRequest();
         return request;
     }
@@ -207,66 +184,24 @@
     public void testProcessRequestPreparedStatement() throws Exception {
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>();
-        FakeApplicationEnvironment environment = 
-            new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);        
         
 
         //Try before plan is cached.
         //If this doesn't throw an exception, assume it was successful.
         RequestMessage message = new RequestMessage(QUERY);
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName(VDB); 
-        workContext.setVdbVersion(VDB_VERSION); 
-        workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5), "foo")); //$NON-NLS-1$
-        message.setPreparedStatement(true);
+        DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
+        
+        message.setStatementType(StatementType.PREPARED);
         message.setParameterValues(new ArrayList());
         
-        helpProcessMessage(environment, message, cache, workContext);
+        helpProcessMessage(message, cache, workContext);
         
         //Try again, now that plan is already cached.
         //If this doesn't throw an exception, assume it was successful.
         message = new RequestMessage(QUERY);
-        message.setPreparedStatement(true);
+        message.setStatementType(StatementType.PREPARED);
         message.setParameterValues(new ArrayList());
 
-        helpProcessMessage(environment, message, cache, workContext);
+        helpProcessMessage(message, cache, workContext);
     }
-    
-    
-    /**Fake ApplicationEnvironment that always returns the same metadata*/
-    public static final class FakeApplicationEnvironment extends ApplicationEnvironment {
-        private QueryMetadataInterface metadata;
-        
-        private FakeVDBService fakeVDBService;
-        
-        public FakeApplicationEnvironment(QueryMetadataInterface metadata, String vdbname, String version, String model, 
-                                          String bindingID, String bindingName) {
-            this.metadata = metadata; 
-            
-            fakeVDBService = new FakeVDBService();
-            fakeVDBService.addModel(vdbname, version, model, ModelInfo.PUBLIC, false);
-            fakeVDBService.addBinding(vdbname, version, model, bindingID, bindingName);
-        }
-        
-        public ApplicationService findService(String type) {
-            if (type == DQPServiceNames.METADATA_SERVICE) {
-                MetadataService mdSvc = Mockito.mock(MetadataService.class);
-                try {
-					Mockito.stub(mdSvc.lookupMetadata(Mockito.anyString(), Mockito.anyString())).toReturn(metadata);
-				} catch (MetaMatrixComponentException e) {
-					throw new RuntimeException(e);
-				}
-                return mdSvc;
-            } else if (type == DQPServiceNames.VDB_SERVICE) {
-                return fakeVDBService;
-            } else if (type == DQPServiceNames.DATA_SERVICE) {
-                return new AutoGenDataService();
-            } else if (type == DQPServiceNames.AUTHORIZATION_SERVICE) {
-                return new FakeAuthorizationService(true);
-            }
-            
-            return null;
-        }
-    }
-    
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -85,7 +85,15 @@
 	    private void assertDoneState() {
 	        checkState(ThreadState.DONE);
 	    }
-		
+
+		@Override
+		protected boolean assosiateSecurityContext() {
+			return false;
+		}
+
+		@Override
+		protected void clearSecurityContext() {
+		}
 	}
 	
     public TestWorkItemState(String name) {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,15 +22,11 @@
 
 package org.teiid.dqp.internal.process.multisource;
 
-import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
 
-import org.teiid.dqp.internal.process.multisource.MultiSourceElementReplacementVisitor;
-import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
-
 import junit.framework.TestCase;
 
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.service.FakeVDBService;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.QueryResolver;
@@ -45,13 +41,10 @@
 public class TestMultiSourceElementReplacementVisitor extends TestCase {
 
     public QueryMetadataInterface getMetadata() throws Exception {
-        FakeVDBService vdbService = new FakeVDBService();
-        vdbService.addModel("MyVDB", "1", "MultiModel", ModelInfo.PUBLIC, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        vdbService.addBinding("MyVDB", "1", "MultiModel", "mmuuid:blahblahblah", "x"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-        vdbService.addBinding("MyVDB", "1", "MultiModel", "mmuuid:foofoofoo", "y"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
         
         QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
-        Collection multiSourceModels = vdbService.getMultiSourceModels("MyVDB", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        Set<String> multiSourceModels = new HashSet<String>();
+        multiSourceModels.add("MultiModel");
         MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);  
         
         return wrapper;

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,18 +22,13 @@
 
 package org.teiid.dqp.internal.process.multisource;
 
-import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
 
-import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
-import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
-
 import junit.framework.TestCase;
 
 import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.service.FakeVDBService;
 import com.metamatrix.query.unittest.FakeMetadataFactory;
 
 
@@ -43,12 +38,8 @@
 public class TestMultiSourceMetadataWrapper extends TestCase {
 
     public void testMultiSourcePseudoElement() throws Exception {
-        String vdbName = "My Cool VDB"; //$NON-NLS-1$
-        String vdbVersion = "1"; //$NON-NLS-1$
-        
-        FakeVDBService vdbService = new FakeVDBService();
-        vdbService.addModel(vdbName, vdbVersion, "BQT1", ModelInfo.PUBLIC, true); //$NON-NLS-1$
-        Collection multiSourceModels = vdbService.getMultiSourceModels(vdbName, vdbVersion);
+        HashSet<String> multiSourceModels = new HashSet<String>();
+        multiSourceModels.add("BQT1");
         MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(FakeMetadataFactory.exampleBQTCached(), multiSourceModels);
         
         Object groupID = wrapper.getGroupID("BQT1.SmallA"); //$NON-NLS-1$

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,26 +22,23 @@
 
 package org.teiid.dqp.internal.process.multisource;
 
+import static org.junit.Assert.*;
+
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
-import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
-import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
-import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
-import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
+import org.junit.Test;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.process.DQPWorkContext;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.vdb.api.ModelInfo;
 import com.metamatrix.core.id.IDGenerator;
 import com.metamatrix.core.id.IntegerIDFactory;
-import com.metamatrix.dqp.service.FakeVDBService;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.QueryOptimizer;
@@ -68,7 +65,7 @@
  * 
  * @since 4.2
  */
-public class TestMultiSourcePlanToProcessConverter extends TestCase {
+public class TestMultiSourcePlanToProcessConverter {
     
     private final class MultiSourceDataManager extends HardcodedDataManager {
         
@@ -93,19 +90,21 @@
 
     private static final boolean DEBUG = false;
     
-    public void helpTestMultiSourcePlan(QueryMetadataInterface metadata, String userSql, String multiModel, int sourceCount, ProcessorDataManager dataMgr, List[] expectedResults) throws Exception {
-        final String vdbName = "MyVDB"; //$NON-NLS-1$
-        final String vdbVersion = "1"; //$NON-NLS-1$
-     
-        // Set up metadata and other dependencies
-        FakeVDBService vdbService = new FakeVDBService();
-        vdbService.addModel(vdbName, vdbVersion, multiModel, ModelInfo.PUBLIC, true); 
+    public void helpTestMultiSourcePlan(QueryMetadataInterface metadata, String userSql, String multiModel, int sourceCount, ProcessorDataManager dataMgr, List[] expectedResults, VDBMetaData vdb) throws Exception {
         
-        char sourceID = 'a';
-        for(int i=0; i<sourceCount; i++, sourceID++) {
-            vdbService.addBinding(vdbName, vdbVersion, multiModel, "mmuuid:source_" + sourceID, "" + sourceID); //$NON-NLS-1$ //$NON-NLS-2$ 
+       DQPWorkContext dqpContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
+     
+        Set<String> multiSourceModels = vdb.getMultiSourceModelNames();
+        for (String model:multiSourceModels) {
+            char sourceID = 'a';
+            // by default every model has one binding associated, but for multi-source there were none assigned. 
+            ModelMetaData m = vdb.getModel(model);
+            int x = m.getSourceNames().size();
+            for(int i=x; i<sourceCount; i++, sourceID++) {
+            	 m.addSourceMapping("" + sourceID, null);
+            }
         }
-        Set<String> multiSourceModels = new HashSet<String>(vdbService.getMultiSourceModels(vdbName, vdbVersion));
+        
         MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels); 
         AnalysisRecord analysis = new AnalysisRecord(false, false, DEBUG);
         
@@ -122,8 +121,8 @@
         idGenerator.setDefaultFactory(new IntegerIDFactory());            
         
         Properties props = new Properties();
-        CommandContext context = new CommandContext("0", "test", "user", null, vdbName, vdbVersion, props, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        context.setPlanToProcessConverter(new MultiSourcePlanToProcessConverter(metadata, idGenerator, analysis, finder, multiSourceModels, vdbName, vdbService, vdbVersion, context));
+        CommandContext context = new CommandContext("0", "test", "user", null, vdb.getName(), vdb.getVersion(), props, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        context.setPlanToProcessConverter(new MultiSourcePlanToProcessConverter(metadata, idGenerator, analysis, finder, multiSourceModels, dqpContext, context));
 
         ProcessorPlan plan = QueryOptimizer.optimizePlan(command, wrapper, idGenerator, finder, analysis, context);
                         
@@ -135,7 +134,7 @@
         TestProcessor.helpProcess(plan, context, dataMgr, expectedResults);                        
     }
 
-    public void testNoReplacement() throws Exception {
+    @Test public void testNoReplacement() throws Exception {
         final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
         final String userSql = "SELECT * FROM MultiModel.Phys WHERE SOURCE_NAME = 'bogus'"; //$NON-NLS-1$
         final String multiModel = "MultiModel"; //$NON-NLS-1$
@@ -143,10 +142,10 @@
         final List[] expected = 
             new List[0];
         final ProcessorDataManager dataMgr = new MultiSourceDataManager();
-        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
     }
 
-    public void testSingleReplacement() throws Exception {
+    @Test public void testSingleReplacement() throws Exception {
         final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
         final String userSql = "SELECT * FROM MultiModel.Phys WHERE SOURCE_NAME = 'a'"; //$NON-NLS-1$
         final String multiModel = "MultiModel"; //$NON-NLS-1$
@@ -155,10 +154,10 @@
             new List[] { Arrays.asList(new Object[] { null, null, null}) };
         final HardcodedDataManager dataMgr = new MultiSourceDataManager();
         dataMgr.setMustRegisterCommands(false);
-        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
     }
     
-    public void testMultiReplacement() throws Exception {
+    @Test public void testMultiReplacement() throws Exception {
         final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
         final String userSql = "SELECT * FROM MultiModel.Phys"; //$NON-NLS-1$
         final String multiModel = "MultiModel"; //$NON-NLS-1$
@@ -168,10 +167,10 @@
                          Arrays.asList(new Object[] { null, null, null}),
                          Arrays.asList(new Object[] { null, null, null})};
         final ProcessorDataManager dataMgr = new MultiSourceDataManager();
-        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
     }
     
-    public void testMultiReplacementWithOrderBy() throws Exception {
+    @Test public void testMultiReplacementWithOrderBy() throws Exception {
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleMultiBinding();
 
         final String userSql = "SELECT * FROM MultiModel.Phys order by a"; //$NON-NLS-1$
@@ -192,10 +191,10 @@
                         new List[] {
                             Arrays.asList("e", "z", "b"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                             Arrays.asList("f", "z", "b")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
     }
 
-    public void testMultiReplacementWithLimit() throws Exception {
+    @Test public void testMultiReplacementWithLimit() throws Exception {
         final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
         final String userSql = "SELECT distinct * FROM MultiModel.Phys order by a limit 1"; //$NON-NLS-1$
         final String multiModel = "MultiModel"; //$NON-NLS-1$
@@ -212,10 +211,10 @@
                         new List[] {
                             Arrays.asList("e", "z", "b"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                             Arrays.asList("f", "z", "b")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
     }
     
-    public void testMultiDependentJoin() throws Exception {
+    @Test public void testMultiDependentJoin() throws Exception {
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleMultiBinding();
         
         final String userSql = "SELECT a.a FROM MultiModel.Phys a inner join MultiModel.Phys b makedep on (a.a = b.a) order by a"; //$NON-NLS-1$
@@ -238,17 +237,17 @@
         dataMgr.addData("SELECT g_0.a FROM MultiModel.Phys AS g_0 WHERE g_0.a IN ('x', 'y')",  //$NON-NLS-1$
                         new List[] { Arrays.asList(new Object[] { "x" }), //$NON-NLS-1$
                                      Arrays.asList(new Object[] { "y" })}); //$NON-NLS-1$
-        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
     }
     
-    public void testSingleReplacementInDynamicCommand() throws Exception {
+    @Test public void testSingleReplacementInDynamicCommand() throws Exception {
         final QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
         final String userSql = "exec Virt.sq1('a')"; //$NON-NLS-1$
         final String multiModel = "MultiModel"; //$NON-NLS-1$
         final int sources = 3;
         final List[] expected = new List[] { Arrays.asList(new Object[] { null, null}), };
         final ProcessorDataManager dataMgr = new MultiSourceDataManager();
-        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected);
+        helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, FakeMetadataFactory.exampleMultiBindingVDB());
     }
 
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -27,21 +27,18 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import junit.framework.TestCase;
+
 import org.mockito.Mockito;
+import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.dqp.internal.process.Request;
-import org.teiid.dqp.internal.process.validator.AuthorizationValidationVisitor;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryParserException;
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.vdb.api.ModelInfo;
 import com.metamatrix.dqp.service.AuthorizationService;
 import com.metamatrix.dqp.service.FakeAuthorizationService;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.dqp.service.VDBService;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.QueryResolver;
@@ -68,40 +65,40 @@
         FakeAuthorizationService svc = new FakeAuthorizationService(false);
         
         // pm1.g1
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_DELETE, "pm1.g1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_DELETE, "pm1.g1"); //$NON-NLS-1$
         
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_READ, "pm1.g1"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_READ, "pm1.g1.e1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_READ, "pm1.g1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_READ, "pm1.g1.e1"); //$NON-NLS-1$
 
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1.e1"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1.e2"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1.e3"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g1.e4"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1.e1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1.e2"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1.e3"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g1.e4"); //$NON-NLS-1$
 
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g1"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g1.e2"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g1.e3"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g1.e4"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g1.e2"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g1.e3"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g1.e4"); //$NON-NLS-1$
 
         // pm1.g2
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g2"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g2.e2"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g2.e3"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_CREATE, "pm1.g2.e4"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g2"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g2.e2"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g2.e3"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_CREATE, "pm1.g2.e4"); //$NON-NLS-1$
 
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g2"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g2.e2"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g2.e3"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_UPDATE, "pm1.g2.e4"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g2"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g2.e2"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g2.e3"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_UPDATE, "pm1.g2.e4"); //$NON-NLS-1$
 
         // pm1.g4
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_DELETE, "pm1.g4"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_DELETE, "pm1.g4.e1"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_DELETE, "pm1.g4.e2"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_DELETE, "pm1.g4"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_DELETE, "pm1.g4.e1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_DELETE, "pm1.g4.e2"); //$NON-NLS-1$
 
         // pm1.sq2
-        svc.addResource(CONN_ID, AuthorizationService.ACTION_READ, "pm1.sq1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.ACTION_READ, "pm1.sq1"); //$NON-NLS-1$
         
         return svc;
     }
@@ -111,21 +108,23 @@
         FakeAuthorizationService svc = new FakeAuthorizationService(true);
         
         // pm2.g2
-        svc.addResource(CONN_ID, AuthorizationService.CONTEXT_INSERT, "pm2.g2.e1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.CONTEXT_INSERT, "pm2.g2.e1"); //$NON-NLS-1$
         
         // pm3.g2
-        svc.addResource(CONN_ID, AuthorizationService.CONTEXT_INSERT, "pm3.g2.e1"); //$NON-NLS-1$
-        svc.addResource(CONN_ID, AuthorizationService.CONTEXT_INSERT, "pm3.g2.e2"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.CONTEXT_INSERT, "pm3.g2.e1"); //$NON-NLS-1$
+        svc.addResource(AuthorizationService.CONTEXT_INSERT, "pm3.g2.e2"); //$NON-NLS-1$
         
         return svc;
     }
 
-    private void helpTest(AuthorizationService svc, String sql, QueryMetadataInterface metadata, String[] expectedInaccesible) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+    private void helpTest(AuthorizationService svc, String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
         QueryParser parser = QueryParser.getQueryParser();
         Command command = parser.parseCommand(sql);
         QueryResolver.resolveCommand(command, metadata);
         
-        AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(CONN_ID, svc, Mockito.mock(VDBService.class), "foo", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        vdb.addAttchment(QueryMetadataInterface.class, metadata);
+        
+        AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(svc, vdb); 
         ValidatorReport report = Validator.validate(command, metadata, visitor);
         if(report.hasItems()) {
             ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
@@ -146,109 +145,107 @@
     }
     
     public void testEverythingAccessible() throws Exception {
-        helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
     
     public void testEverythingAccessible1() throws Exception {
-        helpTest(exampleAuthSvc1(), "SELECT e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc1(), "SELECT e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
     
     public void testEverythingAccessible2() throws Exception {
-        helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
 
     public void testInaccesibleElement() throws Exception {        
-        helpTest(exampleAuthSvc1(), "SELECT e2 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "SELECT e2 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     public void testInaccesibleElement2() throws Exception {        
-        helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e2', '1')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e2', '1')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testInaccesibleGroup() throws Exception {        
-        helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g2", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g2", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testInsert() throws Exception {        
-        helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
 
     public void testInsertInaccessible() throws Exception {        
-        helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testUpdate() throws Exception {        
-        helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e2 = 5", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e2 = 5", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
 
     public void testUpdateCriteriaInaccessibleForRead() throws Exception {        
-        helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testUpdateElementInaccessibleForUpdate() throws Exception {        
-        helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testDelete() throws Exception {        
-        helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
 
     public void testDeleteCriteriaInaccesibleForRead() throws Exception {        
-        helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g2 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g2 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testDeleteInaccesibleGroup() throws Exception {        
-        helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g3", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g3"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g3", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g3"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     public void testProc() throws Exception {
-        helpTest(exampleAuthSvc1(), "EXEC pm1.sq1()", FakeMetadataFactory.example1Cached(), new String[] {});         //$NON-NLS-1$
+        helpTest(exampleAuthSvc1(), "EXEC pm1.sq1()", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB());         //$NON-NLS-1$
     }
 
     public void testProcInaccesible() throws Exception {
-        helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.sq2"});         //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}, FakeMetadataFactory.example1VDB());         //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testSelectIntoEverythingAccessible() throws Exception {
-        helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
 
     public void testSelectIntoTarget_e1_NotAccessible() throws Exception {
-        helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm2.g2.e1"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm2.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testSelectIntoTarget_e1e2_NotAccessible() throws Exception {
-        helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm3.g2.e1", "pm3.g2.e2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm3.g2.e1", "pm3.g2.e2"},FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
     public void testTempTableSelectInto() throws Exception {
-        helpTest(exampleAuthSvc1(), "SELECT e1 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc1(), "SELECT e1 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
     
     public void testTempTableSelectInto1() throws Exception {
-        helpTest(exampleAuthSvc1(), "SELECT e1, e2 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "SELECT e1, e2 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     public void testTempTableInsert() throws Exception {
-        helpTest(exampleAuthSvc2(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc2(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
 
     public void testXMLAccessible() throws Exception {
-        helpTest(exampleAuthSvc2(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
+        helpTest(exampleAuthSvc2(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
     }
     
     public void testXMLInAccessible() throws Exception {
-        helpTest(exampleAuthSvc1(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(exampleAuthSvc1(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
 	private void helpTestLookupVisibility(boolean visible) throws QueryParserException, QueryValidatorException, MetaMatrixComponentException {
-		FakeVDBService vdbService = new FakeVDBService();
-		String vdbName = "foo"; //$NON-NLS-1$
-		String vdbVersion = "1"; //$NON-NLS-1$
-		String modelName = "pm1"; //$NON-NLS-1$
-		vdbService.addModel(vdbName, vdbVersion, modelName, visible?ModelInfo.PUBLIC:ModelInfo.PRIVATE, false);
-		AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(CONN_ID, Mockito.mock(AuthorizationService.class), vdbService, vdbName, vdbVersion);
-		
+		VDBMetaData vdb = FakeMetadataFactory.example1VDB();
+		if (!visible) {
+			vdb.getModel("pm1").setVisible(false);
+		}
+		AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(Mockito.mock(AuthorizationService.class), vdb);
 		String sql = "select lookup('pm1.g1', 'e1', 'e2', 1)"; //$NON-NLS-1$
 		Command command = QueryParser.getQueryParser().parseCommand(sql);
 		Request.validateWithVisitor(mvvv, FakeMetadataFactory.example1Cached(), command);

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.transaction;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.xa.XAResource;
-
-import org.teiid.dqp.internal.transaction.TransactionContextImpl;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.UnitTestUtil;
-
-public class TestTransactionContextImpl extends TestCase {
-    
-    public void testSerialization() throws Exception {
-        TransactionContextImpl context = new TransactionContextImpl();
-        
-        UnitTestUtil.helpSerialize(context);
-        
-        context.setTransaction(new Transaction() {
-
-            public void commit() throws RollbackException,
-                                HeuristicMixedException,
-                                HeuristicRollbackException,
-                                SecurityException,
-                                IllegalStateException,
-                                SystemException {
-            }
-
-            public boolean delistResource(XAResource arg0,
-                                          int arg1) throws IllegalStateException,
-                                                   SystemException {
-                return false;
-            }
-
-            public boolean enlistResource(XAResource arg0) throws RollbackException,
-                                                          IllegalStateException,
-                                                          SystemException {
-                return false;
-            }
-
-            public int getStatus() throws SystemException {
-                return 0;
-            }
-
-            public void registerSynchronization(Synchronization arg0) throws RollbackException,
-                                                                     IllegalStateException,
-                                                                     SystemException {
-            }
-
-            public void rollback() throws IllegalStateException,
-                                  SystemException {
-            }
-
-            public void setRollbackOnly() throws IllegalStateException,
-                                         SystemException {
-            }
-            
-        }, "foo"); //$NON-NLS-1$
-        
-        try {
-            UnitTestUtil.helpSerialize(context);
-            fail("expected exception"); //$NON-NLS-1$
-        } catch (MetaMatrixRuntimeException e) {
-            
-        }
-    }
-
-}

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -22,20 +22,23 @@
 
 package org.teiid.dqp.internal.transaction;
 
+import javax.resource.spi.XATerminator;
 import javax.transaction.xa.XAResource;
 
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
 import org.teiid.adminapi.Transaction;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.common.xa.MMXid;
 import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.core.util.SimpleMock;
+import com.metamatrix.dqp.service.TransactionContext;
 
 public class TestTransactionServer extends TestCase {
 
     private TransactionServerImpl server;
-
+    private XATerminator xaTerminator;
+    
     private static final String THREAD1 = "1"; //$NON-NLS-1$
     private static final String THREAD2 = "2"; //$NON-NLS-1$
 
@@ -51,7 +54,11 @@
      */
     protected void setUp() throws Exception {
         server = new TransactionServerImpl();
-        server.setTransactionProvider(SimpleMock.createSimpleMock(TransactionProvider.class)); 
+        TransactionProvider provider = Mockito.mock(TransactionProvider.class);
+        xaTerminator = Mockito.mock(XATerminator.class);
+        Mockito.stub(provider.getXATerminator()).toReturn(xaTerminator);
+        server.setTransactionProvider(provider); 
+        server.setXidFactory(new XidFactory());
     }
 
     /**
@@ -61,7 +68,7 @@
         server.begin(THREAD1);
 
         try {
-            server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+            server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
             assertEquals("Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.", //$NON-NLS-1$
@@ -73,7 +80,7 @@
      * once in a global, cannot start a local
      */
     public void testTransactionExclusion1() throws Exception {
-        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false);
 
         try {
             server.begin(THREAD1);
@@ -88,13 +95,13 @@
      * global can only be started once
      */
     public void testTransactionExclusion2() throws Exception {
-        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
 
         try {
-            server.start(THREAD2, XID1, XAResource.TMNOFLAGS, 100);
+            server.start(THREAD2, XID1, XAResource.TMNOFLAGS, 100,false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
-            assertEquals("Global transaction MMXid global:1 branch:null format:0 already exists.", ex.getMessage()); //$NON-NLS-1$
+            assertEquals("Global transaction Teiid-Xid global:1 branch:null format:0 already exists.", ex.getMessage()); //$NON-NLS-1$
         }
     }
 
@@ -102,10 +109,10 @@
      * global cannot be nested
      */
     public void testTransactionExclusion3() throws Exception {
-        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
 
         try {
-            server.start(THREAD1, XID2, XAResource.TMNOFLAGS, 100);
+            server.start(THREAD1, XID2, XAResource.TMNOFLAGS, 100,false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
             assertEquals("Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.", //$NON-NLS-1$
@@ -132,12 +139,12 @@
      * global cannot be nested
      */
     public void testTransactionExclusion5() throws Exception {
-        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
-        server.start(THREAD2, XID2, XAResource.TMNOFLAGS, 100);
-        server.end(THREAD2, XID2, XAResource.TMSUCCESS);
+        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+        server.start(THREAD2, XID2, XAResource.TMNOFLAGS, 100,false);
+        server.end(THREAD2, XID2, XAResource.TMSUCCESS,false);
 
         try {
-            server.start(THREAD1, XID2, XAResource.TMJOIN, 100);
+            server.start(THREAD1, XID2, XAResource.TMJOIN, 100,false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
             assertEquals("Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.", //$NON-NLS-1$
@@ -156,10 +163,49 @@
         }
     }
 
+    public void testLocalSetRollback() throws Exception {
+        TransactionContext tc = server.begin(THREAD1);
+        tc.incrementPartcipatingSourceCount("s1");
+        tc.setRollbackOnly();
+        
+        server.commit(THREAD1);
+        
+        Mockito.verify(xaTerminator).rollback(tc.getXid());
+    }    
+    
+    public void testSinglePhaseCommit() throws Exception {
+        TransactionContext tc = server.begin(THREAD1);
+        tc.incrementPartcipatingSourceCount("S1");
+        
+        server.commit(THREAD1);
+        
+        Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+        
+        tc = server.begin(THREAD1);
+        tc.incrementPartcipatingSourceCount("S1");
+        tc.incrementPartcipatingSourceCount("S1");
+        
+        server.commit(THREAD1);
+        
+        Mockito.verify(xaTerminator).commit(tc.getXid(), true);        
+    }      
+    
+    public void testTwoPhaseCommit() throws Exception {
+        TransactionContext tc = server.begin(THREAD1);
+        tc.incrementPartcipatingSourceCount("S1");
+        tc.incrementPartcipatingSourceCount("S2");
+        
+        server.commit(THREAD1);
+        
+        Mockito.verify(xaTerminator).commit(tc.getXid(), false);
+    }     
+    
     public void testLocalRollback() throws Exception {
-        server.begin(THREAD1);
+        TransactionContext tc = server.begin(THREAD1);
+        tc.incrementPartcipatingSourceCount("s1");
         server.rollback(THREAD1);
-
+        Mockito.verify(xaTerminator).rollback(tc.getXid());
+        
         try {
             server.rollback(THREAD1);
         } catch (XATransactionException e) {
@@ -168,46 +214,46 @@
     }
 
     public void testConcurrentEnlistment() throws Exception {
-        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
 
         try {
-            server.start(THREAD1, XID1, XAResource.TMJOIN, 100);
+            server.start(THREAD1, XID1, XAResource.TMJOIN, 100,false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
-            assertEquals("Concurrent enlistment in global transaction MMXid global:1 branch:null format:0 is not supported.", //$NON-NLS-1$
+            assertEquals("Concurrent enlistment in global transaction Teiid-Xid global:1 branch:null format:0 is not supported.", //$NON-NLS-1$
                          ex.getMessage());
         }
     }
 
     public void testSuspend() throws Exception {
-        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
-        server.end(THREAD1, XID1, XAResource.TMSUSPEND);
+        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+        server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
 
         try {
-            server.end(THREAD1, XID1, XAResource.TMSUSPEND);
+            server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
-            assertEquals("Client is not currently enlisted in transaction MMXid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
+            assertEquals("Client is not currently enlisted in transaction Teiid-Xid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
         }
     }
     
     public void testSuspendResume() throws Exception {
-        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
-        server.end(THREAD1, XID1, XAResource.TMSUSPEND);
-        server.start(THREAD1, XID1, XAResource.TMRESUME, 100);
-        server.end(THREAD1, XID1, XAResource.TMSUSPEND);
+        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+        server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
+        server.start(THREAD1, XID1, XAResource.TMRESUME, 100,false);
+        server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
 
         try {
-            server.start(THREAD2, XID1, XAResource.TMRESUME, 100);
+            server.start(THREAD2, XID1, XAResource.TMRESUME, 100,false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
-            assertEquals("Cannot resume, transaction MMXid global:1 branch:null format:0 was not suspended by client 2.", ex.getMessage()); //$NON-NLS-1$
+            assertEquals("Cannot resume, transaction Teiid-Xid global:1 branch:null format:0 was not suspended by client 2.", ex.getMessage()); //$NON-NLS-1$
         }
     }
 
     public void testUnknownFlags() throws Exception {
         try {
-            server.start(THREAD1, XID1, Integer.MAX_VALUE, 100);
+            server.start(THREAD1, XID1, Integer.MAX_VALUE, 100,false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
             assertEquals("Unknown flags", ex.getMessage()); //$NON-NLS-1$
@@ -216,22 +262,22 @@
 
     public void testUnknownGlobalTransaction() throws Exception {
         try {
-            server.end(THREAD1, XID1, XAResource.TMSUCCESS);
+            server.end(THREAD1, XID1, XAResource.TMSUCCESS,false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
-            assertEquals("No global transaction found for MMXid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
+            assertEquals("No global transaction found for Teiid-Xid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
         }
     }
     
     public void testPrepareWithSuspended() throws Exception {
-        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
-        server.end(THREAD1, XID1, XAResource.TMSUSPEND);
+        server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+        server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
 
         try {
-            server.prepare(THREAD1, XID1);
+            server.prepare(THREAD1, XID1,false);
             fail("exception expected"); //$NON-NLS-1$
         } catch (XATransactionException ex) {
-            assertEquals("Suspended work still exists on transaction MMXid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
+            assertEquals("Suspended work still exists on transaction Teiid-Xid global:1 branch:null format:0.", ex.getMessage()); //$NON-NLS-1$
         }
     }
     
@@ -240,7 +286,7 @@
     }
     
     public void testGetTransactions() throws Exception {
-    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
         server.begin(THREAD2);
         
         assertEquals(2, server.getTransactions().size());
@@ -249,7 +295,184 @@
         assertEquals(1, server.getTransactions().size());
         
         Transaction t = server.getTransactions().iterator().next();
-        assertEquals(THREAD1, t.getAssociatedSession());
+        assertEquals(Long.parseLong(THREAD1), t.getAssociatedSession());
         assertNotNull(t.getXid());
     }
+    
+    public void testGlobalPrepare() throws Exception {
+    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+        TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+        server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+        
+    	server.prepare(THREAD1, XID1, false);
+    	
+    	Mockito.verify(xaTerminator).prepare(tc.getXid());
+    	
+    	server.commit(THREAD1, XID1, true, false);
+    }
+    
+    public void testGlobalPrepareFail() throws Exception {
+    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+        server.end(THREAD1, XID1, XAResource.TMFAIL, false);
+        
+    	try {
+			server.prepare(THREAD1, XID1, false);
+			fail("should have failed to prepare as end resulted in TMFAIL");
+		} catch (Exception e) {
+		}
+		
+		server.forget(THREAD1, XID1, false);
+    }    
+    
+    public void testGlobalOnePhaseCommit() throws Exception {
+    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+    	
+    	tc.incrementPartcipatingSourceCount("S1");
+    	
+        server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+        
+        server.prepare(THREAD1, XID1, false);
+
+		
+		server.commit(THREAD1, XID1, true, false);
+		
+		// since there are two sources the commit is not single phase
+		Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+    }  
+    
+    public void testGlobalOnePhaseCommit_force_prepare_through() throws Exception {
+    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+    	
+    	tc.incrementPartcipatingSourceCount("S1");
+    	
+        server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+        
+		
+		server.commit(THREAD1, XID1, true, false);
+		
+		// since there are two sources the commit is not single phase
+		Mockito.verify(xaTerminator, Mockito.times(0)).prepare(tc.getXid());
+		Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+    }  
+    
+    public void testGlobalOnePhaseCommit_force_prepare() throws Exception {
+    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+    	
+    	tc.incrementPartcipatingSourceCount("S1");
+    	tc.incrementPartcipatingSourceCount("S2");
+    	
+        server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+        
+		
+		server.commit(THREAD1, XID1, true, false);
+		
+		// since there are two sources the commit is not single phase
+		Mockito.verify(xaTerminator).prepare(tc.getXid());
+		Mockito.verify(xaTerminator).commit(tc.getXid(), false);
+    }  
+    
+    
+    public void testGlobalOnePhase_teiid_multiple() throws Exception {
+    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+    	
+    	tc.incrementPartcipatingSourceCount("S1");
+    	tc.incrementPartcipatingSourceCount("S2");
+    	
+        server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+        
+        server.prepare(THREAD1, XID1, false);
+
+		
+		server.commit(THREAD1, XID1, true, false);
+		
+		// since there are two sources the commit is not single phase
+		Mockito.verify(xaTerminator).commit(tc.getXid(), false);
+    }    
+    
+    public void testGlobalOnePhaseRoolback() throws Exception {
+    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+    	
+    	tc.incrementPartcipatingSourceCount("S1");
+    	
+        server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+        
+        server.prepare(THREAD1, XID1, false);
+
+		
+		server.rollback(THREAD1, XID1, false);
+		
+		// since there are two sources the commit is not single phase
+		Mockito.verify(xaTerminator).rollback(tc.getXid());
+    }     
+    
+    public void testLocalCommit_rollback() throws Exception {
+        TransactionContext tc = server.begin(THREAD1);
+        tc.incrementPartcipatingSourceCount("s1");
+        tc.setRollbackOnly();
+        server.commit(THREAD1);
+
+        Mockito.verify(xaTerminator).rollback(tc.getXid());
+    }    
+    
+    public void testLocalCommit_not_in_Tx() throws Exception {
+        TransactionContext tc = server.begin(THREAD1);
+        server.commit(THREAD1);
+
+        Mockito.verify(xaTerminator,Mockito.times(0)).commit(tc.getXid(), true);
+    }       
+    
+    public void testRequestCommit() throws Exception{
+    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+    	server.start(tc);
+    	tc.incrementPartcipatingSourceCount("s1");
+    	server.commit(tc);
+    	Mockito.verify(xaTerminator,Mockito.times(0)).prepare(tc.getXid());
+    	Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+    }
+    
+    public void testRequestCommit2() throws Exception{
+    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+    	server.start(tc);
+    	tc.incrementPartcipatingSourceCount("s1");
+    	tc.incrementPartcipatingSourceCount("s2");
+    	server.commit(tc);
+    	
+    	Mockito.verify(xaTerminator).prepare(tc.getXid());
+    	Mockito.verify(xaTerminator).commit(tc.getXid(), false);
+    }    
+    
+    public void testRequestRollback() throws Exception{
+    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+    	server.start(tc);
+    	tc.incrementPartcipatingSourceCount("s1");
+    	tc.incrementPartcipatingSourceCount("s2");
+    	
+    	server.rollback(tc);
+    	Mockito.verify(xaTerminator).rollback(tc.getXid());
+    }     
+    
+    public void testLocalCancel() throws Exception {
+        TransactionContext tc = server.begin(THREAD1);
+        tc.incrementPartcipatingSourceCount("S1");
+        tc.incrementPartcipatingSourceCount("S2");
+        
+        server.cancelTransactions(THREAD1, false);
+        
+        Mockito.verify(xaTerminator).rollback(tc.getXid());
+    }  
+    
+    public void testRequestCancel() throws Exception{
+    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
+    	server.start(tc);
+    	tc.incrementPartcipatingSourceCount("s1");
+    	tc.incrementPartcipatingSourceCount("s2");
+    	
+    	 server.cancelTransactions(THREAD1, true);
+    	Mockito.verify(xaTerminator).rollback(tc.getXid());
+    }      
 }

Modified: trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java	2010-03-05 14:18:19 UTC (rev 1915)
+++ trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java	2010-03-05 14:26:51 UTC (rev 1916)
@@ -31,15 +31,16 @@
 import java.util.Properties;
 
 import org.junit.Test;
-import org.mockito.Mockito;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.connector.metadata.runtime.Datatype;
 import org.teiid.connector.metadata.runtime.MetadataFactory;
+import org.teiid.dqp.internal.process.DQPWorkContext;
 
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
+import com.metamatrix.core.vdb.ModelType;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
 
 public class TestTransformationMetadata {
 
@@ -50,8 +51,18 @@
 		mf.addProcedure("y"); //$NON-NLS-1$
 		MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties()); //$NON-NLS-1$
 		mf1.addProcedure("y"); //$NON-NLS-1$
-		CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()), Mockito.mock(MetadataSource.class));
-		TransformationMetadata tm = new TransformationMetadata(cms);
+		CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()));
+		
+		VDBMetaData vdb = new VDBMetaData();
+		vdb.setName("vdb");
+		vdb.setVersion(1);
+		
+		vdb.addModel(buildModel("x"));
+		vdb.addModel(buildModel("x1"));
+		
+		TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null);
+		DQPWorkContext context = FakeMetadataFactory.buildWorkContext(tm, vdb);
+
 		try {
 			tm.getStoredProcedureInfoForProcedure("y"); //$NON-NLS-1$
 			fail("expected exception"); //$NON-NLS-1$
@@ -60,6 +71,14 @@
 		}
 	}
 	
+	ModelMetaData buildModel(String name) {
+		ModelMetaData model = new ModelMetaData();
+		model.setName(name);
+		model.setModelType(ModelType.getString(ModelType.PHYSICAL));
+		model.setVisible(true);
+		return model;
+	}
+	
 	@Test public void testAmbiguousTableWithPrivateModel() throws Exception {
 		Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
         datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new Datatype());
@@ -67,20 +86,32 @@
 		mf.addTable("y"); //$NON-NLS-1$
 		MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties()); //$NON-NLS-1$
 		mf1.addTable("y"); //$NON-NLS-1$
-		MetadataSource ms = Mockito.mock(MetadataSource.class);
-		Mockito.stub(ms.getName()).toReturn("foo"); //$NON-NLS-1$
-		CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()), ms);
-		TransformationMetadata tm = new TransformationMetadata(cms);
+		CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()));
+		
+		VDBMetaData vdb = new VDBMetaData();
+		vdb.setName("foo");
+		vdb.setVersion(1);
+		
+		ModelMetaData model = new ModelMetaData();
+		model.setName("x1");
+		vdb.addModel(model);
+		
+		ModelMetaData model2 = new ModelMetaData();
+		model2.setName("x");
+		model2.setVisible(true);
+		vdb.addModel(model2);		
+
+		TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null);
 		Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
 		assertEquals(2, result.size());
-		
-		VDBService vdbService = Mockito.mock(VDBService.class);
-		Mockito.stub(vdbService.getModelVisibility("foo", "1", "x1")).toReturn((int)ModelInfo.PRIVATE); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-		Mockito.stub(vdbService.getModelVisibility("foo", "1", "x")).toReturn((int)ModelInfo.PUBLIC); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-		tm = new TransformationMetadata(cms, vdbService, "1"); //$NON-NLS-1$
+
+		FakeMetadataFactory.buildWorkContext(tm, vdb);
+
+		model.setVisible(false);
+
+		tm = new TransformationMetadata(vdb, cms, null, null);
 		result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
 		assertEquals(1, result.size());
-		
 	}
 	
 }



More information about the teiid-commits mailing list