[teiid-commits] teiid SVN: r2361 - in trunk: connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle and 19 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Jul 20 16:42:47 EDT 2010


Author: shawkins
Date: 2010-07-20 16:42:43 -0400 (Tue, 20 Jul 2010)
New Revision: 2361

Added:
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWork.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ProcedureBatchHandler.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/RuntimeMetadataImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/TranslatorRepository.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeConnector.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeProcedureExecution.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeTransactionService.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestAggregateImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestBatchedUpdatesImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestCompareCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestCompoundCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorManager.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestDeleteImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestElementImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExecutionContextImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExistsCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestFunctionImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestGroupByImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestGroupImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInlineViewImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInsertImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestIsNullCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestJoinImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestLikeCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestLiteralImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestMetadataFactory.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestNotCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestOrderByImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestParameterImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestProcedureImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestQueryImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestScalarSubqueryImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSearchedCaseExpressionImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSelectSymbolImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSetQueryImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSubqueryCompareCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSubqueryInCriteriaImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestTypeFacilityImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestUpdateImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TstLanguageBridgeFactory.java
Removed:
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/
   trunk/engine/src/main/java/org/teiid/internal/
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/
   trunk/engine/src/test/java/org/teiid/internal/core/
   trunk/runtime/src/test/java/com/metamatrix/dqp/service/
Modified:
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
   trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
   trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
   trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.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/Request.java
   trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.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/TestDataTierManager.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
   trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java
   trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
   trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
   trunk/runtime/src/main/java/org/teiid/deployers/TranslatorAnnotationScanningDeployer.java
   trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
   trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
   trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
consolidating datamgr package

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -26,13 +26,13 @@
 
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-import org.teiid.dqp.internal.datamgr.language.TestDeleteImpl;
-import org.teiid.dqp.internal.datamgr.language.TestInsertImpl;
-import org.teiid.dqp.internal.datamgr.language.TestProcedureImpl;
-import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
-import org.teiid.dqp.internal.datamgr.language.TestUpdateImpl;
-import org.teiid.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
+import org.teiid.dqp.internal.datamgr.ExecutionContextImpl;
+import org.teiid.dqp.internal.datamgr.TestDeleteImpl;
+import org.teiid.dqp.internal.datamgr.TestInsertImpl;
+import org.teiid.dqp.internal.datamgr.TestProcedureImpl;
+import org.teiid.dqp.internal.datamgr.TestQueryImpl;
+import org.teiid.dqp.internal.datamgr.TestUpdateImpl;
+import org.teiid.dqp.internal.datamgr.TstLanguageBridgeFactory;
 import org.teiid.language.LanguageObject;
 import org.teiid.metadata.RuntimeMetadata;
 import org.teiid.translator.TranslatorException;

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -32,8 +32,8 @@
 import org.teiid.cdk.api.TranslationUtility;
 import org.teiid.core.types.DataTypeManager;
 import org.teiid.core.util.UnitTestUtil;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-import org.teiid.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
+import org.teiid.dqp.internal.datamgr.ExecutionContextImpl;
+import org.teiid.dqp.internal.datamgr.FakeExecutionContextImpl;
 import org.teiid.language.Command;
 import org.teiid.metadata.Column;
 import org.teiid.metadata.CompositeMetadataStore;

Modified: trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -35,7 +35,7 @@
 
 import org.teiid.cdk.CommandBuilder;
 import org.teiid.core.types.DataTypeManager;
-import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl;
 import org.teiid.language.Command;
 import org.teiid.language.Select;
 import org.teiid.metadata.Column;

Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -171,14 +171,18 @@
     }
 
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        rowOffset = in.readInt();
+        //rowOffset = in.readInt();
         terminationFlag = in.readBoolean();
         tuples = BatchSerializer.readBatch(in, types);
     }
     public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(rowOffset);
+        //out.writeInt(rowOffset);
         out.writeBoolean(terminationFlag);
         BatchSerializer.writeBatch(out, types, tuples);
     }
+    
+    public void setRowOffset(int rowOffset) {
+		this.rowOffset = rowOffset;
+	}
 }
 

Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -36,7 +36,6 @@
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.ReentrantLock;
@@ -151,7 +150,7 @@
 
 		@Override
 		public TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException {
-			int reads = readAttempts.incrementAndGet();
+			long reads = readAttempts.incrementAndGet();
 			LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
 			synchronized (activeBatches) {
 				TupleBufferInfo tbi = activeBatches.remove(this.id);
@@ -188,13 +187,14 @@
 						return batch;
 					}
 				}
-				int count = readCount.incrementAndGet();
+				long count = readCount.incrementAndGet();
 				LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, id, beginRow, "reading batch from disk, total reads:", count); //$NON-NLS-1$
 				try {
 		            ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(store.createInputStream(this.offset), IO_BUFFER_SIZE));
 		            batch = new TupleBatch();
 		            batch.setDataTypes(types);
 		            batch.readExternal(ois);
+		            batch.setRowOffset(this.beginRow);
 			        batch.setDataTypes(null);
 			        if (cache) {
 			        	this.activeBatch = batch;
@@ -214,7 +214,7 @@
 				TupleBatch batch = activeBatch;
 				if (batch != null) {
 					if (!persistent) {
-						int count = writeCount.incrementAndGet();
+						long count = writeCount.incrementAndGet();
 						LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, id, beginRow, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
 						synchronized (store) {
 							offset = store.getLength();
@@ -268,11 +268,11 @@
     private StorageManager diskMgr;
 
     private AtomicLong currentTuple = new AtomicLong();
-    private AtomicInteger batchAdded = new AtomicInteger();
-    private AtomicInteger readCount = new AtomicInteger();
-	private AtomicInteger writeCount = new AtomicInteger();
-	private AtomicInteger readAttempts = new AtomicInteger();
-	private AtomicInteger referenceHit = new AtomicInteger();
+    private AtomicLong batchAdded = new AtomicLong();
+    private AtomicLong readCount = new AtomicLong();
+	private AtomicLong writeCount = new AtomicLong();
+	private AtomicLong readAttempts = new AtomicLong();
+	private AtomicLong referenceHit = new AtomicLong();
 	
 	public long getBatchesAdded() {
 		return batchAdded.get();

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -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 org.teiid.dqp.internal.datamgr;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.translator.ExecutionFactory;
+
+
+/**
+ * Utility to convert a ConnectorCapabilities class into a Map of 
+ * capabilities information that can be passed through the system.
+ */
+public class CapabilitiesConverter {
+
+    private CapabilitiesConverter() {
+    }
+
+    public static SourceCapabilities convertCapabilities(ExecutionFactory srcCaps) {
+        return convertCapabilities(srcCaps, null);
+    }
+    
+    public static BasicSourceCapabilities convertCapabilities(ExecutionFactory srcCaps, Object connectorID) {
+        BasicSourceCapabilities tgtCaps = new BasicSourceCapabilities();
+        
+        tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, srcCaps.supportsSelectExpression());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, srcCaps.supportsSelectDistinct());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, srcCaps.supportsAliasedTable());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, srcCaps.supportsInnerJoins());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, srcCaps.supportsSelfJoins());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, srcCaps.supportsOuterJoins());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, srcCaps.supportsFullOuterJoins());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, srcCaps.supportsInlineViews());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, srcCaps.supportsCompareCriteriaEquals());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, srcCaps.supportsCompareCriteriaOrdered());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE, srcCaps.supportsLikeCriteria());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, srcCaps.supportsLikeCriteriaEscapeCharacter());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN, srcCaps.supportsInCriteria());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, srcCaps.supportsInCriteriaSubquery());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_ISNULL, srcCaps.supportsIsNullCriteria());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_OR, srcCaps.supportsOrCriteria());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_NOT, srcCaps.supportsNotCriteria());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_EXISTS, srcCaps.supportsExistsCriteria());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, srcCaps.supportsQuantifiedCompareCriteriaSome());
+        tgtCaps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, srcCaps.supportsQuantifiedCompareCriteriaAll());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY, srcCaps.supportsOrderBy());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, srcCaps.supportsAggregatesSum());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, srcCaps.supportsAggregatesAvg());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, srcCaps.supportsAggregatesMin());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, srcCaps.supportsAggregatesMax());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, srcCaps.supportsAggregatesCount());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, srcCaps.supportsAggregatesCountStar());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, srcCaps.supportsAggregatesDistinct());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, srcCaps.supportsScalarSubqueries());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, srcCaps.supportsCorrelatedSubqueries());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_CASE, srcCaps.supportsCaseExpressions());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, srcCaps.supportsSearchedCaseExpressions());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_UNION, srcCaps.supportsUnions());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_INTERSECT, srcCaps.supportsIntersect());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_EXCEPT, srcCaps.supportsExcept());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, srcCaps.supportsSetQueryOrderBy());
+        tgtCaps.setCapabilitySupport(Capability.BULK_UPDATE , srcCaps.supportsBulkUpdate());
+        tgtCaps.setCapabilitySupport(Capability.BATCHED_UPDATES, srcCaps.supportsBatchedUpdates());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, srcCaps.supportsFunctionsInGroupBy());
+        tgtCaps.setCapabilitySupport(Capability.ROW_LIMIT, srcCaps.supportsRowLimit());
+        tgtCaps.setCapabilitySupport(Capability.ROW_OFFSET, srcCaps.supportsRowOffset());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, srcCaps.useAnsiJoin());
+        tgtCaps.setCapabilitySupport(Capability.REQUIRES_CRITERIA, srcCaps.requiresCriteria());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_GROUP_BY, srcCaps.supportsGroupBy());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_HAVING, srcCaps.supportsHaving());
+        tgtCaps.setCapabilitySupport(Capability.INSERT_WITH_QUERYEXPRESSION, srcCaps.supportsInsertWithQueryExpression());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY_UNRELATED, srcCaps.supportsOrderByUnrelated());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_ENHANCED_NUMERIC, srcCaps.supportsAggregatesEnhancedNumeric());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, srcCaps.supportsOrderByNullOrdering());
+        
+        List functions = srcCaps.getSupportedFunctions();
+        if(functions != null && functions.size() > 0) {
+            Iterator iter = functions.iterator();
+            while(iter.hasNext()) {
+                String func = (String) iter.next();
+                tgtCaps.setFunctionSupport(func.toLowerCase(), true);
+            }
+        }
+        
+        tgtCaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(srcCaps.getMaxInCriteriaSize()));
+        tgtCaps.setSourceProperty(Capability.CONNECTOR_ID, connectorID);
+        tgtCaps.setSourceProperty(Capability.MAX_QUERY_FROM_GROUPS, new Integer(srcCaps.getMaxFromGroups()));
+        tgtCaps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, srcCaps.getSupportedJoinCriteria());
+        tgtCaps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, srcCaps.getDefaultNullOrder());
+        return tgtCaps;
+    }
+
+}


Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,276 @@
+/*
+ * 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: Aug 25, 2003
+ * Time: 3:53:37 PM
+ */
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.Assertion;
+import org.teiid.dqp.DQPPlugin;
+import org.teiid.dqp.internal.cache.DQPContextCache;
+import org.teiid.dqp.message.AtomicRequestID;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.service.BufferService;
+import org.teiid.logging.CommandLogMessage;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
+import org.teiid.logging.CommandLogMessage.Event;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Scope;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.TranslatorException;
+
+
+/**
+ * The <code>ConnectorManager</code> manages a {@link org.teiid.translator.BasicExecutionFactory Connector}
+ * and its associated workers' state.
+ */
+public class ConnectorManager  {
+	
+	private static final String JAVA_CONTEXT = "java:"; //$NON-NLS-1$
+
+	private String translatorName;
+	private String connectionName;
+	
+    //services acquired in start
+    private BufferService bufferService;
+    
+    // known requests
+    private ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem> requestStates = new ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem>();
+	
+	private SourceCapabilities cachedCapabilities;
+	
+	private volatile boolean stopped;
+	private ExecutionFactory<Object, Object> executionFactory;
+	
+    public ConnectorManager(String translatorName, String connectionName) {
+    	this.translatorName = translatorName;
+    	this.connectionName = connectionName;
+    }
+    
+    public String getStausMessage() {
+    	StringBuilder sb = new StringBuilder();
+    	ExecutionFactory<Object, Object> ef = getExecutionFactory();
+		
+    	if(ef != null) {
+    		if (ef.isSourceRequired()) {
+    			Object conn = getConnectionFactory();
+    			if (conn == null) {
+    				sb.append(DQPPlugin.Util.getString("datasource_not_found", this.connectionName)); //$NON-NLS-1$
+    			}
+    		}
+    	}
+    	else {
+    		sb.append(DQPPlugin.Util.getString("translator_not_found", this.translatorName)); //$NON-NLS-1$
+    	}
+    	return sb.toString();
+    }
+    
+    public MetadataStore getMetadata(String modelName, Map<String, Datatype> datatypes, Properties importProperties) throws TranslatorException {
+		MetadataFactory factory = new MetadataFactory(modelName, datatypes, importProperties);
+		Object connectionFactory = getConnectionFactory();
+		Object connection = executionFactory.getConnection(connectionFactory);
+		try {
+			executionFactory.getMetadata(factory, connection);
+		} finally {
+			executionFactory.closeConnection(connection, connectionFactory);
+		}
+		return factory.getMetadataStore();
+	}    
+    
+    public SourceCapabilities getCapabilities() throws TeiidComponentException {
+    	if (cachedCapabilities != null) {
+    		return cachedCapabilities;
+    	}
+
+		checkStatus();
+		ExecutionFactory<Object, Object> translator = getExecutionFactory();
+		BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(translator, Arrays.asList(translatorName, connectionName));
+		resultCaps.setScope(Scope.SCOPE_GLOBAL);
+		cachedCapabilities = resultCaps;
+		return resultCaps;
+    }
+    
+    public ConnectorWork registerRequest(AtomicRequestMessage message) throws TeiidComponentException {
+        // 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 = new ConnectorWorkItem(message, this);
+        Assertion.isNull(requestStates.put(atomicRequestId, item), "State already existed"); //$NON-NLS-1$
+        return item;
+    }
+    
+    ConnectorWork getState(AtomicRequestID requestId) {
+        return requestStates.get(requestId);
+    }
+    
+    /**
+     * Remove the state associated with
+     * the given <code>RequestID</code>.
+     */
+    void removeState(AtomicRequestID id) {
+    	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {id, "Remove State"}); //$NON-NLS-1$
+        ConnectorWorkItem cwi = requestStates.remove(id);
+    }
+
+    int size() {
+        return requestStates.size();
+    }
+    
+    public void setBufferService(BufferService service) {
+    	this.bufferService = service;
+    }
+    
+    /**
+     * initialize this <code>ConnectorManager</code>.
+     * @throws TranslatorException 
+     */
+    public void start() {
+        LogManager.logDetail(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorManagerImpl.Initializing_connector", translatorName)); //$NON-NLS-1$
+    }
+    
+    /**
+     * Stop this connector.
+     */
+    public void stop() {    
+    	stopped = true;
+        //ensure that all requests receive a response
+        for (ConnectorWork workItem : this.requestStates.values()) {
+    		workItem.cancel();
+		}
+    }
+
+    /**
+     * Add begin point to transaction monitoring table.
+     * @param qr Request that contains the MetaMatrix command information in the transaction.
+     */
+    void logSRCCommand(AtomicRequestMessage qr, ExecutionContext context, Event cmdStatus, Integer finalRowCnt) {
+    	if (!LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.DETAIL)) {
+    		return;
+    	}
+        String sqlStr = null;
+        if(cmdStatus == Event.NEW){
+        	Command cmd = qr.getCommand();
+            sqlStr = cmd != null ? cmd.toString() : null;
+        }
+        String userName = qr.getWorkContext().getUserName();
+        String transactionID = null;
+        if ( qr.isTransactional() ) {
+            transactionID = qr.getTransactionContext().getTransactionId();
+        }
+        
+        String modelName = qr.getModelName();
+        AtomicRequestID id = qr.getAtomicRequestID();
+        
+        String principal = userName == null ? "unknown" : userName; //$NON-NLS-1$
+        
+        CommandLogMessage message = null;
+        if (cmdStatus == Event.NEW) {
+            message = new CommandLogMessage(System.currentTimeMillis(), qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, translatorName, qr.getWorkContext().getSessionId(), principal, sqlStr, context);
+        } 
+        else {
+            message = new CommandLogMessage(System.currentTimeMillis(), qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, translatorName, qr.getWorkContext().getSessionId(), principal, finalRowCnt, cmdStatus, context);
+        }         
+        LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_COMMANDLOGGING, message);
+    }
+    
+    /**
+     * Get the <code>Translator</code> object managed by this  manager.
+     * @return the <code>ExecutionFactory</code>.
+     */
+	protected ExecutionFactory<Object, Object> getExecutionFactory() {
+		return this.executionFactory;
+    }
+    
+	public void setExecutionFactory(ExecutionFactory<Object, Object> ef) {
+		this.executionFactory = ef;
+	}
+    
+    
+    /**
+     * Get the ConnectionFactory object required by this manager
+     * @return
+     */
+    protected Object getConnectionFactory() {
+    	if (this.connectionName != null) {
+    		String jndiName = this.connectionName;
+    		if (!this.connectionName.startsWith(JAVA_CONTEXT)) {
+    			jndiName = JAVA_CONTEXT + jndiName;
+    		}
+
+			try {
+				InitialContext ic = new InitialContext();    		
+				try {
+					return ic.lookup(jndiName);
+				} catch (NamingException e) {
+					if (!jndiName.equals(this.connectionName)) {
+						return ic.lookup(this.connectionName);
+					}
+				}
+			} catch (NamingException e) {
+			}    		
+    	}
+    	return null;
+    }
+    
+    
+    DQPContextCache getContextCache() {
+     	if (bufferService != null) {
+    		return bufferService.getContextCache();
+    	}
+    	return null;
+    }
+    
+    private void checkStatus() throws TeiidComponentException {
+    	if (stopped) {
+    		throw new TeiidComponentException(DQPPlugin.Util.getString("ConnectorManager.not_in_valid_state", this.translatorName)); //$NON-NLS-1$
+    	}
+    }
+    
+    public String getTranslatorName() {
+    	return this.translatorName;
+    }
+    
+    public String getConnectionName() {
+    	return this.connectionName;
+    }
+}

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+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 List<ConnectorManager> getConnectorManagers() {
+		return new ArrayList<ConnectorManager>(this.repo.values());
+	}
+	
+	
+	public ConnectorManager removeConnectorManager(String connectorName) {
+		return this.repo.remove(connectorName);
+	}
+}

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWork.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWork.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWork.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.translator.TranslatorException;
+
+
+/**
+ * Represents a connector execution in batched form.
+ */
+public interface ConnectorWork {
+
+	void cancel();
+
+	AtomicResultsMessage more() throws TranslatorException, BlockedException;
+
+	void close();
+
+	AtomicResultsMessage execute() throws TranslatorException, BlockedException;
+	
+}
\ No newline at end of file


Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWork.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,402 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.TransformationException;
+import org.teiid.core.util.Assertion;
+import org.teiid.dqp.DQPPlugin;
+import org.teiid.dqp.message.AtomicRequestID;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.language.Call;
+import org.teiid.language.QueryExpression;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.CommandLogMessage.Event;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.Execution;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.UpdateExecution;
+
+
+public class ConnectorWorkItem implements ConnectorWork {
+	
+	/* Permanent state members */
+	private AtomicRequestID id;
+    private ConnectorManager manager;
+    private AtomicRequestMessage requestMsg;
+    private ExecutionFactory connector;
+    private QueryMetadataInterface queryMetadata;
+    
+    /* Created on new request */
+    private Object connection;
+    private Object connectionFactory;
+    private ExecutionContextImpl securityContext;
+    private volatile ResultSetExecution execution;
+    private ProcedureBatchHandler procedureBatchHandler;
+    private org.teiid.language.Command translatedCommand;
+    private Class<?>[] schema;
+    private List<Integer> convertToRuntimeType;
+    private boolean[] convertToDesiredRuntimeType;
+        
+    /* End state information */    
+    private boolean lastBatch;
+    private int rowCount;
+    private boolean error;
+    
+    private AtomicBoolean isCancelled = new AtomicBoolean();
+    
+    ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager) {
+        this.id = message.getAtomicRequestID();
+        this.requestMsg = message;
+        this.manager = manager;
+        AtomicRequestID requestID = this.requestMsg.getAtomicRequestID();
+        this.securityContext = new ExecutionContextImpl(requestMsg.getWorkContext().getVdbName(),
+                requestMsg.getWorkContext().getVdbVersion(),                
+                requestMsg.getExecutionPayload(),                                                                       
+                requestMsg.getWorkContext().getSessionId(),                                                                      
+                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.getExecutionFactory();
+    	VDBMetaData vdb = requestMsg.getWorkContext().getVDB();
+    	this.queryMetadata = vdb.getAttachment(QueryMetadataInterface.class);
+        this.queryMetadata = new TempMetadataAdapter(this.queryMetadata, new TempMetadataStore());
+		this.securityContext.setTransactional(requestMsg.isTransactional());
+    }
+    
+    public AtomicRequestID getId() {
+		return id;
+	}
+    
+    public void cancel() {
+    	try {
+            LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing CANCEL request"}); //$NON-NLS-1$
+            if (this.isCancelled.compareAndSet(false, true)) {
+                this.manager.logSRCCommand(this.requestMsg, this.securityContext, Event.CANCEL, -1);
+    	        if(execution != null) {
+    	            execution.cancel();
+    	        }            
+    	        LogManager.logDetail(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("DQPCore.The_atomic_request_has_been_cancelled", this.id)); //$NON-NLS-1$
+        	}
+        } catch (TranslatorException e) {
+            LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, DQPPlugin.Util.getString("Cancel_request_failed", this.id)); //$NON-NLS-1$
+        }
+    }
+    
+    public AtomicResultsMessage more() throws TranslatorException {
+    	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing MORE request"}); //$NON-NLS-1$
+    	try {
+    		return handleBatch();
+    	} catch (Throwable t) {
+    		throw handleError(t);
+    	}
+    }
+    
+    public void close() {
+    	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing Close :", this.requestMsg.getCommand()}); //$NON-NLS-1$
+    	if (!error) {
+            manager.logSRCCommand(this.requestMsg, this.securityContext, Event.END, this.rowCount);
+        }
+        try {
+	        if (execution != null) {
+	            execution.close();
+	            LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed execution"}); //$NON-NLS-1$                    
+	        }	        
+        } catch (Throwable e) {
+            LogManager.logError(LogConstants.CTX_CONNECTOR, e, e.getMessage());
+        } finally {
+        	try {
+        		this.connector.closeConnection(connection, connectionFactory);
+        	} catch (Throwable e) {
+        		LogManager.logError(LogConstants.CTX_CONNECTOR, e, e.getMessage());
+        	} finally {
+        		manager.removeState(this.id);
+        	}
+		    LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed connection"}); //$NON-NLS-1$
+        } 
+    }
+    
+    private TranslatorException handleError(Throwable t) {
+    	if (t instanceof DataNotAvailableException) {
+    		throw (DataNotAvailableException)t;
+    	}
+    	error = true;
+    	if (t instanceof RuntimeException && t.getCause() != null) {
+    		t = t.getCause();
+    	}
+        manager.logSRCCommand(this.requestMsg, this.securityContext, Event.ERROR, null);
+        
+        String msg = DQPPlugin.Util.getString("ConnectorWorker.process_failed", this.id); //$NON-NLS-1$
+        if (isCancelled.get()) {            
+            LogManager.logDetail(LogConstants.CTX_CONNECTOR, msg);
+        } else if (t instanceof TranslatorException || t instanceof TeiidProcessingException) {
+        	LogManager.logWarning(LogConstants.CTX_CONNECTOR, t, msg);
+        } else {
+            LogManager.logError(LogConstants.CTX_CONNECTOR, t, msg);
+        } 
+		if (t instanceof TranslatorException) {
+			return (TranslatorException)t;
+		}
+		if (t instanceof RuntimeException) {
+			throw (RuntimeException)t;
+		}
+		return new TranslatorException(t);
+    }
+    
+	public AtomicResultsMessage execute() throws TranslatorException, BlockedException {
+        if(isCancelled()) {
+    		throw new TranslatorException("Request canceled"); //$NON-NLS-1$
+    	}
+        
+    	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Processing NEW request:", this.requestMsg.getCommand()}); //$NON-NLS-1$                                     
+    	try {
+	    	this.connectionFactory = this.manager.getConnectionFactory();
+	        this.connection = this.connector.getConnection(this.connectionFactory);
+	        // Translate the command
+	        Command command = this.requestMsg.getCommand();
+			List<SingleElementSymbol> symbols = this.requestMsg.getCommand().getProjectedSymbols();
+			this.schema = new Class[symbols.size()];
+			this.convertToDesiredRuntimeType = new boolean[symbols.size()];
+			this.convertToRuntimeType = new ArrayList<Integer>(symbols.size());
+			for (int i = 0; i < schema.length; i++) {
+				SingleElementSymbol symbol = symbols.get(i);
+				this.schema[i] = symbol.getType();
+				this.convertToDesiredRuntimeType[i] = true;
+				this.convertToRuntimeType.add(i);
+			}
+	
+	        LanguageBridgeFactory factory = new LanguageBridgeFactory(queryMetadata);
+	        this.translatedCommand = factory.translate(command);
+	
+	        RuntimeMetadata rmd = new RuntimeMetadataImpl(queryMetadata);
+	        
+	        // Create the execution based on mode
+	        final Execution exec = connector.createExecution(this.translatedCommand, this.securityContext, rmd, this.connection);
+	        if (this.translatedCommand instanceof Call) {
+	        	Assertion.isInstanceOf(this.execution, ProcedureExecution.class, "Call Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
+	        	this.execution = (ProcedureExecution)exec;
+	        	StoredProcedure proc = (StoredProcedure)command;
+	        	if (proc.returnParameters()) {
+	        		this.procedureBatchHandler = new ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)this.execution);
+	        	}
+	        } else if (this.translatedCommand instanceof QueryExpression){
+	        	Assertion.isInstanceOf(this.execution, ResultSetExecution.class, "QueryExpression Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
+	        	this.execution = (ResultSetExecution)exec;
+	        } else {
+	        	Assertion.isInstanceOf(this.execution, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions"); //$NON-NLS-1$
+	        	this.execution = new ResultSetExecution() {
+	        		private int[] results;
+	        		private int index;
+	        		
+	        		@Override
+	        		public void cancel() throws TranslatorException {
+	        			exec.cancel();
+	        		}
+	        		@Override
+	        		public void close() {
+	        			exec.close();
+	        		}
+	        		@Override
+	        		public void execute() throws TranslatorException {
+	        			exec.execute();
+	        		}
+	        		@Override
+	        		public List<?> next() throws TranslatorException,
+	        				DataNotAvailableException {
+	        			if (results == null) {
+	        				results = ((UpdateExecution)exec).getUpdateCounts();
+	        			}
+	        			if (index < results.length) {
+	        				return Arrays.asList(results[index++]);
+	        			}
+	        			return null;
+	        		}
+	        	};
+	        }
+	        LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Obtained execution"}); //$NON-NLS-1$      
+	        //Log the Source Command (Must be after obtaining the execution context)
+	        manager.logSRCCommand(this.requestMsg, this.securityContext, Event.NEW, null); 
+	        
+	        // Execute query
+	    	this.execution.execute();
+	        LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Executed command"}); //$NON-NLS-1$
+	
+	        return handleBatch();
+    	} catch (Throwable t) {
+    		throw handleError(t);
+    	}
+	}
+    
+    protected AtomicResultsMessage handleBatch() throws TranslatorException {
+    	Assertion.assertTrue(!this.lastBatch);
+        LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Sending results from connector"}); //$NON-NLS-1$
+        int batchSize = 0;
+        List<List> rows = new ArrayList<List>(batchSize/4);
+        
+        try {
+	        while (batchSize < this.requestMsg.getFetchSize()) {
+	        	
+        		List row = this.execution.next();
+            	if (row == null) {
+            		this.lastBatch = true;
+            		break;
+            	}
+            	
+            	this.rowCount += 1;
+            	batchSize++;
+            	if (this.procedureBatchHandler != null) {
+            		row = this.procedureBatchHandler.padRow(row);
+            	}
+            	
+            	correctTypes(row);
+            	rows.add(row);
+	            // Check for max result rows exceeded
+	            if(this.requestMsg.getMaxResultRows() > -1 && this.rowCount >= this.requestMsg.getMaxResultRows()){
+	                if (this.rowCount == this.requestMsg.getMaxResultRows() && !this.requestMsg.isExceptionOnMaxRows()) {
+		                LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Exceeded max, returning", this.requestMsg.getMaxResultRows()}); //$NON-NLS-1$
+		        		this.lastBatch = true;
+		        		break;
+	            	} else if (this.rowCount > this.requestMsg.getMaxResultRows() && this.requestMsg.isExceptionOnMaxRows()) {
+	                    String msg = DQPPlugin.Util.getString("ConnectorWorker.MaxResultRowsExceed", this.requestMsg.getMaxResultRows()); //$NON-NLS-1$
+	                    throw new TranslatorException(msg);
+	                }
+	            }
+	        }
+    	} catch (DataNotAvailableException e) {
+    		if (rows.size() == 0) {
+    			throw e;
+    		}
+    	}
+                
+        if (lastBatch) {
+        	if (this.procedureBatchHandler != null) {
+        		List row = this.procedureBatchHandler.getParameterRow();
+        		if (row != null) {
+        			correctTypes(row);
+        			rows.add(row);
+        			this.rowCount++;
+        		}
+        	}
+            LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Obtained last batch, total row count:", rowCount}); //$NON-NLS-1$\
+        }   
+        
+    	int currentRowCount = rows.size();
+		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.getConnectorName())); //$NON-NLS-1$
+		}
+
+		AtomicResultsMessage response = createResultsMessage(rows.toArray(new List[currentRowCount]), requestMsg.getCommand().getProjectedSymbols());
+		
+		// if we need to keep the execution alive, then we can not support implicit close.
+		response.setSupportsImplicitClose(!this.securityContext.keepExecutionAlive());
+		response.setTransactional(this.securityContext.isTransactional());
+		response.setWarnings(this.securityContext.getWarnings());
+
+		if ( lastBatch ) {
+		    response.setFinalRow(rowCount);
+		} 
+		return response;
+	}
+
+	private void correctTypes(List row) throws TranslatorException {
+		//TODO: add a proper source schema
+		for (int i = convertToRuntimeType.size() - 1; i >= 0; i--) {
+			int index = convertToRuntimeType.get(i);
+			Object value = row.get(index);
+			if (value != null) {
+				Object result = DataTypeManager.convertToRuntimeType(value);
+				if (DataTypeManager.isLOB(result.getClass())) {
+					this.securityContext.keepExecutionAlive(true);
+				}
+				if (value == result && !DataTypeManager.DefaultDataClasses.OBJECT.equals(this.schema[index])) {
+					convertToRuntimeType.remove(i);
+				}
+				row.set(index, result);
+			}
+		}
+		//TODO: add a proper intermediate schema
+		for (int i = 0; i < row.size(); i++) {
+			if (convertToDesiredRuntimeType[i]) {
+				Object value = row.get(i);
+				if (value != null) {
+					Object result;
+					try {
+						result = DataTypeManager.transformValue(value, value.getClass(), this.schema[i]);
+					} catch (TransformationException e) {
+						throw new TranslatorException(e);
+					}
+					if (value == result) {
+						convertToDesiredRuntimeType[i] = false;
+					}
+					row.set(i, result);
+				}
+			} else {
+				row.set(i, DataTypeManager.getCanonicalValue(row.get(i)));
+			}
+		}
+	}
+    
+    public static AtomicResultsMessage createResultsMessage(List[] batch, List columnSymbols) {
+        String[] dataTypes = TupleBuffer.getTypeNames(columnSymbols);        
+        return new AtomicResultsMessage(batch, dataTypes);
+    }    
+            
+    boolean isCancelled() {
+    	return this.isCancelled.get();
+    }
+
+	@Override
+	public String toString() {
+		return this.id.toString();
+	}
+
+}
\ No newline at end of file

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -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 org.teiid.dqp.internal.datamgr;
+
+import java.io.Serializable;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.teiid.cache.Cache;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.dqp.DQPPlugin;
+import org.teiid.dqp.internal.cache.DQPContextCache;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.translator.CacheScope;
+import org.teiid.translator.ExecutionContext;
+
+
+/**
+ */
+public class ExecutionContextImpl implements ExecutionContext {
+
+    // Orginal request non-atomic request id
+    private String requestID;   
+    //  Access Node ID
+    private String partID;
+    // currentConnector ID
+    private String connectorName;    
+    // current VDB 
+    private String vdbName;
+    // Current VDB's version
+    private int vdbVersion;
+    // User Name
+    private Subject user;
+    // Payload setup on the Statement object
+    private Serializable executionPayload;
+    // ID of the parent JDBC Connection which is executing the statement
+    private String requestConnectionID;
+    // Execute count of the query
+    private String executeCount;
+    // keep the execution object alive during the processing. default:false 
+    private boolean keepAlive = false;
+    
+    private boolean isTransactional;
+    private DQPContextCache contextCache;
+    
+    private int batchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
+	private List<Exception> warnings = new LinkedList<Exception>();
+    
+    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.executionPayload = executionPayload;
+        this.connectorName = connectorName;
+        this.requestID = requestId;
+        this.partID = partId;        
+        this.requestConnectionID = originalConnectionID;
+        this.executeCount = execCount;
+    }
+    
+    public String getConnectorIdentifier() {
+        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;
+    }
+    @Override
+    public int getVirtualDatabaseVersion() {
+        return this.vdbVersion;
+    }
+    @Override
+    public Subject getSubject() {
+        return this.user;
+    }
+    
+    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;
+    }    
+    
+    boolean keepExecutionAlive() {
+        return this.keepAlive;
+    }
+    	
+    public boolean equals(Object obj) {
+        if(obj == this) {
+            return true;
+        } 
+        if(! (obj instanceof ExecutionContext)) {
+            return false;
+        } 
+        ExecutionContext other = (ExecutionContext) obj;
+        return compareWithNull(this.getRequestIdentifier(), other.getRequestIdentifier()) && 
+                compareWithNull(this.getPartIdentifier(), other.getPartIdentifier());
+    }
+
+    private boolean compareWithNull(Object obj1, Object obj2) {
+        if(obj1 == null) { 
+            if(obj2 == null) {
+                return true;
+            }
+            return false;
+        }
+        if(obj2 == null) {
+            return false;
+        }
+        return obj1.equals(obj2);
+    }
+
+    public int hashCode() {
+        return HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, requestID), partID);
+    }
+
+    public String toString() {
+    	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;
+	}
+
+	void setTransactional(boolean isTransactional) {
+		this.isTransactional = isTransactional;
+	}
+		
+	@Override
+	public int getBatchSize() {
+		return batchSize;
+	}
+	
+	public void setBatchSize(int batchSize) {
+		this.batchSize = batchSize;
+	}
+		
+	/**
+	 * Add an exception as a warning to this Execution.
+	 */
+	@Override
+	public void addWarning(Exception ex) {
+		if (ex == null) {
+			return;
+		}
+		this.warnings.add(ex);
+	}
+	
+	public List<Exception> getWarnings() {
+		List<Exception> result = new ArrayList<Exception>(warnings);
+		warnings.clear();
+		return result;
+	}
+	
+	public void setContextCache(DQPContextCache cache) {
+		this.contextCache = cache;
+	}
+	
+	@Override
+	public Object get(Object key) {
+		if (this.contextCache != null) {
+			Cache cache = contextCache.getRequestScopedCache(getRequestIdentifier());
+			return cache.get(key);
+		}
+		return null;
+	}
+	
+	@Override
+	public void put(Object key, Object value) {
+		if (this.contextCache != null) {
+			Cache cache = contextCache.getRequestScopedCache(getRequestIdentifier());
+			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$
+			}
+		}
+	}	
+}

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,684 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.AndOr;
+import org.teiid.language.Argument;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Call;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Condition;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.DerivedTable;
+import org.teiid.language.Exists;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.In;
+import org.teiid.language.InsertValueSource;
+import org.teiid.language.IsNull;
+import org.teiid.language.Join;
+import org.teiid.language.Like;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Not;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.SearchedWhenClause;
+import org.teiid.language.Select;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.SubqueryComparison;
+import org.teiid.language.SubqueryIn;
+import org.teiid.language.TableReference;
+import org.teiid.language.Argument.Direction;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.SortSpecification.Ordering;
+import org.teiid.language.SubqueryComparison.Quantifier;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.SetClause;
+import org.teiid.query.sql.lang.SetClauseList;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.translator.TranslatorException;
+
+
+public class LanguageBridgeFactory {
+    private RuntimeMetadataImpl metadataFactory = null;
+
+    public LanguageBridgeFactory(QueryMetadataInterface metadata) {
+        if (metadata != null) {
+            metadataFactory = new RuntimeMetadataImpl(metadata);
+        }
+    }
+
+    public org.teiid.language.Command translate(Command command) {
+        if (command == null) return null;
+        if (command instanceof Query) {
+            return translate((Query)command);
+        } else if (command instanceof SetQuery) {
+            return translate((SetQuery)command);
+        } else if (command instanceof Insert) {
+            return translate((Insert)command);
+        } else if (command instanceof Update) {
+            return translate((Update)command);
+        } else if (command instanceof Delete) {
+            return translate((Delete)command);
+        } else if (command instanceof StoredProcedure) {
+            return translate((StoredProcedure)command);
+        } else if (command instanceof BatchedUpdateCommand) {
+            return translate((BatchedUpdateCommand)command);
+        }
+        throw new AssertionError();
+    }
+    
+    QueryExpression translate(QueryCommand command) {
+    	if (command instanceof Query) {
+            return translate((Query)command);
+        } 
+    	return translate((SetQuery)command);
+    }
+
+    org.teiid.language.SetQuery translate(SetQuery union) {
+        org.teiid.language.SetQuery result = new org.teiid.language.SetQuery();
+        result.setAll(union.isAll());
+        switch (union.getOperation()) {
+            case UNION:
+                result.setOperation(org.teiid.language.SetQuery.Operation.UNION);
+                break;
+            case INTERSECT:
+                result.setOperation(org.teiid.language.SetQuery.Operation.INTERSECT);
+                break;
+            case EXCEPT:
+                result.setOperation(org.teiid.language.SetQuery.Operation.EXCEPT);
+                break;
+        }
+        result.setLeftQuery(translate(union.getLeftQuery()));
+        result.setRightQuery(translate(union.getRightQuery()));
+        result.setOrderBy(translate(union.getOrderBy()));
+        result.setLimit(translate(union.getLimit()));
+        return result;
+    }
+
+    /* Query */
+    Select translate(Query query) {
+        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();
+            String alias = null;
+            if(symbol instanceof AliasSymbol) {
+                alias = symbol.getOutputName();
+                symbol = ((AliasSymbol)symbol).getSymbol();
+            }
+
+            org.teiid.language.Expression iExp = null;
+            if(symbol instanceof ElementSymbol) {
+                iExp = translate((ElementSymbol)symbol);
+            } else if(symbol instanceof AggregateSymbol) {
+                iExp = translate((AggregateSymbol)symbol);
+            } else if(symbol instanceof ExpressionSymbol) {
+                iExp = translate(((ExpressionSymbol)symbol).getExpression());
+            }
+
+            DerivedColumn selectSymbol = new DerivedColumn(alias, iExp);
+            translatedSymbols.add(selectSymbol);
+        }
+    	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 TableReference translate(FromClause clause) {
+        if (clause == null) return null;
+        if (clause instanceof JoinPredicate) {
+            return translate((JoinPredicate)clause);
+        } else if (clause instanceof SubqueryFromClause) {
+            return translate((SubqueryFromClause)clause);
+        } else if (clause instanceof UnaryFromClause) {
+            return translate((UnaryFromClause)clause);
+        }
+        throw new AssertionError();
+    }
+
+    Join translate(JoinPredicate join) {
+        List crits = join.getJoinCriteria();
+        Criteria crit = null;
+        if (crits.size() == 1) {
+        	crit = (Criteria)crits.get(0);
+        } else if (crits.size() > 1) {
+        	crit = new CompoundCriteria(crits);        	
+        }
+        
+        Join.JoinType joinType = Join.JoinType.INNER_JOIN;
+        if(join.getJoinType().equals(JoinType.JOIN_INNER)) {
+            joinType = Join.JoinType.INNER_JOIN;
+        } else if(join.getJoinType().equals(JoinType.JOIN_LEFT_OUTER)) {
+            joinType = Join.JoinType.LEFT_OUTER_JOIN;
+        } else if(join.getJoinType().equals(JoinType.JOIN_RIGHT_OUTER)) {
+            joinType = Join.JoinType.RIGHT_OUTER_JOIN;
+        } else if(join.getJoinType().equals(JoinType.JOIN_FULL_OUTER)) {
+            joinType = Join.JoinType.FULL_OUTER_JOIN;
+        } else if(join.getJoinType().equals(JoinType.JOIN_CROSS)) {
+            joinType = Join.JoinType.CROSS_JOIN;
+        }
+        
+        return new Join(translate(join.getLeftClause()),
+                            translate(join.getRightClause()),
+                            joinType,
+                            translate(crit));
+    }
+
+    TableReference translate(SubqueryFromClause clause) {        
+        return new DerivedTable(translate((QueryCommand)clause.getCommand()), clause.getOutputName());
+    }
+
+    NamedTable translate(UnaryFromClause clause) {
+        return translate(clause.getGroup());
+    }
+
+    public Condition translate(Criteria criteria) {
+        if (criteria == null) return null;
+        if (criteria instanceof CompareCriteria) {
+            return translate((CompareCriteria)criteria);
+        } else if (criteria instanceof CompoundCriteria) {
+            return translate((CompoundCriteria)criteria);
+        } else if (criteria instanceof ExistsCriteria) {
+            return translate((ExistsCriteria)criteria);
+        } else if (criteria instanceof IsNullCriteria) {
+            return translate((IsNullCriteria)criteria);
+        }else if (criteria instanceof MatchCriteria) {
+            return translate((MatchCriteria)criteria);
+        } else if (criteria instanceof NotCriteria) {
+            return translate((NotCriteria)criteria);
+        } else if (criteria instanceof SetCriteria) {
+            return translate((SetCriteria)criteria);
+        } else if (criteria instanceof SubqueryCompareCriteria) {
+            return translate((SubqueryCompareCriteria)criteria);
+        } else if (criteria instanceof SubquerySetCriteria) {
+            return translate((SubquerySetCriteria)criteria);
+        }
+        throw new AssertionError();
+    }
+
+    org.teiid.language.Comparison translate(CompareCriteria criteria) {
+        Operator operator = Operator.EQ;
+        switch(criteria.getOperator()) {
+            case CompareCriteria.EQ:    
+                operator = Operator.EQ;
+                break;
+            case CompareCriteria.NE:    
+                operator = Operator.NE;
+                break;
+            case CompareCriteria.LT:    
+                operator = Operator.LT;
+                break;
+            case CompareCriteria.LE:    
+                operator = Operator.LE;
+                break;
+            case CompareCriteria.GT:    
+                operator = Operator.GT;
+                break;
+            case CompareCriteria.GE:    
+                operator = Operator.GE;
+                break;
+            
+        }
+        
+        return new org.teiid.language.Comparison(translate(criteria.getLeftExpression()),
+                                        translate(criteria.getRightExpression()), operator);
+    }
+
+    AndOr translate(CompoundCriteria criteria) {
+        List nestedCriteria = criteria.getCriteria();
+        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 result;
+    }
+
+    Exists translate(ExistsCriteria criteria) {
+        return new Exists(translate((QueryCommand)criteria.getCommand()));
+    }
+
+    IsNull translate(IsNullCriteria criteria) {
+        return new IsNull(translate(criteria.getExpression()), criteria.isNegated());
+    }
+
+    Like translate(MatchCriteria criteria) {
+        Character escapeChar = null;
+        if(criteria.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) {
+            escapeChar = new Character(criteria.getEscapeChar());
+        }
+        return new Like(translate(criteria.getLeftExpression()),
+                                    translate(criteria.getRightExpression()), 
+                                    escapeChar, 
+                                    criteria.isNegated());
+    }
+
+    In translate(SetCriteria criteria) {
+        List expressions = criteria.getValues();
+        List translatedExpressions = new ArrayList();
+        for (Iterator i = expressions.iterator(); i.hasNext();) {
+            translatedExpressions.add(translate((Expression)i.next()));
+        }
+        return new In(translate(criteria.getExpression()),
+                                  translatedExpressions, 
+                                  criteria.isNegated());
+    }
+
+    SubqueryComparison translate(SubqueryCompareCriteria criteria) {
+        Quantifier quantifier = Quantifier.ALL;
+        switch(criteria.getPredicateQuantifier()) {
+            case SubqueryCompareCriteria.ALL:   
+                quantifier = Quantifier.ALL;
+                break;
+            case SubqueryCompareCriteria.ANY:
+                quantifier = Quantifier.SOME;
+                break;
+            case SubqueryCompareCriteria.SOME:
+                quantifier = Quantifier.SOME;
+                break;
+        }
+        
+        Operator operator = Operator.EQ;
+        switch(criteria.getOperator()) {
+            case SubqueryCompareCriteria.EQ:
+                operator = Operator.EQ;
+                break;
+            case SubqueryCompareCriteria.NE:
+                operator = Operator.NE;
+                break;
+            case SubqueryCompareCriteria.LT:
+                operator = Operator.LT;
+                break;
+            case SubqueryCompareCriteria.LE:
+                operator = Operator.LE;
+                break;
+            case SubqueryCompareCriteria.GT:
+                operator = Operator.GT;
+                break;
+            case SubqueryCompareCriteria.GE:
+                operator = Operator.GE;
+                break;                    
+        }
+                
+        return new SubqueryComparison(translate(criteria.getLeftExpression()),
+                                  operator,
+                                  quantifier,
+                                  translate((QueryCommand)criteria.getCommand()));
+    }
+
+    SubqueryIn translate(SubquerySetCriteria criteria) {
+        return new SubqueryIn(translate(criteria.getExpression()),
+                                  criteria.isNegated(),
+                                  translate((QueryCommand)criteria.getCommand()));
+    }
+
+    Not translate(NotCriteria criteria) {
+        return new Not(translate(criteria.getCriteria()));
+    }
+
+    public org.teiid.language.GroupBy translate(GroupBy groupBy) {
+        if(groupBy == null){
+            return null;
+        }
+        List items = groupBy.getSymbols();
+        List<org.teiid.language.Expression> translatedItems = new ArrayList<org.teiid.language.Expression>();
+        for (Iterator i = items.iterator(); i.hasNext();) {
+            translatedItems.add(translate((Expression)i.next()));
+        }
+        return new org.teiid.language.GroupBy(translatedItems);
+    }
+
+    public org.teiid.language.OrderBy translate(OrderBy orderBy) {
+        if(orderBy == null){
+            return null;
+        }
+        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 SortSpecification(direction, translate(symbol));                                
+            }
+            orderByItem.setNullOrdering(items.get(i).getNullOrdering());
+            translatedItems.add(orderByItem);
+        }
+        return new org.teiid.language.OrderBy(translatedItems);
+    }
+
+
+    /* Expressions */
+    public org.teiid.language.Expression translate(Expression expr) {
+        if (expr == null) return null;
+        if (expr instanceof Constant) {
+            return translate((Constant)expr);
+        } else if (expr instanceof Function) {
+            return translate((Function)expr);
+        } else if (expr instanceof ScalarSubquery) {
+            return translate((ScalarSubquery)expr);
+        } else if (expr instanceof SearchedCaseExpression) {
+            return translate((SearchedCaseExpression)expr);
+        } else if (expr instanceof SingleElementSymbol) {
+            return translate((SingleElementSymbol)expr);
+        } else if (expr instanceof Criteria) {
+        	return translate((Criteria)expr);
+        }
+        throw new AssertionError();
+    }
+
+    Literal translate(Constant constant) {
+        Literal result = new Literal(constant.getValue(), constant.getType());
+        result.setBindValue(constant.isMultiValued());
+        result.setMultiValued(constant.isMultiValued());
+        return result;
+    }
+
+    org.teiid.language.Function translate(Function function) {
+        Expression [] args = function.getArgs();
+        List<org.teiid.language.Expression> params = new ArrayList<org.teiid.language.Expression>(args.length);
+        if (args != null) {
+            for (int i = 0; i < args.length; i++) {
+                params.add(translate(args[i]));
+            }
+        }
+        return new org.teiid.language.Function(function.getName(), params, function.getType());
+    }
+
+    SearchedCase translate(SearchedCaseExpression expr) {
+        ArrayList<SearchedWhenClause> whens = new ArrayList<SearchedWhenClause>();
+        for (int i = 0; i < expr.getWhenCount(); i++) {
+        	whens.add(new SearchedWhenClause(translate(expr.getWhenCriteria(i)), translate(expr.getThenExpression(i))));
+        }
+        return new SearchedCase(whens,
+                                      translate(expr.getElseExpression()),
+                                      expr.getType());
+    }
+
+
+    org.teiid.language.Expression translate(ScalarSubquery ss) {
+        return new org.teiid.language.ScalarSubquery(translate((QueryCommand)ss.getCommand()));
+    }
+
+    org.teiid.language.Expression translate(SingleElementSymbol symbol) {
+        if (symbol == null) return null;
+        if (symbol instanceof ElementSymbol) {
+            return translate((ElementSymbol)symbol);
+        } else if (symbol instanceof AggregateSymbol) {
+            return translate((AggregateSymbol)symbol);
+        } else if (symbol instanceof ExpressionSymbol) {
+            return translate((ExpressionSymbol)symbol);
+        }
+        throw new AssertionError();
+    }
+
+    org.teiid.language.Expression translate(AliasSymbol symbol) {
+        return translate(symbol.getSymbol());
+    }
+
+    ColumnReference translate(ElementSymbol symbol) {
+        ColumnReference element = new ColumnReference(translate(symbol.getGroupSymbol()), symbol.getOutputName(), null, symbol.getType());
+        if (element.getTable().getMetadataObject() == null) {
+            return element;
+        }
+
+        Object mid = symbol.getMetadataID();
+        
+        if(! (mid instanceof TempMetadataID)) { 
+            element.setMetadataObject(metadataFactory.getElement(mid));
+        }
+        return element;
+    }
+
+    AggregateFunction translate(AggregateSymbol symbol) {
+        return new AggregateFunction(symbol.getAggregateFunction().name(), 
+                                symbol.isDistinct(), 
+                                translate(symbol.getExpression()),
+                                symbol.getType());
+    }
+
+    org.teiid.language.Expression translate(ExpressionSymbol symbol) {
+        return translate(symbol.getExpression());
+    }
+
+
+    /* Insert */
+    org.teiid.language.Insert translate(Insert insert) {
+        List elements = insert.getVariables();
+        List<ColumnReference> translatedElements = new ArrayList<ColumnReference>();
+        for (Iterator i = elements.iterator(); i.hasNext();) {
+            translatedElements.add(translate((ElementSymbol)i.next()));
+        }
+        
+        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<org.teiid.language.Expression> translatedValues = new ArrayList<org.teiid.language.Expression>();
+            for (Iterator i = values.iterator(); i.hasNext();) {
+                translatedValues.add(translate((Expression)i.next()));
+            }
+            valueSource = new ExpressionValueSource(translatedValues);
+        }
+        
+        return new org.teiid.language.Insert(translate(insert.getGroup()),
+                              translatedElements,
+                              valueSource);
+    }
+
+    /* Update */
+    org.teiid.language.Update translate(Update update) {
+        return new org.teiid.language.Update(translate(update.getGroup()),
+                              translate(update.getChangeList()),
+                              translate(update.getCriteria()));
+    }
+    
+    List<org.teiid.language.SetClause> translate(SetClauseList setClauseList) {
+    	List<org.teiid.language.SetClause> clauses = new ArrayList<org.teiid.language.SetClause>(setClauseList.getClauses().size());
+    	for (SetClause setClause : setClauseList.getClauses()) {
+    		clauses.add(translate(setClause));
+    	}
+    	return clauses;
+    }
+    
+    org.teiid.language.SetClause translate(SetClause setClause) {
+    	return new org.teiid.language.SetClause(translate(setClause.getSymbol()), translate(setClause.getValue()));
+    }
+
+    /* Delete */
+    org.teiid.language.Delete translate(Delete delete) {
+        org.teiid.language.Delete deleteImpl = new org.teiid.language.Delete(translate(delete.getGroup()),
+                              translate(delete.getCriteria()));
+        return deleteImpl;
+    }
+
+    /* Execute */
+    Call translate(StoredProcedure sp) {
+        Procedure proc = null;
+        if(sp.getProcedureID() != null) {
+            try {
+				proc = this.metadataFactory.getProcedure(sp.getGroup().getName());
+			} catch (TranslatorException e) {
+				throw new TeiidRuntimeException(e);
+			}
+        }
+        Class<?> returnType = null;
+        List parameters = sp.getParameters();
+        List<Argument> translatedParameters = new ArrayList<Argument>();
+        for (Iterator i = parameters.iterator(); i.hasNext();) {
+        	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);
+        }
+                        
+        Call call = new Call(removeSchemaName(sp.getProcedureName()), translatedParameters, proc);
+        call.setReturnType(returnType);
+        return call;
+    }
+
+    public NamedTable translate(GroupSymbol symbol) {
+    	String alias = null;
+        String fullGroup = symbol.getOutputName();
+        if(symbol.getOutputDefinition() != null) {
+            alias = symbol.getOutputName();
+            fullGroup = symbol.getOutputDefinition();
+        }
+        fullGroup = removeSchemaName(fullGroup);
+        NamedTable group = new NamedTable(fullGroup, alias, null);
+		if (symbol.getMetadataID() instanceof TempMetadataID) {
+			return group;
+		}
+        try {
+			group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID()));
+		} catch (QueryMetadataException e) {
+			throw new TeiidRuntimeException(e);
+		} catch (TeiidComponentException e) {
+			throw new TeiidRuntimeException(e);
+		}
+        return group;
+    }
+
+	private String removeSchemaName(String fullGroup) {
+		//remove the model name
+        int index = fullGroup.indexOf(ElementSymbol.SEPARATOR);
+        if (index > 0) {
+        	fullGroup = fullGroup.substring(index + 1);
+        }
+		return fullGroup;
+	}
+    
+    /* Batched Updates */
+    BatchedUpdates translate(BatchedUpdateCommand command) {
+        List updates = command.getUpdateCommands();
+        List<org.teiid.language.Command> translatedUpdates = new ArrayList<org.teiid.language.Command>(updates.size());
+        for (Iterator i = updates.iterator(); i.hasNext();) {
+            translatedUpdates.add(translate((Command)i.next()));
+        }
+        return new BatchedUpdates(translatedUpdates);
+    }
+
+    org.teiid.language.Limit translate(Limit limit) {
+        if (limit == null) {
+            return null;
+        }
+        int rowOffset = 0;
+        if (limit.getOffset() != null) {
+            Literal c1 = (Literal)translate(limit.getOffset());
+            rowOffset = ((Integer)c1.getValue()).intValue();
+        }
+        Literal c2 = (Literal)translate(limit.getRowLimit());
+        int rowLimit = ((Integer)c2.getValue()).intValue();
+        return new org.teiid.language.Limit(rowOffset, rowLimit);
+    }
+}

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ProcedureBatchHandler.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ProcedureBatchHandler.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ProcedureBatchHandler.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+/**
+ * 
+ */
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.teiid.dqp.DQPPlugin;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Argument.Direction;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.ProcedureExecution;
+
+
+class ProcedureBatchHandler {
+	private Call proc;
+	private ProcedureExecution procExec;
+	private int paramCols = 0;
+	private int resultSetCols = 0;
+	private List filler;
+    
+	public ProcedureBatchHandler(Call proc, ProcedureExecution procExec) {
+		this.proc = proc;
+		this.procExec = procExec;
+        List<Argument> params = proc.getArguments();
+        resultSetCols = proc.getResultSetColumnTypes().length;
+        if (proc.getReturnType() != null) {
+        	paramCols++;
+        }
+        if(params != null && !params.isEmpty()){
+        	for (Argument param : params) {
+                if(param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
+                    paramCols += 1;
+                }
+            }
+        }
+        if (paramCols > 0) {
+        	filler = Collections.nCopies(paramCols, null);
+        }
+	}
+	
+	List padRow(List row) throws TranslatorException {
+        if (row.size() != resultSetCols) {
+            throw new TranslatorException(DQPPlugin.Util.getString("ConnectorWorker.ConnectorWorker_result_set_unexpected_columns", new Object[] {proc, new Integer(resultSetCols), new Integer(row.size())})); //$NON-NLS-1$
+        }
+        if (paramCols == 0) {
+        	return row;
+        }
+        List result = new ArrayList(resultSetCols + paramCols);
+        result.addAll(row);
+        result.addAll(filler);
+        return result;
+	}
+	
+	List getParameterRow() throws TranslatorException {
+		if (paramCols == 0) {
+			return null;
+		}
+        List<Object> result = new ArrayList<Object>(Arrays.asList(new Object[resultSetCols]));
+        result.addAll(procExec.getOutputParameterValues());
+        return result;
+	}
+	
+}


Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ProcedureBatchHandler.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/RuntimeMetadataImpl.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/RuntimeMetadataImpl.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/RuntimeMetadataImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+/*
+ */
+package org.teiid.dqp.internal.datamgr;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.metadata.*;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.StoredProcedureInfo;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.translator.TranslatorException;
+
+
+/**
+ */
+public class RuntimeMetadataImpl implements RuntimeMetadata {
+    private QueryMetadataInterface metadata;
+    
+    public RuntimeMetadataImpl(QueryMetadataInterface metadata){
+    	ArgCheck.isNotNull(metadata);
+        this.metadata = metadata;
+    }
+    
+    @Override
+    public Column getColumn(String fullName) throws TranslatorException {
+		try {
+			Object metadataId = metadata.getElementID(fullName);
+			return getElement(metadataId);
+		} catch (QueryMetadataException e) {
+			throw new TranslatorException(e);
+		} catch (TeiidComponentException e) {
+			throw new TranslatorException(e);
+		}
+    }
+    
+    public Column getElement(Object elementId) {
+    	if (elementId instanceof Column) {
+    		return (Column)elementId;
+    	}
+    	return null;
+    }
+    
+    @Override
+    public Table getTable(String fullName) throws TranslatorException {
+		try {
+			Object groupId = metadata.getGroupID(fullName);
+	    	return getGroup(groupId);
+		} catch (QueryMetadataException e) {
+			throw new TranslatorException(e);
+		} catch (TeiidComponentException e) {
+			throw new TranslatorException(e);
+		}
+    }
+
+	public Table getGroup(Object groupId) throws QueryMetadataException, TeiidComponentException {
+		if (!metadata.isVirtualGroup(groupId) && groupId instanceof Table) {
+			return (Table)groupId;
+		}
+		return null;
+	}    
+    
+    @Override
+    public Procedure getProcedure(String fullName) throws TranslatorException {
+		try {
+			StoredProcedureInfo sp = metadata.getStoredProcedureInfoForProcedure(fullName);
+	    	return getProcedure(sp);
+		} catch (QueryMetadataException e) {
+			throw new TranslatorException(e);
+		} catch (TeiidComponentException e) {
+			throw new TranslatorException(e);
+		}
+    }
+
+	public Procedure getProcedure(StoredProcedureInfo sp) {
+		if (sp.getProcedureID() instanceof Procedure) {
+			return (Procedure)sp.getProcedureID();
+		}
+		return null;
+	}
+	
+	public ProcedureParameter getParameter(SPParameter param) {
+		if (param.getMetadataID() instanceof ProcedureParameter) {
+			return (ProcedureParameter)param.getMetadataID();
+		}
+		return null;
+	}
+    
+    public byte[] getBinaryVDBResource(String resourcePath) throws TranslatorException {
+        try {
+            return metadata.getBinaryVDBResource(resourcePath);
+        } catch (QueryMetadataException e) {
+            throw new TranslatorException(e);
+        } catch (TeiidComponentException e) {
+            throw new TranslatorException(e);
+        }
+    }
+
+    public String getCharacterVDBResource(String resourcePath) throws TranslatorException {
+        try {
+            return metadata.getCharacterVDBResource(resourcePath);
+        } catch (QueryMetadataException e) {
+            throw new TranslatorException(e);
+        } catch (TeiidComponentException e) {
+            throw new TranslatorException(e);
+        }
+    }
+
+    public String[] getVDBResourcePaths() throws TranslatorException {
+        try {
+            return metadata.getVDBResourcePaths();
+        } catch (QueryMetadataException e) {
+            throw new TranslatorException(e);
+        } catch (TeiidComponentException e) {
+            throw new TranslatorException(e);
+        }
+    }
+    
+    public QueryMetadataInterface getMetadata() {
+    	return metadata;
+    }
+    
+}

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/TranslatorRepository.java (from rev 2352, trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TranslatorRepository.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/TranslatorRepository.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/TranslatorRepository.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -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 org.teiid.dqp.internal.datamgr;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.impl.TranslatorMetaData;
+import org.teiid.adminapi.impl.VDBTranslatorMetaData;
+import org.teiid.vdb.runtime.VDBKey;
+
+
+public class TranslatorRepository implements Serializable{
+	
+	private static final long serialVersionUID = -1212280886010974273L;
+	private Map<String, TranslatorMetaData> translatorRepo = new ConcurrentHashMap<String, TranslatorMetaData>();
+	private Map<VDBKey, Map<String, VDBTranslatorMetaData>> vdbScopedTranslatorRepo = new ConcurrentHashMap<VDBKey, Map<String, VDBTranslatorMetaData>>();
+
+	public void addTranslatorMetadata(String name, TranslatorMetaData factory) {
+		this.translatorRepo.put(name, factory);
+	}
+	
+	public void addTranslatorMetadata(VDBKey key, String name, VDBTranslatorMetaData factory) {
+		Map<String, VDBTranslatorMetaData> repo = vdbScopedTranslatorRepo.get(key);
+		if (repo == null) {
+			repo = new ConcurrentHashMap<String, VDBTranslatorMetaData>();
+			this.vdbScopedTranslatorRepo.put(key, repo);
+		}
+		repo.put(name, factory);
+	}	
+	
+	public Translator getTranslatorMetaData(VDBKey key, String name) {
+		Translator factory = null;
+
+		if (key != null) {
+			Map<String, VDBTranslatorMetaData> repo = vdbScopedTranslatorRepo.get(key);
+			if (repo != null && !repo.isEmpty()) {
+				factory = repo.get(name); 	
+			}
+		}
+		
+		if (factory == null) {
+			factory = this.translatorRepo.get(name);
+		}
+		
+		return factory;
+	}
+	
+	public TranslatorMetaData removeTranslatorMetadata(String name) {
+		return this.translatorRepo.remove(name);
+	}	
+	
+	public void removeVDBTranslators(VDBKey name) {
+		this.vdbScopedTranslatorRepo.remove(name);
+	}
+}
\ No newline at end of file


Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/TranslatorRepository.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: 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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -31,8 +31,8 @@
 import org.teiid.core.TeiidComponentException;
 import org.teiid.core.TeiidRuntimeException;
 import org.teiid.dqp.DQPPlugin;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
 import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
 import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
 import org.teiid.query.optimizer.capabilities.SourceCapabilities;

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -59,7 +59,7 @@
 import org.teiid.core.types.Streamable;
 import org.teiid.dqp.DQPPlugin;
 import org.teiid.dqp.internal.cache.DQPContextCache;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
 import org.teiid.dqp.internal.process.ThreadReuseExecutor.PrioritizedRunnable;
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.dqp.message.RequestID;

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -50,9 +50,9 @@
 import org.teiid.core.types.XMLType;
 import org.teiid.core.util.Assertion;
 import org.teiid.dqp.DQPPlugin;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.ConnectorWork;
 import org.teiid.dqp.internal.process.CodeTableCache.CacheKey;
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.dqp.message.RequestID;

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -35,7 +35,7 @@
 import org.teiid.core.TeiidProcessingException;
 import org.teiid.core.TeiidRuntimeException;
 import org.teiid.core.util.Assertion;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
+import org.teiid.dqp.internal.datamgr.ConnectorWork;
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.dqp.message.AtomicResultsMessage;
 import org.teiid.translator.DataNotAvailableException;

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -45,7 +45,7 @@
 import org.teiid.core.types.DataTypeManager;
 import org.teiid.core.util.Assertion;
 import org.teiid.dqp.DQPPlugin;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.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;

Modified: trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -28,7 +28,7 @@
 
 import org.teiid.core.TeiidException;
 import org.teiid.core.TeiidRuntimeException;
-import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
+import org.teiid.dqp.internal.datamgr.LanguageBridgeFactory;
 import org.teiid.language.LanguageFactory;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.optimizer.relational.AliasGenerator;

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeConnector.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeConnector.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeConnector.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.Execution;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.UpdateExecution;
+
+public class FakeConnector extends ExecutionFactory {
+	private static final int RESULT_SIZE = 5;
+	
+	private boolean executeBlocks;
+    private boolean nextBatchBlocks;
+    private boolean returnsFinalBatch;
+    private boolean driverThrowsExceptionOnCancel;
+    private long simulatedBatchRetrievalTime = 1000L;
+    private ClassLoader classloader;
+    
+    private int connectionCount;
+    private int executionCount;
+    
+    public int getConnectionCount() {
+		return connectionCount;
+	}
+    
+    public int getExecutionCount() {
+		return executionCount;
+	}
+    
+    @Override
+    public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws TranslatorException {
+    	executionCount++;
+        return new FakeBlockingExecution(executionContext);
+    }
+    
+    public Object getConnection() {
+        return new FakeConnection();
+    }
+    
+    @Override
+    public Object getConnection(Object factory) throws TranslatorException {
+    	return factory;
+    }
+    
+    @Override
+    public void closeConnection(Object connection, Object factory) {
+    }
+	
+    private class FakeConnection {
+    	public FakeConnection() {
+			connectionCount++;
+		}
+    	
+        public boolean released = false;
+        public void close() {
+            Assert.assertFalse("The connection should not be released more than once", released); //$NON-NLS-1$
+            released = true;
+        }
+    }   
+    
+    private final class FakeBlockingExecution implements ResultSetExecution, UpdateExecution {
+        private boolean closed = false;
+        private boolean cancelled = false;
+        private int rowCount;
+        ExecutionContext ec;
+        public FakeBlockingExecution(ExecutionContext ec) {
+            this.ec = ec;
+        }
+        public void execute(QueryExpression query, int maxBatchSize) throws TranslatorException {
+            if (executeBlocks) {
+                waitForCancel();
+            }
+            if (classloader != null) {
+            	Assert.assertSame(classloader, Thread.currentThread().getContextClassLoader());
+            }
+        }
+        public synchronized void cancel() throws TranslatorException {
+            cancelled = true;
+            this.notify();
+        }
+        public void close() {
+            Assert.assertFalse("The execution should not be closed more than once", closed); //$NON-NLS-1$
+            closed = true;
+        }
+        @Override
+        public void execute() throws TranslatorException {
+            ec.addWarning(new Exception("Some warning")); //$NON-NLS-1$
+        }
+        @Override
+        public List next() throws TranslatorException, DataNotAvailableException {
+        	if (nextBatchBlocks) {
+                waitForCancel();
+            }
+            if (this.rowCount >= RESULT_SIZE || returnsFinalBatch) {
+            	return null;
+            }
+            this.rowCount++;
+            return Arrays.asList(this.rowCount - 1);
+        }
+        private synchronized void waitForCancel() throws TranslatorException {
+            try {
+                this.wait(simulatedBatchRetrievalTime);
+                if (cancelled && driverThrowsExceptionOnCancel) {
+                    throw new TranslatorException("Request cancelled"); //$NON-NLS-1$
+                }
+            } catch (InterruptedException e) {
+                throw new RuntimeException(e);
+            }
+        }
+		@Override
+		public int[] getUpdateCounts() throws DataNotAvailableException,
+				TranslatorException {
+			return new int[] {1};
+		}
+    }
+
+	public boolean isExecuteBlocks() {
+		return executeBlocks;
+	}
+	public void setExecuteBlocks(boolean executeBlocks) {
+		this.executeBlocks = executeBlocks;
+	}
+	public boolean isNextBatchBlocks() {
+		return nextBatchBlocks;
+	}
+	public void setNextBatchBlocks(boolean nextBatchBlocks) {
+		this.nextBatchBlocks = nextBatchBlocks;
+	}
+	public boolean isReturnsFinalBatch() {
+		return returnsFinalBatch;
+	}
+	public void setReturnsFinalBatch(boolean returnsFinalBatch) {
+		this.returnsFinalBatch = returnsFinalBatch;
+	}
+	public boolean isDriverThrowsExceptionOnCancel() {
+		return driverThrowsExceptionOnCancel;
+	}
+	public void setDriverThrowsExceptionOnCancel(
+			boolean driverThrowsExceptionOnCancel) {
+		this.driverThrowsExceptionOnCancel = driverThrowsExceptionOnCancel;
+	}
+	public long getSimulatedBatchRetrievalTime() {
+		return simulatedBatchRetrievalTime;
+	}
+	public void setSimulatedBatchRetrievalTime(long simulatedBatchRetrievalTime) {
+		this.simulatedBatchRetrievalTime = simulatedBatchRetrievalTime;
+	}
+	
+	public void setClassloader(ClassLoader classloader) {
+		this.classloader = classloader;
+	}
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.teiid.dqp.internal.datamgr.ExecutionContextImpl;
+import org.teiid.translator.ExecutionContext;
+
+/**
+ */
+public class FakeExecutionContextImpl extends ExecutionContextImpl {
+
+	private final static AtomicInteger COUNT = new AtomicInteger(0);
+
+	public FakeExecutionContextImpl() {
+		this(COUNT.getAndIncrement());
+	}
+
+	public FakeExecutionContextImpl(int unique) {
+		super("VDB" + unique, //$NON-NLS-1$
+				unique, 
+				"ExecutionPayload" + unique, //$NON-NLS-1$            
+				"ConnectionID" + unique, //$NON-NLS-1$
+				"ConnectorID" + unique, //$NON-NLS-1$
+				"RequestID" + unique, //$NON-NLS-1$
+				"PartID" + unique, //$NON-NLS-1$
+				"ExecCount" + unique); //$NON-NLS-1$
+	}
+
+	public FakeExecutionContextImpl(ExecutionContext c) {
+		super(c.getVirtualDatabaseName(), c.getVirtualDatabaseVersion(), c.getExecutionPayload(), c
+				.getConnectionIdentifier(), c.getConnectorIdentifier(), c
+				.getRequestIdentifier(), c.getPartIdentifier(), c
+				.getExecutionCountIdentifier());
+	}
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeProcedureExecution.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeProcedureExecution.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeProcedureExecution.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ProcedureExecution;
+
+
+final class FakeProcedureExecution implements ProcedureExecution {
+
+    int resultSetSize;
+    int rowNum;
+    int paramSize;
+
+    public FakeProcedureExecution(int resultSetSize, int paramSize) {
+        this.resultSetSize = resultSetSize;
+        this.paramSize = paramSize;
+    }
+    
+    @Override
+    public void execute() throws TranslatorException {
+    	
+    }
+    
+    @Override
+    public List<?> getOutputParameterValues() throws TranslatorException {
+    	List<Object> result = new ArrayList<Object>(paramSize);
+    	for (int i = 0; i < paramSize; i++) {
+    		result.add(i);
+    	}
+    	return result;
+    }
+    
+    public void close() {
+    }
+
+    public void cancel() throws TranslatorException {
+    }
+    
+    @Override
+    public List next() throws TranslatorException, DataNotAvailableException {
+    	if (rowNum == 1) {
+    		return null;
+    	}
+    	rowNum++;
+    	return Arrays.asList(new Object[resultSetSize]);
+    }
+
+}
\ No newline at end of file

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeTransactionService.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeTransactionService.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeTransactionService.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -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.datamgr;
+
+import javax.resource.spi.XATerminator;
+import javax.transaction.TransactionManager;
+
+import org.teiid.common.queue.FakeWorkManager;
+import org.teiid.core.util.SimpleMock;
+import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+
+
+public class FakeTransactionService extends TransactionServerImpl {
+
+	public FakeTransactionService() {
+		this.setTransactionManager(SimpleMock.createSimpleMock(TransactionManager.class));
+		this.setXaTerminator(SimpleMock.createSimpleMock(XATerminator.class));
+		this.setWorkManager(new FakeWorkManager());
+	}
+	
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestAggregateImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestAggregateImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestAggregateImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import junit.framework.TestCase;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.Literal;
+import org.teiid.language.SQLConstants.NonReserved;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
+
+
+public class TestAggregateImpl extends TestCase {
+
+    /**
+     * Constructor for TestAggregateImpl.
+     * @param name
+     */
+    public TestAggregateImpl(String name) {
+        super(name);
+    }
+
+    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 TstLanguageBridgeFactory.factory.translate(symbol);
+        
+    }
+
+    public void testGetName() throws Exception {
+        assertEquals(AggregateFunction.COUNT, example("testName", NonReserved.COUNT, true, 42).getName()); //$NON-NLS-1$ 
+    }
+
+    public void testIsDistinct() throws Exception {
+        assertTrue(example("testName", NonReserved.COUNT, true, 42).isDistinct()); //$NON-NLS-1$
+        assertFalse(example("testName", NonReserved.COUNT, false, 42).isDistinct()); //$NON-NLS-1$
+    }
+
+    public void testGetExpression() throws Exception {
+        AggregateFunction agg = example("testName", NonReserved.COUNT, true, 42); //$NON-NLS-1$
+        assertNotNull(agg.getExpression());
+        assertTrue(agg.getExpression() instanceof Literal);
+        assertEquals(new Integer(42), ((Literal)agg.getExpression()).getValue());
+    }
+
+    public void testGetType() throws Exception {
+        assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, example("x", NonReserved.COUNT, true, 42).getType()); //$NON-NLS-1$
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestBatchedUpdatesImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestBatchedUpdatesImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestBatchedUpdatesImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Delete;
+import org.teiid.language.Insert;
+import org.teiid.language.Update;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+
+import junit.framework.TestCase;
+
+
+
+/** 
+ * @since 4.2
+ */
+public class TestBatchedUpdatesImpl extends TestCase {
+
+    public TestBatchedUpdatesImpl(String name) {
+        super(name);
+    }
+
+    public static BatchedUpdateCommand helpExample() {
+        List updates = new ArrayList();
+        updates.add(TestInsertImpl.helpExample("a.b")); //$NON-NLS-1$
+        updates.add(TestUpdateImpl.helpExample());
+        updates.add(TestDeleteImpl.helpExample());
+        return new BatchedUpdateCommand(updates);
+    }
+    
+    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 Insert);
+        assertTrue(updates.get(1) instanceof Update);
+        assertTrue(updates.get(2) instanceof Delete);
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestCompareCriteriaImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestCompareCriteriaImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestCompareCriteriaImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Comparison;
+import org.teiid.language.Literal;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.query.sql.lang.AbstractCompareCriteria;
+import org.teiid.query.sql.symbol.Constant;
+
+
+public class TestCompareCriteriaImpl extends TestCase {
+
+    /**
+     * Constructor for TestCompareCriteriaImpl.
+     * @param name
+     */
+    public TestCompareCriteriaImpl(String name) {
+        super(name);
+    }
+
+    public static org.teiid.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 org.teiid.query.sql.lang.CompareCriteria(left, operator, right);
+    }
+    
+    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 {
+        Comparison impl = example(AbstractCompareCriteria.GE, 200, 100);
+        assertNotNull(impl.getLeftExpression());
+        assertTrue(impl.getLeftExpression() instanceof Literal);
+        assertEquals(new Integer(200), ((Literal)impl.getLeftExpression()).getValue());
+    }
+
+    public void testGetRightExpression() throws Exception {
+        Comparison impl = example(AbstractCompareCriteria.GE, 200, 100);
+        assertNotNull(impl.getRightExpression());
+        assertTrue(impl.getRightExpression() instanceof Literal);
+        assertEquals(new Integer(100), ((Literal)impl.getRightExpression()).getValue());
+    }
+
+    public void testGetOperator() throws Exception {
+        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());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestCompoundCriteriaImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestCompoundCriteriaImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestCompoundCriteriaImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.AndOr;
+import org.teiid.language.Comparison;
+import org.teiid.language.AndOr.Operator;
+import org.teiid.query.sql.lang.CompareCriteria;
+
+
+public class TestCompoundCriteriaImpl extends TestCase {
+
+    /**
+     * Constructor for TestCompoundCriteriaImpl.
+     * @param name
+     */
+    public TestCompoundCriteriaImpl(String name) {
+        super(name);
+    }
+
+    public static org.teiid.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 org.teiid.query.sql.lang.CompoundCriteria(operator, c1, c2);
+    }
+    
+    public static AndOr example(int operator) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(operator));
+    }
+
+    public void testGetOperator() throws Exception {
+        assertEquals(Operator.AND, example(org.teiid.query.sql.lang.CompoundCriteria.AND).getOperator());
+        assertEquals(Operator.OR, example(org.teiid.query.sql.lang.CompoundCriteria.OR).getOperator());
+    }
+
+    public void testGetCriteria() throws Exception {
+        AndOr cc = example(org.teiid.query.sql.lang.CompoundCriteria.AND);
+        assertTrue(cc.getLeftCondition() instanceof Comparison);
+        assertTrue(cc.getRightCondition() instanceof Comparison);
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorManager.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorManager.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorManager.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,108 @@
+/*
+ * 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 17, 2003
+ * Time: 3:48:54 PM
+ */
+package org.teiid.dqp.internal.datamgr;
+
+import junit.framework.TestCase;
+
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorWork;
+import org.teiid.dqp.message.AtomicRequestID;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.translator.ExecutionFactory;
+
+
+/**
+ * JUnit test for TestConnectorStateManager
+ */
+public final class TestConnectorManager extends TestCase {
+    private AtomicRequestMessage request;
+    private ConnectorManager csm;
+    
+	static ConnectorManager getConnectorManager() throws Exception {
+		final FakeConnector c = new FakeConnector();
+		ConnectorManager cm = new ConnectorManager("FakeConnector","FakeConnector") { //$NON-NLS-1$ //$NON-NLS-2$
+			protected ExecutionFactory getExecutionFactory() {
+				return c;
+			}
+			protected Object getConnectionFactory(){
+				return c.getConnection();
+			}
+		};
+		cm.start();
+		return cm;
+	}
+
+    /**
+     * Constructor for TestConnectorStateManager.
+     * @param name
+     */
+    public TestConnectorManager(final String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
+        csm = getConnectorManager();
+    }
+
+    void helpAssureOneState() throws Exception {
+    	csm.registerRequest(request);
+    	ConnectorWork state = csm.getState(request.getAtomicRequestID());
+    	assertEquals(state, csm.getState(request.getAtomicRequestID()));
+    }
+
+    public void testCreateAndAddRequestState() throws Exception {
+        helpAssureOneState();
+        assertEquals("Expected size of 1", 1, csm.size()); //$NON-NLS-1$
+    }
+
+    public void testIllegalCreate() throws Exception {
+        helpAssureOneState();
+        try {
+        	helpAssureOneState();
+        	fail("expected exception"); //$NON-NLS-1$
+        } catch (AssertionError e) {
+        	assertEquals("State already existed", e.getMessage()); //$NON-NLS-1$
+        }
+    }
+
+    public void testRemoveRequestState() throws Exception {
+        helpAssureOneState();
+        csm.removeState(request.getAtomicRequestID());
+        assertEquals("Expected size of 0", 0, csm.size()); //$NON-NLS-1$
+    }
+
+    public void testRemoveUnknownRequestState() throws Exception {
+        helpAssureOneState();
+        csm.removeState(new AtomicRequestID(new RequestID("ZZZZ", 3210), 5, 5)); //$NON-NLS-1$
+
+        assertEquals("Expected size of 1", 1, csm.size()); //$NON-NLS-1$
+    }
+           
+}
\ No newline at end of file

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import static junit.framework.Assert.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.transaction.xa.Xid;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.client.RequestMessage;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorWorkItem;
+import org.teiid.dqp.internal.datamgr.LanguageBridgeFactory;
+import org.teiid.dqp.internal.datamgr.ProcedureBatchHandler;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.language.Call;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+
+
+public class TestConnectorWorkItem {
+
+	private static final QueryMetadataInterface EXAMPLE_BQT = FakeMetadataFactory.exampleBQTCached();
+
+	private static Command helpGetCommand(String sql,
+			QueryMetadataInterface metadata) throws Exception {
+		Command command = QueryParser.getQueryParser().parseCommand(sql);
+		QueryResolver.resolveCommand(command, metadata);
+		return command;
+	}
+
+	static AtomicRequestMessage createNewAtomicRequestMessage(int requestid, int nodeid) throws Exception {
+		RequestMessage rm = new RequestMessage();
+		
+		DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(EXAMPLE_BQT, FakeMetadataFactory.exampleBQTVDB());
+		workContext.getSession().setSessionId(String.valueOf(1));
+		workContext.getSession().setUserName("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.setConnectorName("testing"); //$NON-NLS-1$
+		request.setFetchSize(5);
+		return request;
+	}
+
+	@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));
+		Call proc = (Call)new LanguageBridgeFactory(EXAMPLE_BQT).translate(command);
+
+		ProcedureBatchHandler pbh = new ProcedureBatchHandler(proc, exec);
+
+		assertEquals(total_columns, pbh.padRow(Arrays.asList(null, null)).size());
+
+		List params = pbh.getParameterRow();
+		
+		assertEquals(total_columns, params.size());
+		// check the parameter value
+		assertEquals(Integer.valueOf(0), params.get(2));
+
+		try {
+			pbh.padRow(Arrays.asList(1));
+			fail("Expected exception from resultset mismatch"); //$NON-NLS-1$
+		} catch (TranslatorException 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$
+		}
+	}
+
+    @Test public void testUpdateExecution() throws Throwable {
+		AtomicResultsMessage results = helpExecuteUpdate();
+		assertEquals(Integer.valueOf(1), results.getResults()[0].get(0));
+	}
+
+	private AtomicResultsMessage helpExecuteUpdate() throws Exception,
+			Throwable {
+		Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
+		AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
+		arm.setCommand(command);
+		ConnectorWorkItem synchConnectorWorkItem = new ConnectorWorkItem(arm, TestConnectorManager.getConnectorManager());
+		return synchConnectorWorkItem.execute();
+	}
+	
+	@Test public void testExecutionWarning() throws Throwable {
+		AtomicResultsMessage results = helpExecuteUpdate();
+		assertEquals(1, results.getWarnings().size());
+	}
+
+	@Ignore    
+	@Test public void testIsImmutablePropertySucceeds() throws Exception {
+    	/*
+    	 * Setup:
+    	 *  1. requestMsg.isTransactional() must be TRUE 
+    	 *  2. manager.isXa() must be FALSE  ()
+    	 *  3. command must NOT be a SELECT
+    	 *  4. Then, set isImmutable to TRUE, we should SUCCEED
+    	 */
+		ConnectorManager cm = TestConnectorManager.getConnectorManager();
+		((FakeConnector)cm.getExecutionFactory()).setImmutable(true);
+		
+
+		// 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);
+		requestMsg.setCommand(command);
+		
+		// To make the AtomicRequestMessage transactional, construct your own
+		requestMsg.setTransactionContext( new TransactionContext(){
+			@Override
+			public Xid getXid() {
+				return Mockito.mock(Xid.class);
+			}} );
+		
+		new ConnectorWorkItem(requestMsg, cm);
+    }
+    
+	@Ignore
+	@Test(expected=TranslatorException.class) public void testIsImmutablePropertyFails() throws Exception {
+    	/*
+    	 * Setup:
+    	 *  1. requestMsg.isTransactional() must be TRUE 
+    	 *  2. manager.isXa() must be FALSE  ()
+    	 *  3. command must NOT be a SELECT
+    	 *  4. Then, set isImmutable to FALSE, and we should FAIL
+    	 */
+		ConnectorManager cm = TestConnectorManager.getConnectorManager();
+		((FakeConnector)cm.getExecutionFactory()).setImmutable(false);
+		
+        
+		// 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);
+		requestMsg.setCommand(command);
+		
+		// To make the AtomicRequestMessage transactional, construct your own
+		requestMsg.setTransactionContext( new TransactionContext(){
+			@Override
+			public Xid getXid() {
+				return Mockito.mock(Xid.class);
+			}} );
+		
+		new ConnectorWorkItem(requestMsg, cm);
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestDeleteImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestDeleteImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestDeleteImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Delete;
+import org.teiid.query.sql.lang.CompoundCriteria;
+
+
+public class TestDeleteImpl extends TestCase {
+
+    /**
+     * Constructor for TestDeleteImpl.
+     * @param name
+     */
+    public TestDeleteImpl(String name) {
+        super(name);
+    }
+
+    public static org.teiid.query.sql.lang.Delete helpExample() {
+        return new org.teiid.query.sql.lang.Delete(TestGroupImpl.helpExample("vm1.g1"), //$NON-NLS-1$
+                          TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND));
+    }
+    
+    public static Delete example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetGroup() throws Exception {
+        assertNotNull(example().getTable());
+    }
+
+    public void testGetCriteria() throws Exception {
+        assertNotNull(example().getWhere());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestElementImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestElementImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestElementImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.ColumnReference;
+import org.teiid.language.NamedTable;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.unittest.FakeMetadataObject;
+
+
+public class TestElementImpl extends TestCase {
+
+    /**
+     * Constructor for TestElementImpl.
+     * @param name
+     */
+    public TestElementImpl(String name) {
+        super(name);
+    }
+
+    public static ElementSymbol helpExample(String groupName, String elementName) {
+        ElementSymbol symbol = new ElementSymbol(elementName);
+        symbol.setType(String.class);
+        symbol.setGroupSymbol(TestGroupImpl.helpExample(groupName));
+        FakeMetadataObject obj = new FakeMetadataObject(groupName + "." + elementName, FakeMetadataObject.ELEMENT); //$NON-NLS-1$
+        obj.putProperty(FakeMetadataObject.Props.GROUP, new FakeMetadataObject(groupName, FakeMetadataObject.GROUP));
+        obj.putProperty(FakeMetadataObject.Props.LENGTH, "3"); //$NON-NLS-1$
+        symbol.setMetadataID(obj);
+        return symbol;
+        
+    }
+    
+    public static ElementSymbol helpIntExample(String groupName, String elementName) {
+        ElementSymbol symbol = new ElementSymbol(elementName);
+        symbol.setType(Integer.class);
+        symbol.setGroupSymbol(TestGroupImpl.helpExample(groupName));
+        FakeMetadataObject obj = new FakeMetadataObject(groupName + "." + elementName, FakeMetadataObject.ELEMENT); //$NON-NLS-1$
+        obj.putProperty(FakeMetadataObject.Props.GROUP, new FakeMetadataObject(groupName, FakeMetadataObject.GROUP));
+        obj.putProperty(FakeMetadataObject.Props.LENGTH, "3"); //$NON-NLS-1$
+        symbol.setMetadataID(obj);
+        return symbol;
+        
+    }
+    
+    public static ElementSymbol helpExample(String groupName, String elementName, Object metadataID) {
+        ElementSymbol symbol = new ElementSymbol(elementName);
+        symbol.setGroupSymbol(TestGroupImpl.helpExample(groupName));
+        symbol.setType(Integer.class);
+        symbol.setMetadataID(metadataID);
+        return symbol;
+    }
+    
+    public static ColumnReference example(String groupName, String elementName) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, elementName));
+    }
+    
+    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 {
+        Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e1"); //$NON-NLS-1$
+        assertEquals("e1", example("pm1.g1", "e1", metadataID).getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    }
+
+    public void testGetGroup() throws Exception {
+        Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e1"); //$NON-NLS-1$
+        assertNotNull(example("pm1.g1", "e1", metadataID).getTable()); //$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 helpTestEquals(ColumnReference e1, ColumnReference e2, boolean equal) {
+        boolean actual = e1.equals(e2);
+        boolean actual2 = e2.equals(e1);
+        
+        assertEquals("e1.equals(e2) != e2.equals(e1)", actual, actual2); //$NON-NLS-1$
+        assertEquals("Did not get expected equal value", equal, actual); //$NON-NLS-1$
+    }
+    
+    public NamedTable createGroup(String context, String definition) {
+        return new NamedTable(context, definition, null);
+    }
+    
+    public ColumnReference createElement(NamedTable group, String name) {
+        return new ColumnReference(group, name, null, String.class);
+    }
+   
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExecutionContextImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExecutionContextImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExecutionContextImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.dqp.internal.datamgr.ExecutionContextImpl;
+
+
+import junit.framework.TestCase;
+
+/**
+ */
+public class TestExecutionContextImpl extends TestCase {
+
+    public TestExecutionContextImpl(String name) {
+        super(name);
+    }
+
+    public ExecutionContextImpl createContext(String requestID, String partID) {
+        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$
+    }
+    
+    public void testEqivalenceSemanticsSame() {
+        UnitTestUtil.helpTestEquivalence(0, createContext("100", "1"), createContext("100", "1")); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$
+    }
+
+    public void testEqivalenceSemanticsDifferentPart() {
+        UnitTestUtil.helpTestEquivalence(1, createContext("100", "1"), createContext("100", "2")); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$
+    }
+
+    public void testEqivalenceSemanticsDifferentRequest() {
+        UnitTestUtil.helpTestEquivalence(1, createContext("100", "1"), createContext("200", "1")); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExistsCriteriaImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExistsCriteriaImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExistsCriteriaImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+
+import org.teiid.language.Exists;
+import org.teiid.query.sql.lang.ExistsCriteria;
+
+
+import junit.framework.TestCase;
+
+/**
+ */
+public class TestExistsCriteriaImpl extends TestCase {
+
+    /**
+     * Constructor for TestExistsCriteriaImpl.
+     * @param name
+     */
+    public TestExistsCriteriaImpl(String name) {
+        super(name);
+    }
+
+    public static ExistsCriteria helpExample() {
+        ExistsCriteria crit = new ExistsCriteria(TestQueryImpl.helpExample(true));
+        return crit;
+    }
+    
+    public static Exists example() throws Exception {
+        return (Exists)TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetQuery() throws Exception {
+        assertNotNull(example().getSubquery());    
+    }
+    
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestFunctionImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestFunctionImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestFunctionImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.query.sql.symbol.Constant;
+
+
+public class TestFunctionImpl extends TestCase {
+
+    /**
+     * Constructor for TestFunctionImpl.
+     * @param name
+     */
+    public TestFunctionImpl(String name) {
+        super(name);
+    }
+
+    public static org.teiid.query.sql.symbol.Function helpExample(String name) {
+        Constant c1 = new Constant(new Integer(100));
+        Constant c2 = new Constant(new Integer(200));
+        org.teiid.query.sql.symbol.Function f = new org.teiid.query.sql.symbol.Function(name, new org.teiid.query.sql.symbol.Expression[] {c1, c2});
+        f.setType(Integer.class);
+        return f;
+    }
+    
+    public static Function example(String name) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(name));
+    }
+
+    public void testGetName() throws Exception {
+        assertEquals("testName", example("testName").getName()); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    public void testGetParameters() throws Exception {
+        List<Expression> params = example("testFunction").getParameters(); //$NON-NLS-1$
+        assertNotNull(params);
+        assertEquals(2, params.size());
+        for (int i = 0; i < params.size(); i++) {
+            assertNotNull(params.get(i));
+        }
+    }
+
+    public void testGetType() throws Exception {
+        assertEquals(Integer.class, example("test").getType()); //$NON-NLS-1$
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestGroupByImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestGroupByImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestGroupByImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.ColumnReference;
+import org.teiid.language.GroupBy;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+
+
+public class TestGroupByImpl extends TestCase {
+
+    /**
+     * Constructor for TestGroupByImpl.
+     * @param name
+     */
+    public TestGroupByImpl(String name) {
+        super(name);
+    }
+
+    public static org.teiid.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 org.teiid.query.sql.lang.GroupBy(symbols);
+    }
+
+    public static org.teiid.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 org.teiid.query.sql.lang.GroupBy(symbols);
+    }
+    
+
+    public static GroupBy example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetElements() throws Exception {
+        GroupBy gb = example();
+        assertNotNull(gb.getElements());
+        assertEquals(4, gb.getElements().size());
+        for (Iterator i = gb.getElements().iterator(); i.hasNext();) {
+            assertTrue(i.next() instanceof ColumnReference);
+        }
+    }
+    
+    public void testTranslateWithFunction() throws Exception {
+        TstLanguageBridgeFactory.factory.translate(helpExampleWithFunctions());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestGroupImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestGroupImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestGroupImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+
+import org.teiid.language.NamedTable;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.unittest.FakeMetadataObject;
+
+import junit.framework.TestCase;
+
+
+public class TestGroupImpl extends TestCase {
+
+    /**
+     * Constructor for TestGroupImpl.
+     * @param name
+     */
+    public TestGroupImpl(String name) {
+        super(name);
+    }
+
+    public static GroupSymbol helpExample(String groupName) {
+        return helpExample(groupName, null);
+    }
+    
+    public static GroupSymbol helpExample(String groupName, String definition) {
+        String name = groupName;
+        if (definition != null) {
+            name = definition;
+        }
+        Object obj = new FakeMetadataObject(name, FakeMetadataObject.GROUP);
+        return helpExample(groupName, definition, obj);
+    }
+    
+    public static GroupSymbol helpExample(String groupName, String definition, Object metadataID) {
+        GroupSymbol symbol = new GroupSymbol(groupName, definition);
+        symbol.setMetadataID(metadataID);
+        return symbol;
+    }
+    
+    public static NamedTable example(String groupName) throws Exception {
+        return example(groupName, null);
+    }
+
+    public static NamedTable example(String groupName, String definition) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(groupName, definition));
+    }
+
+    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).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("g1", example("x", "pm1.g1", metadataID).getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInCriteriaImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInCriteriaImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInCriteriaImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.language.Expression;
+import org.teiid.language.In;
+import org.teiid.language.Literal;
+import org.teiid.query.sql.lang.SetCriteria;
+
+
+import junit.framework.TestCase;
+
+public class TestInCriteriaImpl extends TestCase {
+
+    /**
+     * Constructor for TestInCriteriaImpl.
+     * @param name
+     */
+    public TestInCriteriaImpl(String name) {
+        super(name);
+    }
+    
+    public static SetCriteria helpExample(boolean negated) {
+        ArrayList values = new ArrayList();
+        values.add(TestLiteralImpl.helpExample(100));
+        values.add(TestLiteralImpl.helpExample(200));
+        values.add(TestLiteralImpl.helpExample(300));
+        values.add(TestLiteralImpl.helpExample(400));
+        SetCriteria crit = new SetCriteria(TestLiteralImpl.helpExample(300), values);
+        crit.setNegated(negated);
+        return crit;
+    }
+    
+    public static In example(boolean negated) throws Exception {
+        return (In)TstLanguageBridgeFactory.factory.translate(helpExample(negated));
+    }
+
+    public void testGetLeftExpression() throws Exception {
+        In inCriteria = example(false);
+        assertNotNull(inCriteria.getLeftExpression());
+        assertTrue(inCriteria.getLeftExpression() instanceof Literal);
+        assertEquals(new Integer(300), ((Literal)inCriteria.getLeftExpression()).getValue());
+    }
+
+    public void testGetRightExpressions() throws Exception {
+        List values = example(false).getRightExpressions();
+        assertNotNull(values);
+        assertEquals(4, values.size());
+        for (Iterator i = values.iterator(); i.hasNext();) {
+            assertTrue(i.next() instanceof Expression);
+        }
+        
+    }
+
+    public void testIsNegated() throws Exception {
+        assertTrue(example(true).isNegated());
+        assertFalse(example(false).isNegated());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInlineViewImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInlineViewImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInlineViewImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+
+import org.teiid.language.DerivedTable;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+
+
+import junit.framework.TestCase;
+
+public class TestInlineViewImpl extends TestCase {
+
+    public TestInlineViewImpl(String name) {
+        super(name);
+    }
+
+    public static SubqueryFromClause helpExample() {
+        return new SubqueryFromClause("xyz", TestQueryImpl.helpExample(true)); //$NON-NLS-1$
+    }
+    
+    public static DerivedTable example() throws Exception {
+        return (DerivedTable)TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetName() throws Exception {
+        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$
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInsertImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInsertImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInsertImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Expression;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Insert;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
+
+public class TestInsertImpl extends TestCase {
+
+    /**
+     * Constructor for TestInsertImpl.
+     * @param name
+     */
+    public TestInsertImpl(String name) {
+        super(name);
+    }
+
+    public static org.teiid.query.sql.lang.Insert helpExample(String groupName) {
+        GroupSymbol group = TestGroupImpl.helpExample(groupName);
+        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<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 org.teiid.query.sql.lang.Insert(group,
+                          elements,
+                          values);
+    }
+    
+    public static org.teiid.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$
+        
+        ArrayList values = new ArrayList();
+        values.add(TestSearchedCaseExpressionImpl.helpExample());
+        
+        return new org.teiid.query.sql.lang.Insert(group,
+                          elements,
+                          values);
+    }
+  
+    public static Insert example(String groupName) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(groupName));
+        
+    }
+    public static Insert example2(String groupName) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample2(groupName));
+        
+    }
+    public void testGetGroup() throws Exception {
+        assertNotNull(example("a.b").getTable()); //$NON-NLS-1$
+    }
+
+    public void testGetElements() throws Exception {
+        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.substring(sInsertSQL.indexOf('(')).indexOf( '.') == -1 );                        
+    }
+
+    public void testGetValues() throws Exception {
+        Insert insert = example("a.b"); //$NON-NLS-1$
+        assertNotNull(insert.getValueSource());
+        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 {
+        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, ((ExpressionValueSource)insert.getValueSource()).getValues().size());
+        for (Iterator i = ((ExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
+            assertTrue(i.next() instanceof Expression);
+        }
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestIsNullCriteriaImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestIsNullCriteriaImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestIsNullCriteriaImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+
+import org.teiid.language.IsNull;
+import org.teiid.query.sql.lang.IsNullCriteria;
+
+
+import junit.framework.TestCase;
+
+public class TestIsNullCriteriaImpl extends TestCase {
+
+    /**
+     * Constructor for TestIsNullCriteriaImpl.
+     * @param name
+     */
+    public TestIsNullCriteriaImpl(String name) {
+        super(name);
+    }
+
+    public static IsNullCriteria helpExample(boolean negated) {
+    	IsNullCriteria crit = new IsNullCriteria(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
+        crit.setNegated(negated);
+        return crit;
+    }
+    
+    public static IsNull example(boolean negated) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(negated));
+    }
+
+    public void testGetExpression() throws Exception {
+        assertNotNull(example(false).getExpression());
+    }
+
+    public void testIsNegated() throws Exception {
+        assertTrue(example(true).isNegated());
+        assertFalse(example(false).isNegated());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestJoinImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestJoinImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestJoinImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Comparison;
+import org.teiid.language.Join;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
+
+public class TestJoinImpl extends TestCase {
+
+    /**
+     * Constructor for TestJoinImpl.
+     * @param name
+     */
+    public TestJoinImpl(String name) {
+        super(name);
+    }
+
+    public static JoinPredicate helpExample(JoinType type) {
+        ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
+        ElementSymbol e2 = TestElementImpl.helpExample("vm1.g2", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
+        ArrayList criteria = new ArrayList();
+        criteria.add(new CompareCriteria(e1, CompareCriteria.EQ, e2));
+        return new JoinPredicate(new UnaryFromClause(e1.getGroupSymbol()),
+                                 new UnaryFromClause(e2.getGroupSymbol()),
+                                 type,
+                                 criteria);
+    }
+    
+    public static Join example(JoinType type) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(type));
+    }
+
+    public void testGetLeftItem() throws Exception {
+        assertNotNull(example(JoinType.JOIN_CROSS).getLeftItem());
+    }
+
+    public void testGetRightItem() throws Exception {
+        assertNotNull(example(JoinType.JOIN_CROSS).getRightItem());
+    }
+
+    public void testGetJoinType() throws Exception {
+        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 {
+        Join join = example(JoinType.JOIN_INNER);
+        assertTrue(join.getCondition() instanceof Comparison);
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestLikeCriteriaImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestLikeCriteriaImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestLikeCriteriaImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import org.teiid.language.Like;
+import org.teiid.language.Literal;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
+
+import junit.framework.TestCase;
+
+public class TestLikeCriteriaImpl extends TestCase {
+
+    /**
+     * Constructor for TestLikeCriteriaImpl.
+     * @param name
+     */
+    public TestLikeCriteriaImpl(String name) {
+        super(name);
+    }
+
+    public static MatchCriteria helpExample(String right, char escape, boolean negated) {
+        ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
+        MatchCriteria match = new MatchCriteria(e1, new Constant(right), escape);
+        match.setNegated(negated);
+        return match;
+    }
+    
+    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 {
+        assertNotNull(example("abc", '.', false).getLeftExpression()); //$NON-NLS-1$
+    }
+
+    public void testGetRightExpression() throws Exception {
+        Like like = example("abc", '.', false); //$NON-NLS-1$
+        assertNotNull(like.getRightExpression());
+        assertTrue(like.getRightExpression() instanceof Literal);
+        assertEquals("abc", ((Literal)like.getRightExpression()).getValue()); //$NON-NLS-1$
+    }
+
+    public void testGetEscapeCharacter() throws Exception {
+        assertEquals(new Character('.'), example("abc", '.', false).getEscapeCharacter()); //$NON-NLS-1$
+    }
+
+    public void testIsNegated() throws Exception {
+        assertTrue(example("abc", '.', true).isNegated()); //$NON-NLS-1$
+        assertFalse(example("abc", '.', false).isNegated()); //$NON-NLS-1$
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestLiteralImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestLiteralImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestLiteralImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+
+import org.teiid.language.Literal;
+import org.teiid.query.sql.symbol.Constant;
+
+
+import junit.framework.TestCase;
+
+public class TestLiteralImpl extends TestCase {
+
+    /**
+     * Constructor for TestLiteralImpl.
+     * @param name
+     */
+    public TestLiteralImpl(String name) {
+        super(name);
+    }
+
+    public static Constant helpExample(int val) {
+        return new Constant(new Integer(val));
+    }
+    
+    public static Constant helpExample(Object val) {
+        return new Constant(val);
+    }
+    
+    public static Literal example(int val) {
+        Constant c = helpExample(val);
+        return new Literal(c.getValue(), c.getType());
+    }
+
+    public static Literal example(Object val) {
+        Constant c = helpExample(val);
+        return new Literal(c.getValue(), c.getType());
+    }
+
+    public void testGetValue() {
+        assertEquals(new Integer(100), example(100).getValue());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestMetadataFactory.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestMetadataFactory.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestMetadataFactory.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -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.datamgr;
+
+import java.util.List;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+
+import junit.framework.TestCase;
+
+
+public class TestMetadataFactory  extends TestCase {
+    private RuntimeMetadataImpl metadataFactory;
+    private FakeMetadataObject pm1g1;
+    
+    public TestMetadataFactory(String name) {
+        super(name);
+    }
+    
+    public void setUp(){
+        FakeMetadataStore store = new FakeMetadataStore();
+        pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", FakeMetadataFactory.createPhysicalModel("pm1.g1")); //$NON-NLS-1$ //$NON-NLS-2$
+        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 });
+        store.addObject(pm1g1);
+        store.addObjects(pm1g1e);
+        metadataFactory = new RuntimeMetadataImpl(new FakeMetadataFacade(store));
+    }
+    
+    public void testGetVDBResourcePaths() throws Exception {
+        String[] expectedPaths = new String[] {"my/resource/path"}; //$NON-NLS-1$
+        String[] mfPaths = metadataFactory.getVDBResourcePaths();
+        assertEquals(expectedPaths.length, mfPaths.length);
+        for (int i = 0; i < expectedPaths.length; i++) {
+            assertEquals(expectedPaths[i], mfPaths[i]);
+        }
+    }
+     
+    public void testGetBinaryVDBResource() throws Exception {
+        byte[] expectedBytes = "ResourceContents".getBytes(); //$NON-NLS-1$
+        byte[] mfBytes =  metadataFactory.getBinaryVDBResource(null);
+        assertEquals(expectedBytes.length, mfBytes.length);
+        for (int i = 0; i < expectedBytes.length; i++) {
+            assertEquals("Byte at index " + i + " differs from expected content", expectedBytes[i], mfBytes[i]); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+    }
+     
+    public void testGetCharacterVDBResource() throws Exception {
+        assertEquals("ResourceContents", metadataFactory.getCharacterVDBResource(null)); //$NON-NLS-1$
+    }
+     
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestNotCriteriaImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestNotCriteriaImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestNotCriteriaImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+
+import org.teiid.language.Not;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+
+
+import junit.framework.TestCase;
+
+public class TestNotCriteriaImpl extends TestCase {
+
+    /**
+     * Constructor for TestNotCriteriaImpl.
+     * @param name
+     */
+    public TestNotCriteriaImpl(String name) {
+        super(name);
+    }
+
+    public static NotCriteria helpExample() {
+        return new NotCriteria(TestCompareCriteriaImpl.helpExample(CompareCriteria.GE, 100, 200));
+    }
+    
+    public static Not example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetCriteria() throws Exception {
+        assertNotNull(example().getCriteria());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestOrderByImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestOrderByImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestOrderByImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.OrderBy;
+import org.teiid.language.SortSpecification;
+
+public class TestOrderByImpl extends TestCase {
+
+    /**
+     * Constructor for TestOrderByImpl.
+     * @param name
+     */
+    public TestOrderByImpl(String name) {
+        super(name);
+    }
+
+    public static org.teiid.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$
+        elements.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
+        elements.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
+        
+        ArrayList types = new ArrayList();
+        types.add(Boolean.TRUE);
+        types.add(Boolean.FALSE);
+        types.add(Boolean.TRUE);
+        types.add(Boolean.FALSE);
+        return new org.teiid.query.sql.lang.OrderBy(elements, types);
+    }
+    
+    public static OrderBy example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetItems() throws Exception {
+        List items = example().getSortSpecifications();
+        assertNotNull(items);
+        assertEquals(4, items.size());
+        for (Iterator i = items.iterator(); i.hasNext();) {
+            assertTrue(i.next() instanceof SortSpecification);
+        }
+        
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestParameterImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestParameterImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestParameterImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Argument.Direction;
+
+public class TestParameterImpl extends TestCase {
+
+    /**
+     * Constructor for TestParameterImpl.
+     * @param name
+     */
+    public TestParameterImpl(String name) {
+        super(name);
+    }
+
+    public static Argument example(int index) throws Exception {
+        Call procImpl = TestProcedureImpl.example();
+        return procImpl.getArguments().get(index);
+    }
+
+    public void testGetDirection() throws Exception {
+        assertEquals(Direction.IN, example(0).getDirection());
+        assertEquals(Direction.IN, example(1).getDirection());
+    }
+
+    public void testGetType() throws Exception {
+        assertTrue(example(0).getType().equals(String.class));
+        assertTrue(example(1).getType().equals(Integer.class));
+    }
+
+    public void testGetValue() throws Exception {
+        assertEquals("x", example(0).getArgumentValue().getValue()); //$NON-NLS-1$
+        assertEquals(new Integer(1), example(1).getArgumentValue().getValue());
+    }
+    
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestProcedureImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestProcedureImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestProcedureImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Call;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.StoredProcedure;
+
+
+public class TestProcedureImpl extends TestCase {
+
+    /**
+     * Constructor for TestExecuteImpl.
+     * @param name
+     */
+    public TestProcedureImpl(String name) {
+        super(name);
+    }
+
+    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 TstLanguageBridgeFactory.factory.translate((StoredProcedure)command);
+    }
+    
+    public void testGetProcedureName() throws Exception {
+        assertEquals("sq3", example().getProcedureName()); //$NON-NLS-1$
+    }
+
+    public void testGetParameters() throws Exception {
+        Call exec = example();
+        assertNotNull(exec.getArguments());
+        assertEquals(2, exec.getArguments().size());
+    }
+    
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestQueryImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestQueryImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestQueryImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -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.dqp.internal.datamgr;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Select;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
+
+public class TestQueryImpl extends TestCase {
+
+    /**
+     * Constructor for TestQueryImpl.
+     * @param name
+     */
+    public TestQueryImpl(String name) {
+        super(name);
+    }
+    
+    public static org.teiid.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$
+        org.teiid.query.sql.lang.Select sel = new org.teiid.query.sql.lang.Select(symbols);
+        sel.setDistinct(distinct);
+        return sel;
+    }
+
+    public static Query helpExample(boolean distinct) {
+        return new Query(helpExampleSelect(distinct),
+                         TestQueryImpl.helpExampleFrom(),
+                         TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
+                         TestGroupByImpl.helpExample(),
+                         TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
+                         TestOrderByImpl.helpExample(),
+                         null);
+    }
+    
+    public static Select example(boolean distinct) throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample(distinct));
+    }
+
+    public void testGetSelect() throws Exception {
+        assertNotNull(example(true).getDerivedColumns());
+    }
+
+    public void testGetFrom() throws Exception {
+        assertNotNull(example(true).getFrom());
+    }
+
+    public void testGetWhere() throws Exception {
+        assertNotNull(example(true).getWhere());
+    }
+
+    public void testGetGroupBy() throws Exception {
+        assertNotNull(example(true).getGroupBy());
+    }
+
+    public void testGetHaving() throws Exception {
+        assertNotNull(example(true).getHaving());
+    }
+
+    public void testGetOrderBy() throws Exception {
+        assertNotNull(example(true).getOrderBy());
+    }
+    
+    public void testGetColumnNames() throws Exception {
+        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(true).getColumnTypes();
+        assertTrue(EquivalenceUtil.areEquivalent(expected, types));
+    }
+
+	public static org.teiid.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 org.teiid.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());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestScalarSubqueryImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestScalarSubqueryImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestScalarSubqueryImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.ScalarSubquery;
+import org.teiid.language.Select;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
+
+/**
+ */
+public class TestScalarSubqueryImpl extends TestCase {
+
+    /**
+     * Constructor for TestScalarSubqueryImpl.
+     * @param name
+     */
+    public TestScalarSubqueryImpl(String name) {
+        super(name);
+    }
+
+    public static org.teiid.query.sql.symbol.ScalarSubquery helpExample() {
+        Query query = TestQueryImpl.helpExample(true);
+        org.teiid.query.sql.symbol.ScalarSubquery ss = new org.teiid.query.sql.symbol.ScalarSubquery(query);
+        ss.setType(((SingleElementSymbol)query.getProjectedSymbols().get(0)).getType());
+        return ss;
+    }
+    
+    public static ScalarSubquery example() throws Exception {
+        return (ScalarSubquery)TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetQuery() throws Exception {
+        assertNotNull(example().getSubquery());    }
+    
+    public void testGetType() throws Exception {
+        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$
+    }
+    
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSearchedCaseExpressionImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSearchedCaseExpressionImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSearchedCaseExpressionImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -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.datamgr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.language.SearchedCase;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.TestCaseExpression;
+
+
+
+import junit.framework.TestCase;
+
+public class TestSearchedCaseExpressionImpl extends TestCase {
+
+    /**
+     * Constructor for TestSearchedCaseExpressionImpl.
+     * @param name
+     */
+    public TestSearchedCaseExpressionImpl(String name) {
+        super(name);
+    }
+
+    public static List getWhenCriteria(int criteria) {
+        ArrayList list = new ArrayList();
+        ElementSymbol x = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
+        for (int i = 0; i < criteria; i++) {
+            list.add(new CompareCriteria(x, CompareCriteria.EQ, new Constant(new Integer(i))));
+        }
+        return list;
+    }
+    
+    public static SearchedCaseExpression helpExample() {
+        SearchedCaseExpression caseExpr = new SearchedCaseExpression(getWhenCriteria(3), TestCaseExpression.getThenExpressions(3));
+        caseExpr.setElseExpression(new Constant(new Integer(9999)));
+        return caseExpr;
+    }
+    
+    public static SearchedCase example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetElseExpression() throws Exception {
+        assertNotNull(example().getElseExpression());
+        SearchedCaseExpression expr = helpExample();
+        expr.setElseExpression(null);
+        assertNull(TstLanguageBridgeFactory.factory.translate(expr).getElseExpression());
+    }
+
+    public void testGetThenExpression() throws Exception {
+        assertNotNull(example().getCases().get(0));
+        assertNotNull(example().getCases().get(1));
+        assertNotNull(example().getCases().get(2));
+    }
+
+    public void testGetWhenCount() throws Exception {
+        assertEquals(3, example().getCases().size());
+    }
+
+    public void testGetWhenCriteria() throws Exception {
+        assertNotNull(example().getCases().get(0));
+        assertNotNull(example().getCases().get(1));
+        assertNotNull(example().getCases().get(2));
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSelectSymbolImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSelectSymbolImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSelectSymbolImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -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 org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Literal;
+import org.teiid.language.Select;
+
+
+public class TestSelectSymbolImpl extends TestCase {
+
+    /**
+     * Constructor for TestSelectSymbolImpl.
+     * @param name
+     */
+    public TestSelectSymbolImpl(String name) {
+        super(name);
+    }
+
+    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 {
+        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("testAlias", example("testName", "testAlias").getAlias()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    }
+
+    public void testGetExpression() throws Exception {
+        assertNotNull(example("testName", null).getExpression()); //$NON-NLS-1$
+    }
+    
+    public void testGetColumnDataTypes(){
+        Class<?>[] expectedResults = new Class[2];
+        List<DerivedColumn> symbols = new ArrayList<DerivedColumn>();
+        symbols.add(new DerivedColumn("c1", new Literal("3", DataTypeManager.DefaultDataClasses.STRING)));  //$NON-NLS-1$//$NON-NLS-2$
+        expectedResults[0] = DataTypeManager.DefaultDataClasses.STRING;
+        symbols.add(new DerivedColumn("c2", new Literal(new Integer(5), DataTypeManager.DefaultDataClasses.INTEGER)));  //$NON-NLS-1$
+        expectedResults[1] = DataTypeManager.DefaultDataClasses.INTEGER;
+        Select query = new Select(symbols, false, null, null, null, null, null);
+        Class<?>[] results = query.getColumnTypes();  
+        assertEquals( results[0], expectedResults[0]);
+        assertEquals( results[1], expectedResults[1]);     
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSetQueryImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSetQueryImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSetQueryImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.NamedTable;
+import org.teiid.language.OrderBy;
+import org.teiid.language.Select;
+import org.teiid.language.SetQuery;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.SortSpecification.Ordering;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+
+
+
+/** 
+ * @since 4.2
+ */
+public class TestSetQueryImpl extends TestCase {
+
+    public static org.teiid.query.sql.lang.SetQuery helpExampleSetQuery() {
+        org.teiid.query.sql.lang.SetQuery setQuery = new org.teiid.query.sql.lang.SetQuery(Operation.UNION);
+        setQuery.setAll(false);
+        setQuery.setLeftQuery(TestQueryImpl.helpExample(true));
+        setQuery.setRightQuery(TestQueryImpl.helpExample(true));
+        setQuery.setOrderBy(TestOrderByImpl.helpExample());
+        return setQuery;
+    }
+        
+    public static SetQuery example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExampleSetQuery());
+    }
+    
+    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(null,element); 
+        List symbols = new ArrayList();
+        symbols.add(symbol);
+        List items = new ArrayList();
+        items.add(group);
+        
+        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(null, element2);
+        List symbols2 = new ArrayList();
+        symbols2.add(symbol2);
+        
+        List items2 = new ArrayList();
+        items2.add(group2);
+        
+        Select secondQuery = new Select(symbols2, false, items2, null, null, null, null);
+        
+        Select query = new Select(symbols, false, items, null, null, null, null);
+        
+        SetQuery setQuery = new SetQuery();
+        setQuery.setOperation(SetQuery.Operation.UNION);
+        setQuery.setAll(true);
+        setQuery.setLeftQuery(query);
+        setQuery.setRightQuery(secondQuery);
+        
+        return setQuery;
+    }
+    
+    public static SetQuery example3() throws Exception {
+        SetQuery union = example2();
+        
+        List<SortSpecification> items = new ArrayList<SortSpecification>();
+        items.add(new SortSpecification(Ordering.ASC, new ColumnReference(null, "nugent", null, DataTypeManager.DefaultDataClasses.STRING))); //$NON-NLS-1$
+        OrderBy orderBy = new OrderBy(items);
+        
+        union.setOrderBy(orderBy);
+        return union;
+    }
+    
+    public void testNestedSetQuery() throws Exception {
+        org.teiid.query.sql.lang.SetQuery query = new org.teiid.query.sql.lang.SetQuery(org.teiid.query.sql.lang.SetQuery.Operation.EXCEPT, true, helpExampleSetQuery(), helpExampleSetQuery());
+        
+        SetQuery setQuery = TstLanguageBridgeFactory.factory.translate(query);
+        assertTrue(setQuery.getLeftQuery() instanceof SetQuery);
+        assertTrue(setQuery.getRightQuery() instanceof SetQuery);
+    }
+    
+    public void testGetSelect() throws Exception {
+        assertNotNull(example().getProjectedQuery().getDerivedColumns());
+    }
+
+    public void testGetFrom() throws Exception {
+        assertNotNull(example().getProjectedQuery().getFrom());
+    }
+
+    public void testGetWhere() throws Exception {
+        assertNotNull(example().getProjectedQuery().getWhere());
+    }
+
+    public void testGetGroupBy() throws Exception {
+        assertNotNull(example().getProjectedQuery().getGroupBy());
+    }
+
+    public void testGetHaving() throws Exception {
+        assertNotNull(example().getProjectedQuery().getHaving());
+    }
+
+    public void testGetOrderBy() throws Exception {
+        assertNotNull(example().getOrderBy());
+    }
+    
+    public void testGetUnionAllFlag() throws Exception {
+        assertEquals(false, example().isAll());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSubqueryCompareCriteriaImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSubqueryCompareCriteriaImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSubqueryCompareCriteriaImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Comparison;
+import org.teiid.language.SubqueryComparison;
+import org.teiid.language.SubqueryComparison.Quantifier;
+import org.teiid.query.sql.lang.AbstractCompareCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
+
+/**
+ */
+public class TestSubqueryCompareCriteriaImpl extends TestCase {
+
+    /**
+     * Constructor for TestSubqueryCompareCriteriaImpl.
+     * @param name
+     */
+    public TestSubqueryCompareCriteriaImpl(String name) {
+        super(name);
+    }
+
+    public static SubqueryCompareCriteria helpExample() {
+        ElementSymbol element = TestElementImpl.helpExample("g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
+        Query query = TestQueryImpl.helpExample(true);
+        SubqueryCompareCriteria scc = new SubqueryCompareCriteria(element, query, AbstractCompareCriteria.GT, SubqueryCompareCriteria.ANY);
+        return scc;
+    }
+    
+    public static SubqueryComparison example() throws Exception {
+        return (SubqueryComparison)TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetExpression() throws Exception {
+        assertNotNull(example().getLeftExpression());
+    }
+
+    public void testGetQuery() throws Exception {
+        assertNotNull(example().getSubquery());
+    }
+    
+    public void testOperator() throws Exception {
+        assertEquals("Wrong operator", Comparison.Operator.GT, example().getOperator()); //$NON-NLS-1$
+    }
+
+    public void testQuantifier() throws Exception {
+        assertEquals("Wrong quantifier", Quantifier.SOME, example().getQuantifier()); //$NON-NLS-1$
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSubqueryInCriteriaImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSubqueryInCriteriaImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestSubqueryInCriteriaImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+
+import org.teiid.language.SubqueryIn;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
+import junit.framework.TestCase;
+
+
+/**
+ */
+public class TestSubqueryInCriteriaImpl extends TestCase {
+
+    /**
+     * Constructor for TestSubqueryInCriteriaImpl.
+     * @param name
+     */
+    public TestSubqueryInCriteriaImpl(String name) {
+        super(name);
+    }
+
+    public static SubquerySetCriteria helpExample() {
+        ElementSymbol element = TestElementImpl.helpExample("g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
+        Query query = TestQueryImpl.helpExample(true);
+        SubquerySetCriteria ssc = new SubquerySetCriteria(element, query);
+        ssc.setNegated(true);
+        return ssc;
+    }
+    
+    public static SubqueryIn example() throws Exception {
+        return (SubqueryIn)TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetExpression() throws Exception {
+        assertNotNull(example().getLeftExpression());
+    }
+
+    public void testGetQuery() throws Exception {
+        assertNotNull(example().getSubquery());
+    }
+    
+    public void testIsNegated() throws Exception {
+        assertEquals("Wrong negation", true, example().isNegated()); //$NON-NLS-1$
+    }
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestTypeFacilityImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestTypeFacilityImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestTypeFacilityImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.sql.Clob;
+
+import org.teiid.translator.TypeFacility;
+
+import junit.framework.TestCase;
+
+public class TestTypeFacilityImpl extends TestCase {
+
+	public void testNullClob() {
+		assertNull(new TypeFacility().convertToRuntimeType((Clob)null));
+	}
+	
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestUpdateImpl.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestUpdateImpl.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestUpdateImpl.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Update;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
+
+public class TestUpdateImpl extends TestCase {
+
+    /**
+     * Constructor for TestUpdateImpl.
+     * @param name
+     */
+    public TestUpdateImpl(String name) {
+        super(name);
+    }
+    
+    public static org.teiid.query.sql.lang.Update helpExample() {
+        GroupSymbol group = TestGroupImpl.helpExample("vm1.g1"); //$NON-NLS-1$
+        org.teiid.query.sql.lang.Update result = new org.teiid.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)));
+        result.addChange(TestElementImpl.helpExample("vm1.g1", "e3"), new Constant(new Integer(1)));
+        result.addChange(TestElementImpl.helpExample("vm1.g1", "e4"), new Constant(new Integer(1)));
+        result.setCriteria(new CompareCriteria(new Constant(new Integer(1)), CompareCriteria.EQ, new Constant(new Integer(1))));
+        return result;
+    }
+    
+    public static Update example() throws Exception {
+        return TstLanguageBridgeFactory.factory.translate(helpExample());
+    }
+
+    public void testGetGroup() throws Exception {
+        assertNotNull(example().getTable());
+    }
+
+    public void testGetChanges() throws Exception {
+        List changes = example().getChanges();
+        assertNotNull(changes);
+        assertEquals(4, changes.size());
+    }
+
+    public void testGetCriteria() throws Exception {
+        assertNotNull(example().getWhere());
+    }
+
+}

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TstLanguageBridgeFactory.java (from rev 2353, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TstLanguageBridgeFactory.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TstLanguageBridgeFactory.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr;
+
+import org.teiid.dqp.internal.datamgr.LanguageBridgeFactory;
+import org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TstLanguageBridgeFactory {
+    
+    public static final QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+    public static final RuntimeMetadataImpl metadataFactory = new RuntimeMetadataImpl(metadata);
+    public static final LanguageBridgeFactory factory = new LanguageBridgeFactory(metadata);
+
+}

Modified: 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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -29,8 +29,8 @@
 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 org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
 import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
 import org.teiid.query.optimizer.capabilities.SourceCapabilities;
 

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -37,8 +37,8 @@
 import org.teiid.client.RequestMessage;
 import org.teiid.client.ResultsMessage;
 import org.teiid.common.queue.FakeWorkManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.FakeTransactionService;
 import org.teiid.dqp.service.AutoGenDataService;
 import org.teiid.dqp.service.FakeBufferService;
 import org.teiid.query.unittest.FakeMetadataFactory;

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -34,7 +34,7 @@
 import org.teiid.client.RequestMessage;
 import org.teiid.client.SourceWarning;
 import org.teiid.core.TeiidException;
-import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.internal.datamgr.FakeTransactionService;
 import org.teiid.dqp.internal.process.DQPCore.ClientState;
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.dqp.message.RequestID;

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -29,8 +29,8 @@
 import org.teiid.client.RequestMessage;
 import org.teiid.common.buffer.BlockedException;
 import org.teiid.core.TeiidException;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.FakeTransactionService;
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.dqp.message.RequestID;
 import org.teiid.dqp.service.AutoGenDataService;

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -34,7 +34,7 @@
 import org.teiid.client.metadata.MetadataResult;
 import org.teiid.client.metadata.ResultsMetadataConstants;
 import org.teiid.core.types.DataTypeManager;
-import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.internal.datamgr.FakeTransactionService;
 import org.teiid.dqp.message.RequestID;
 import org.teiid.query.analysis.AnalysisRecord;
 import org.teiid.query.metadata.QueryMetadataInterface;

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -38,8 +38,8 @@
 import org.teiid.common.buffer.BufferManagerFactory;
 import org.teiid.core.TeiidComponentException;
 import org.teiid.core.TeiidProcessingException;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.FakeTransactionService;
 import org.teiid.dqp.service.AutoGenDataService;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.optimizer.TestOptimizer;

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-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -33,8 +33,8 @@
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.core.TeiidComponentException;
 import org.teiid.core.TeiidProcessingException;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.FakeTransactionService;
 import org.teiid.dqp.service.AutoGenDataService;
 import org.teiid.query.analysis.AnalysisRecord;
 import org.teiid.query.metadata.QueryMetadataInterface;

Modified: trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -26,7 +26,7 @@
 
 import org.teiid.client.RequestMessage;
 import org.teiid.core.util.UnitTestUtil;
-import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
+import org.teiid.dqp.internal.datamgr.TestQueryImpl;
 import org.teiid.dqp.internal.process.DQPWorkContext;
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.dqp.message.RequestID;

Modified: trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -30,9 +30,9 @@
 
 import org.teiid.core.TeiidComponentException;
 import org.teiid.core.types.DataTypeManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorWork;
+import org.teiid.dqp.internal.datamgr.ConnectorWorkItem;
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.dqp.message.AtomicResultsMessage;
 import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -61,7 +61,7 @@
 import org.teiid.core.TeiidComponentException;
 import org.teiid.core.TeiidRuntimeException;
 import org.teiid.deployers.VDBRepository;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
 import org.teiid.dqp.internal.process.DQPConfiguration;
 import org.teiid.dqp.internal.process.DQPCore;
 import org.teiid.dqp.internal.process.DQPWorkContext;

Modified: trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -27,7 +27,7 @@
 import java.util.Collection;
 
 import org.teiid.cdk.CommandBuilder;
-import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl;
 import org.teiid.language.Command;
 import org.teiid.metadata.RuntimeMetadata;
 import org.teiid.metadata.index.VDBMetadataFactory;

Modified: trunk/runtime/src/main/java/org/teiid/deployers/TranslatorAnnotationScanningDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/TranslatorAnnotationScanningDeployer.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/runtime/src/main/java/org/teiid/deployers/TranslatorAnnotationScanningDeployer.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -35,7 +35,7 @@
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.factory.ManagedObjectFactory;
 import org.teiid.adminapi.impl.TranslatorMetaData;
-import org.teiid.dqp.internal.datamgr.impl.TranslatorRepository;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.runtime.RuntimePlugin;

Modified: trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -28,7 +28,7 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.teiid.adminapi.Translator;
 import org.teiid.adminapi.impl.TranslatorMetaData;
-import org.teiid.dqp.internal.datamgr.impl.TranslatorRepository;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.runtime.RuntimePlugin;

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -42,9 +42,9 @@
 import org.teiid.core.CoreConstants;
 import org.teiid.core.util.FileUtils;
 import org.teiid.dqp.internal.cache.DQPContextCache;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.datamgr.impl.TranslatorRepository;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.metadata.MetadataStore;

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -25,8 +25,8 @@
 import org.teiid.adminapi.VDB;
 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 org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.runtime.RuntimePlugin;

Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -32,32 +32,32 @@
 
 import org.junit.Test;
 import org.teiid.cdk.unittest.FakeTranslationFactory;
-import org.teiid.dqp.internal.datamgr.language.TestAggregateImpl;
-import org.teiid.dqp.internal.datamgr.language.TestCompareCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.TestDeleteImpl;
-import org.teiid.dqp.internal.datamgr.language.TestElementImpl;
-import org.teiid.dqp.internal.datamgr.language.TestExistsCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.TestFunctionImpl;
-import org.teiid.dqp.internal.datamgr.language.TestGroupByImpl;
-import org.teiid.dqp.internal.datamgr.language.TestGroupImpl;
-import org.teiid.dqp.internal.datamgr.language.TestInCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.TestInsertImpl;
-import org.teiid.dqp.internal.datamgr.language.TestIsNullCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.TestJoinImpl;
-import org.teiid.dqp.internal.datamgr.language.TestLikeCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.TestLiteralImpl;
-import org.teiid.dqp.internal.datamgr.language.TestNotCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.TestOrderByImpl;
-import org.teiid.dqp.internal.datamgr.language.TestProcedureImpl;
-import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
-import org.teiid.dqp.internal.datamgr.language.TestScalarSubqueryImpl;
-import org.teiid.dqp.internal.datamgr.language.TestSearchedCaseExpressionImpl;
-import org.teiid.dqp.internal.datamgr.language.TestSelectSymbolImpl;
-import org.teiid.dqp.internal.datamgr.language.TestSetQueryImpl;
-import org.teiid.dqp.internal.datamgr.language.TestSubqueryCompareCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.TestSubqueryInCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.TestUpdateImpl;
-import org.teiid.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
+import org.teiid.dqp.internal.datamgr.TestAggregateImpl;
+import org.teiid.dqp.internal.datamgr.TestCompareCriteriaImpl;
+import org.teiid.dqp.internal.datamgr.TestDeleteImpl;
+import org.teiid.dqp.internal.datamgr.TestElementImpl;
+import org.teiid.dqp.internal.datamgr.TestExistsCriteriaImpl;
+import org.teiid.dqp.internal.datamgr.TestFunctionImpl;
+import org.teiid.dqp.internal.datamgr.TestGroupByImpl;
+import org.teiid.dqp.internal.datamgr.TestGroupImpl;
+import org.teiid.dqp.internal.datamgr.TestInCriteriaImpl;
+import org.teiid.dqp.internal.datamgr.TestInsertImpl;
+import org.teiid.dqp.internal.datamgr.TestIsNullCriteriaImpl;
+import org.teiid.dqp.internal.datamgr.TestJoinImpl;
+import org.teiid.dqp.internal.datamgr.TestLikeCriteriaImpl;
+import org.teiid.dqp.internal.datamgr.TestLiteralImpl;
+import org.teiid.dqp.internal.datamgr.TestNotCriteriaImpl;
+import org.teiid.dqp.internal.datamgr.TestOrderByImpl;
+import org.teiid.dqp.internal.datamgr.TestProcedureImpl;
+import org.teiid.dqp.internal.datamgr.TestQueryImpl;
+import org.teiid.dqp.internal.datamgr.TestScalarSubqueryImpl;
+import org.teiid.dqp.internal.datamgr.TestSearchedCaseExpressionImpl;
+import org.teiid.dqp.internal.datamgr.TestSelectSymbolImpl;
+import org.teiid.dqp.internal.datamgr.TestSetQueryImpl;
+import org.teiid.dqp.internal.datamgr.TestSubqueryCompareCriteriaImpl;
+import org.teiid.dqp.internal.datamgr.TestSubqueryInCriteriaImpl;
+import org.teiid.dqp.internal.datamgr.TestUpdateImpl;
+import org.teiid.dqp.internal.datamgr.TstLanguageBridgeFactory;
 import org.teiid.language.AggregateFunction;
 import org.teiid.language.ColumnReference;
 import org.teiid.language.Command;

Modified: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -26,7 +26,7 @@
 import java.util.List;
 
 import org.teiid.core.util.UnitTestUtil;
-import org.teiid.dqp.internal.datamgr.impl.CapabilitiesConverter;
+import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.optimizer.TestOptimizer;
 import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java	2010-07-20 20:06:35 UTC (rev 2360)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java	2010-07-20 20:42:43 UTC (rev 2361)
@@ -34,9 +34,9 @@
 import org.teiid.client.security.ILogon;
 import org.teiid.deployers.MetadataStoreGroup;
 import org.teiid.deployers.VDBRepository;
-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 org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.FakeTransactionService;
 import org.teiid.dqp.internal.process.DQPConfiguration;
 import org.teiid.dqp.internal.process.DQPCore;
 import org.teiid.dqp.service.FakeBufferService;



More information about the teiid-commits mailing list