[teiid-commits] teiid SVN: r4191 - in trunk: admin/src/main/java/org/teiid/adminapi/impl and 17 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Jun 20 11:57:11 EDT 2012


Author: shawkins
Date: 2012-06-20 11:57:10 -0400 (Wed, 20 Jun 2012)
New Revision: 4191

Modified:
   trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
   trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
   trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
   trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
   trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
   trunk/admin/src/test/resources/vdb-describe.txt
   trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
   trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
   trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
   trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
   trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
   trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java
   trunk/engine/src/main/resources/org/teiid/query/i18n.properties
   trunk/engine/src/test/java/org/teiid/query/metadata/TestMetadataValidator.java
   trunk/engine/src/test/java/org/teiid/query/parser/TestDDLParser.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
   trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
   trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
   trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
   trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
   trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
   trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
   trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
   trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
   trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java
   trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
   trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java
Log:
TEIID-2062 allowing deployment to fail on metadata errors and other fixes

Modified: trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/VDB.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/admin/src/main/java/org/teiid/adminapi/VDB.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -40,23 +40,18 @@
  */
 public interface VDB extends AdminObject, DomainAware {
 
-    public static enum Status{
-    	                   //loaded | valid
-    	INCOMPLETE(true),  //f        f
-    	LOADING(true),     //f        t
-    	INVALID(false),    //t        f
-    	ACTIVE(false),     //t        t
-    	REMOVED(false);
-
-    	private boolean loading;
-    	private Status(boolean loading) {
-    		this.loading = loading;
-		}
-    	
-		public boolean isLoading() {
-			return loading;
-		}};
-
+    public enum Status{
+    	/**
+    	 * Initial state waiting for metadata to load
+    	 */
+    	LOADING,     
+    	/**
+    	 * In the vdb repository and querable, but not necessarily valid
+    	 */
+    	ACTIVE,      
+    	REMOVED
+    };
+    
     public enum ConnectionType {NONE, BY_VERSION, ANY}
     
     /**

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -159,8 +159,29 @@
 	
 	public void addSourceMapping(SourceMappingMetadata source) {
 		this.addSourceMapping(source.getName(), source.getTranslatorName(), source.getConnectionJndiName());
-	}    
+	}
 	
+	public synchronized boolean hasErrors() {
+		if (this.validationErrors == null && this.runtimeErrors == null) {
+			return false;
+		}
+		if (this.validationErrors != null) {
+			for (ValidationError error : this.validationErrors) {
+				if (error.getSeverity() == Severity.ERROR) {
+					return true;
+				}
+			}
+		}
+		if (this.runtimeErrors != null) {
+			for (ValidationError error : this.runtimeErrors) {
+				if (error.getSeverity() == Severity.ERROR) {
+					return true;
+				}
+			}
+		}
+		return false;	
+	}
+	
 	public synchronized List<ValidationError> getErrors(){
 		return getErrors(true);
 	}	
@@ -180,7 +201,7 @@
 	}
 	
     public ValidationError addError(String severity, String message) {
-        ValidationError ve = new ValidationError(severity, message);
+        ValidationError ve = new ValidationError(Severity.valueOf(severity), message);
         addError(ve);
         return ve;
     }
@@ -190,7 +211,7 @@
 	}    
     
     public synchronized ValidationError addRuntimeError(String message) {
-        ValidationError ve = new ValidationError(Severity.ERROR.name(), message);
+        ValidationError ve = new ValidationError(Severity.ERROR, message);
         if (this.runtimeErrors == null) {
             this.runtimeErrors = new LinkedList<ValidationError>();
         }
@@ -221,12 +242,12 @@
 		public enum Severity {ERROR, WARNING};
     	
         protected String value;
-        protected String severity;
+        protected Severity severity;
         protected String path;
         
 		public ValidationError() {};
         
-        public ValidationError(String severity, String msg) {
+        public ValidationError(Severity severity, String msg) {
         	this.severity = severity;
         	this.value = msg;
         }
@@ -239,11 +260,11 @@
 			this.value = value;
 		}
 
-		public String getSeverity() {
+		public Severity getSeverity() {
 			return severity;
 		}
 
-		public void setSeverity(String severity) {
+		public void setSeverity(Severity severity) {
 			this.severity = severity;
 		}       
 		

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -27,7 +27,6 @@
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import org.teiid.adminapi.DataPolicy;
@@ -35,6 +34,7 @@
 import org.teiid.adminapi.Translator;
 import org.teiid.adminapi.VDB;
 import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
 
 
 public class VDBMetaData extends AdminObjectImpl implements VDB {
@@ -78,7 +78,7 @@
 	}
 	
 	public boolean isLoading() {
-		return this.status.isLoading();
+		return this.status == Status.LOADING;
 	}
 	
 	public synchronized void setStatus(Status s) {
@@ -107,7 +107,7 @@
 		return new ArrayList<Model>(this.models.values());
 	}
 	
-	public Map<String, ModelMetaData> getModelMetaDatas() {
+	public LinkedHashMap<String, ModelMetaData> getModelMetaDatas() {
 		return this.models;
 	}
 	
@@ -160,7 +160,7 @@
 			List<ValidationError> errors = model.getErrors();
 			if (errors != null && !errors.isEmpty()) {
 				for (ValidationError m:errors) {
-					if (ValidationError.Severity.valueOf(m.getSeverity()).equals(ValidationError.Severity.ERROR)) {
+					if (m.getSeverity() == Severity.ERROR) {
 						allErrors.add(m.getValue());
 					}
 				}
@@ -171,9 +171,18 @@
 	
 	@Override
     public boolean isValid() {
-        return Status.ACTIVE.equals(this.status);
+        return status == Status.ACTIVE && !hasErrors();
     } 	
-    
+	
+	public boolean hasErrors() {
+		for (ModelMetaData model : this.models.values()) {
+			if (model.hasErrors()) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
 	public String toString() {
 		return getName()+VERSION_DELIM+getVersion()+ models.values(); 
 	}

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -37,6 +37,7 @@
 import org.teiid.adminapi.VDB.Status;
 import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
 import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
  
 public class VDBMetadataMapper implements MetadataMapper<VDBMetaData> {
 	private static final String VDBNAME = "vdb-name"; //$NON-NLS-1$
@@ -213,9 +214,7 @@
 		ModelNode statusAllowed = new ModelNode();
 		statusAllowed.add(Status.ACTIVE.toString());
 		statusAllowed.add(Status.LOADING.toString());
-		statusAllowed.add(Status.INVALID.toString());
 		statusAllowed.add(Status.REMOVED.toString());
-		statusAllowed.add(Status.INCOMPLETE.toString());
 		addAttribute(node, STATUS, ModelType.STRING, true);
 		node.get(STATUS).get(ALLOWED).set(statusAllowed);
 		
@@ -475,7 +474,7 @@
 			if (error.getPath() != null) {
 				node.get(ERROR_PATH).set(error.getPath());
 			}
-			node.get(SEVERITY).set(error.getSeverity());
+			node.get(SEVERITY).set(error.getSeverity().name());
 			node.get(MESSAGE).set(error.getValue());
 			
 			return node;
@@ -491,7 +490,7 @@
 				error.setPath(node.get(ERROR_PATH).asString());
 			}
 			if (node.has(SEVERITY)) {
-				error.setSeverity(node.get(SEVERITY).asString());
+				error.setSeverity(Severity.valueOf(node.get(SEVERITY).asString()));
 			}
 			if(node.has(MESSAGE)) {
 				error.setValue(node.get(MESSAGE).asString());

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -48,6 +48,7 @@
 import org.teiid.adminapi.VDBImport;
 import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
 import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
 import org.teiid.core.types.XMLType;
 import org.xml.sax.SAXException;
 
@@ -284,7 +285,7 @@
 				String msg =  reader.getElementText();
 				String severity = validationProps.getProperty(Element.VALIDATION_SEVERITY_ATTR.getLocalName());
 				String path = validationProps.getProperty(Element.PATH.getLocalName());
-				ValidationError ve = new ValidationError(severity, msg);
+				ValidationError ve = new ValidationError(Severity.valueOf(severity), msg);
 				ve.setPath(path);
 				model.addError(ve);
 				break;
@@ -521,7 +522,7 @@
 		// model validation errors
 		for (ValidationError ve:model.getErrors(false)) {
 			writer.writeStartElement(Element.VALIDATION_ERROR.getLocalName());
-			writer.writeAttribute(Element.VALIDATION_SEVERITY_ATTR.getLocalName(), ve.getSeverity());
+			writer.writeAttribute(Element.VALIDATION_SEVERITY_ATTR.getLocalName(), ve.getSeverity().name());
 			if (ve.getPath() != null) {
 				writer.writeAttribute(Element.PATH.getLocalName(), ve.getPath());
 			}

Modified: trunk/admin/src/test/resources/vdb-describe.txt
===================================================================
--- trunk/admin/src/test/resources/vdb-describe.txt	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/admin/src/test/resources/vdb-describe.txt	2012-06-20 15:57:10 UTC (rev 4191)
@@ -27,9 +27,7 @@
         "allowed" : [
             "ACTIVE",
             "LOADING",
-            "INVALID",
-            "REMOVED",
-            "INCOMPLETE"
+            "REMOVED"
         ]
     },
     "vdb-version" : {

Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -342,7 +342,6 @@
 	public void mergeInto (MetadataStore store) {
 		store.addSchema(this.schema);
 		store.addDataTypes(this.dataTypes.values());
-		store.addNamespaces(this.namespaces);
 	}
 	
 	public MetadataStore asMetadataStore() {

Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -40,7 +40,6 @@
 	protected Map<String, Schema> schemas = new TreeMap<String, Schema>(String.CASE_INSENSITIVE_ORDER);
 	protected List<Schema> schemaList = new ArrayList<Schema>(); //used for a stable ordering
 	protected Map<String, Datatype> datatypes = new TreeMap<String, Datatype>();
-	protected Map<String, String> namespaces = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
 	
 	public Map<String, Schema> getSchemas() {
 		return schemas;
@@ -61,7 +60,7 @@
 		return schemaList;
 	}
 	
-	void addDataTypes(Collection<Datatype> types) {
+	public void addDataTypes(Collection<Datatype> types) {
 		if (types != null){
 			for (Datatype type:types) {
 				addDatatype(type);
@@ -77,18 +76,6 @@
 		return datatypes;
 	}
 	
-	public void addNamespace(String prefix, String uri) {
-		this.namespaces.put(prefix, uri);
-	}	
-	
-	public Map<String, String> getNamespaces() {
-		return this.namespaces;
-	}
-	
-	void addNamespaces(Map<String, String> namespaces) {
-		this.namespaces.putAll(namespaces);
-	}	
-	
 	public void merge(MetadataStore store) {
 		if (store != null) {
 			for (Schema s:store.getSchemaList()) {

Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html	2012-06-20 15:57:10 UTC (rev 4191)
@@ -45,6 +45,7 @@
   <li>DDL functions/procedures defined without the VIRTUAL keyword are by default VIRTUAL.  Use the FOREIGN keyword to indicate that they are source specific.
   <li>FunctionMethod.getFullName returns the proper schema, not category qualified name.
   <li>VDB.getUrl has been removed.
+  <li>VDB.Status now has three states - LOADING, ACTIVE, REMOVED.  To check for validity use the isValid method, rather than checking for the VALID state.
 <ul>
 
 <h4>from 7.x</h4>

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -27,10 +27,7 @@
 
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.api.exception.query.QueryParserException;
-import org.teiid.api.exception.query.QueryResolverException;
-import org.teiid.api.exception.query.QueryValidatorException;
-import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
 import org.teiid.language.SQLConstants;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
@@ -56,16 +53,16 @@
 public class MetadataValidator {
 	
 	interface MetadataRule {
-		void execute(VDBMetaData vdb, MetadataStore vdbStore, ValidatorReport report);
+		void execute(VDBMetaData vdb, MetadataStore vdbStore, ValidatorReport report, MetadataValidator metadataValidator);
 	}	
 	
-	public static ValidatorReport validate(VDBMetaData vdb, MetadataStore store) {
+	public ValidatorReport validate(VDBMetaData vdb, MetadataStore store) {
 		ValidatorReport report = new ValidatorReport();
 		if (store != null && !store.getSchemaList().isEmpty()) {
-			new SourceModelArtifacts().execute(vdb, store, report);
-			new ResolveQueryPlans().execute(vdb, store, report);
-			new CrossSchemaResolver().execute(vdb, store, report);
-			new MinimalMetadata().execute(vdb, store, report);
+			new SourceModelArtifacts().execute(vdb, store, report, this);
+			new ResolveQueryPlans().execute(vdb, store, report, this);
+			new CrossSchemaResolver().execute(vdb, store, report, this);
+			new MinimalMetadata().execute(vdb, store, report, this);
 		}
 		return report;
 	}
@@ -73,19 +70,19 @@
 	// At minimum the model must have table/view, procedure or function 
 	static class MinimalMetadata implements MetadataRule {
 		@Override
-		public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report) {
-			for (Schema schema:store.getSchemas().values()) {
+		public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report, MetadataValidator metadataValidator) {
+			for (Schema schema:store.getSchemaList()) {
 				ModelMetaData model = vdb.getModel(schema.getName());
 				
 				if (schema.getTables().isEmpty() 
 						&& schema.getProcedures().isEmpty()
 						&& schema.getFunctions().isEmpty()) {
-					log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31070, model.getName()));
+					metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31070, model.getName()));
 				}
 				
 				for (Table t:schema.getTables().values()) {
 					if (t.getColumns() == null || t.getColumns().size() == 0) {
-						log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31071, t.getName()));
+						metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31071, t.getName()));
 					}					
 				}
 				
@@ -95,7 +92,7 @@
 			    	ActivityReport<ReportItem> funcReport = new ActivityReport<ReportItem>("Translator metadata load " + model.getName()); //$NON-NLS-1$
 					FunctionMetadataValidator.validateFunctionMethods(schema.getFunctions().values(),report);
 					if(report.hasItems()) {
-						log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31073, funcReport));
+						metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31073, funcReport));
 					}						
 				}
 			}
@@ -105,32 +102,32 @@
 	// do not allow foreign tables, source functions in view model and vice versa 
 	static class SourceModelArtifacts implements MetadataRule {
 		@Override
-		public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report) {
-			for (Schema schema:store.getSchemas().values()) {
+		public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report, MetadataValidator metadataValidator) {
+			for (Schema schema:store.getSchemaList()) {
 				ModelMetaData model = vdb.getModel(schema.getName());
 				for (Table t:schema.getTables().values()) {
 					if (t.isVirtual() && model.isSource()) {
-						log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31074, t.getName(), model.getName()));
+						metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31074, t.getName(), model.getName()));
 					}
 					
 					if (t.isPhysical() && !model.isSource()) {
-						log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31075, t.getName(), model.getName()));
+						metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31075, t.getName(), model.getName()));
 					}
 				}
 				
 				for (Procedure p:schema.getProcedures().values()) {
 					if (p.isVirtual() && model.isSource()) {
-						log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31076, p.getName(), model.getName()));
+						metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31076, p.getName(), model.getName()));
 					}
 
 					if (!p.isVirtual() && !model.isSource()) {
-						log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31077, p.getName(), model.getName()));
+						metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31077, p.getName(), model.getName()));
 					}
 				}
 				
 				for (FunctionMethod func:schema.getFunctions().values()) {
 					if (func.getPushdown().equals(FunctionMethod.PushDown.MUST_PUSHDOWN) && !model.isSource()) {
-						log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31078, func.getName(), model.getName()));
+						metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31078, func.getName(), model.getName()));
 					}
 				}
 			}
@@ -140,8 +137,8 @@
 	// Resolves metadata query plans to make sure they are accurate
 	static class ResolveQueryPlans implements MetadataRule {
 		@Override
-		public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report) {
-			for (Schema schema:store.getSchemas().values()) {
+		public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report, MetadataValidator metadataValidator) {
+			for (Schema schema:store.getSchemaList()) {
 				ModelMetaData model = vdb.getModel(schema.getName());
 
 				for (Table t:schema.getTables().values()) {
@@ -154,10 +151,10 @@
 					}
 					if (t.isVirtual()) {
 						if (t.getSelectTransformation() == null) {
-							log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31079, t.getName(), model.getName()));
+							metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31079, t.getName(), model.getName()));
 						}
 						else {
-							validate(vdb, model, t, store, report);
+							metadataValidator.validate(vdb, model, t, store, report);
 						}
 					}						
 				}
@@ -165,10 +162,10 @@
 				for (Procedure p:schema.getProcedures().values()) {
 					if (p.isVirtual() && !p.isFunction()) {
 						if (p.getQueryPlan() == null) {
-							log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31081, p.getName(), model.getName()));
+							metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31081, p.getName(), model.getName()));
 						}
 						else {
-							validate(vdb, model, p, store, report);
+							metadataValidator.validate(vdb, model, p, store, report);
 						}
 					}
 				}					
@@ -176,13 +173,13 @@
 		}
 	}	
 	
-	private static void log(ValidatorReport report, ModelMetaData model, String msg) {
+	public void log(ValidatorReport report, ModelMetaData model, String msg) {
 		model.addRuntimeError(msg);
 		LogManager.logWarning(LogConstants.CTX_QUERY_RESOLVER, msg);
 		report.handleValidationError(msg);
 	}
 	
-    private static void validate(VDBMetaData vdb, ModelMetaData model, AbstractMetadataRecord record, MetadataStore store, ValidatorReport report) {
+    private void validate(VDBMetaData vdb, ModelMetaData model, AbstractMetadataRecord record, MetadataStore store, ValidatorReport report) {
     	QueryMetadataInterface metadata = vdb.getAttachment(QueryMetadataInterface.class);
     	metadata = new TempMetadataAdapter(metadata, new TempMetadataStore()); //TODO: optimize this
     	ValidatorReport resolverReport = null;
@@ -224,18 +221,12 @@
 					}
 				}
 			}
-		} catch (QueryParserException e) {
+		} catch (TeiidException e) {
 			log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31080, record.getFullName(), e.getFullMessage()));
-		} catch (QueryResolverException e) {
-			log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31080, record.getFullName(), e.getFullMessage()));
-		} catch (TeiidComponentException e) {
-			log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31080, record.getFullName(), e.getFullMessage()));
-		} catch (QueryValidatorException e) {
-			log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31080, record.getFullName(), e.getFullMessage()));
 		}
     }
 
-	private static Datatype getDataType(Collection<Datatype> dataTypes, Class<?> clazz) {
+	private Datatype getDataType(Collection<Datatype> dataTypes, Class<?> clazz) {
 		for (Datatype type:dataTypes) {
 			if (type.getJavaClassName().equals(clazz.getName())) {
 				return type;
@@ -244,7 +235,7 @@
 		return null;
 	}
 	
-	private static Column addColumn(String name, Datatype type, Table table) throws TranslatorException {
+	private Column addColumn(String name, Datatype type, Table table) throws TranslatorException {
 		Column column = new Column();
 		column.setName(name);
 		if (table.getColumnByName(name) != null) {
@@ -286,8 +277,8 @@
 		}
 		
 		@Override
-		public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report) {
-			for (Schema schema:store.getSchemas().values()) {
+		public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report, MetadataValidator metadataValidator) {
+			for (Schema schema:store.getSchemaList()) {
 				ModelMetaData model = vdb.getModel(schema.getName());
 
 				for (Table t:schema.getTables().values()) {
@@ -296,18 +287,18 @@
 							String matTableName = t.getMaterializedTable().getName();
 							int index = matTableName.indexOf(Table.NAME_DELIM_CHAR);
 							if (index == -1) {
-								log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31088, matTableName, t.getName()));
+								metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31088, matTableName, t.getName()));
 							}
 							else {
 								String schemaName = matTableName.substring(0, index);
 								Schema matSchema = store.getSchema(schemaName);
 								if (matSchema == null) {
-									log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31089, schemaName, matTableName, t.getName()));
+									metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31089, schemaName, matTableName, t.getName()));
 								}
 								else {
 									Table matTable = matSchema.getTable(matTableName.substring(index+1));
 									if (matTable == null) {
-										log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31090, matTableName.substring(index+1), schemaName, t.getName()));
+										metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31090, matTableName.substring(index+1), schemaName, t.getName()));
 									}
 									else {
 										t.setMaterializedTable(matTable);
@@ -329,7 +320,7 @@
 						
 						String referenceTableName = fk.getReferenceTableName();
 						if (referenceTableName == null){
-							log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31091, t.getName()));
+							metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31091, t.getName()));
 							continue;
 						}
 						
@@ -343,21 +334,21 @@
 							referenceSchemaName = referenceTableName.substring(0, index);
 							Schema referenceSchema = store.getSchema(referenceSchemaName);
 							if (referenceSchema == null) {
-								log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31093, referenceSchemaName, t.getName()));
+								metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31093, referenceSchemaName, t.getName()));
 								continue;
 							}
 							referenceTable = referenceSchema.getTable(referenceTableName.substring(index+1));
 						}
 						
 						if (referenceTable == null) {
-							log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31092, t.getName(), referenceTableName.substring(index+1), referenceSchemaName));
+							metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31092, t.getName(), referenceTableName.substring(index+1), referenceSchemaName));
 							continue;
 						}
 
 						KeyRecord uniqueKey = null;
 						if (fk.getReferenceColumns() == null || fk.getReferenceColumns().isEmpty()) {
 							if (referenceTable.getPrimaryKey() == null) {
-								log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31094, t.getName(), referenceTableName.substring(index+1), referenceSchemaName));
+								metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31094, t.getName(), referenceTableName.substring(index+1), referenceSchemaName));
 							}
 							else {
 								uniqueKey = referenceTable.getPrimaryKey();										
@@ -375,7 +366,7 @@
 							}
 						}
 						if (uniqueKey == null) {
-							log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31095, t.getName(), referenceTableName.substring(index+1), referenceSchemaName, fk.getReferenceColumns()));
+							metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31095, t.getName(), referenceTableName.substring(index+1), referenceSchemaName, fk.getReferenceColumns()));
 						}
 						else {
 							fk.setPrimaryKey(uniqueKey);

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -275,7 +275,11 @@
 
     public List<Column> getElementIDsInGroupID(final Object groupID) throws TeiidComponentException, QueryMetadataException {
     	ArgCheck.isInstanceOf(Table.class, groupID);
-    	return ((Table)groupID).getColumns();
+    	List<Column> columns = ((Table)groupID).getColumns();
+    	if (columns == null || columns.isEmpty()) {
+    		throw new QueryMetadataException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31071, ((Table)groupID).getName()));
+    	}
+    	return columns;
     }
 
     public Object getGroupIDForElementID(final Object elementID) throws TeiidComponentException, QueryMetadataException {

Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -117,7 +117,7 @@
         
 		TupleBatch batch = plan.nextBatch();
        
-        for (List tuple : batch.getTuples()) {
+        for (List<?> tuple : batch.getTuples()) {
             addBatchRow(tuple);
 		}
         
@@ -132,6 +132,11 @@
         return pullBatch();
 	}
 
+    /**
+	 * @throws BlockedException  
+     * @throws TeiidComponentException 
+     * @throws TeiidProcessingException 
+	 */
     protected boolean prepareNextCommand() throws BlockedException,
                                           TeiidComponentException, TeiidProcessingException {
         return true;

Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-06-20 15:57:10 UTC (rev 4191)
@@ -988,7 +988,7 @@
 TEIID31071=Invalid table; Table {0} has no columns defined
 TEIID31072=Invalid Procedure {0}; No return has been defined.
 TEIID31073=Invalid functions; {0}
-TEIID31074=View table {0} is only allowed in VIRTUAL Model; {0} is defined as PHYSICAL model
+TEIID31074=View table {0} is only allowed in VIRTUAL Model; {1} is defined as PHYSICAL model
 TEIID31075=Foreign table {0} is only allowed to be defined on PHYSICAL model; {1} is defined as VIRTUAL model.
 TEIID31076=Virtual procedure {0} is only allowed to be defined on VIRTUAL model; {1} is defined as PHYSICAL model.
 TEIID31077=Source Stored procedure {0} is only allowed to be defined on PHYSICAL model; {1} is defined as VIRTUAL model.

Modified: trunk/engine/src/test/java/org/teiid/query/metadata/TestMetadataValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/metadata/TestMetadataValidator.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/engine/src/test/java/org/teiid/query/metadata/TestMetadataValidator.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -75,7 +75,7 @@
 		String ddl = "create foreign table g1(e1 integer, e2 varchar(12)); create view g2(e1 integer, e2 varchar(12)) AS select * from foo;";
 		buildModel("pm1", true, this.vdb, this.store, ddl);
 		ValidatorReport report = new ValidatorReport();
-		new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report);
+		new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report, new MetadataValidator());
 		assertTrue(printError(report), report.hasItems());
 	}
 
@@ -95,7 +95,7 @@
 		String ddl = "create foreign table g1(e1 integer, e2 varchar(12)); create view g2(e1 integer, e2 varchar(12)) AS select * from foo;";
 		buildModel("vm1", false, this.vdb, this.store, ddl);
 		ValidatorReport report = new ValidatorReport();
-		new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report);
+		new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report, new MetadataValidator());
 		assertTrue(printError(report), report.hasItems());
 	}
 	
@@ -104,7 +104,7 @@
 		buildModel("vm1", false, this.vdb, this.store, "create view g2(e1 integer, e2 varchar(12)) AS select * from foo;");
 		buildModel("pm1", true, this.vdb, this.store, "create foreign table g1(e1 integer, e2 varchar(12));");
 		ValidatorReport report = new ValidatorReport();
-		new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report);
+		new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report, new MetadataValidator());
 		assertFalse(printError(report), report.hasItems());	
 	}
 	
@@ -112,7 +112,7 @@
 	public void testMinimalDataNoColumns() throws Exception {
 		buildModel("pm1", true, this.vdb, this.store, "create foreign table g1;");
 		ValidatorReport report = new ValidatorReport();
-		new MetadataValidator.MinimalMetadata().execute(vdb, store, report);
+		new MetadataValidator.MinimalMetadata().execute(vdb, store, report, new MetadataValidator());
 		assertTrue(printError(report), report.hasItems());		
 	}
 	
@@ -126,7 +126,7 @@
 		buildModel("vm1", false, this.vdb, this.store, ddl);
 		buildTransformationMetadata();
 		ValidatorReport report = new ValidatorReport();
-		new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report);
+		new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator());
 		assertTrue(printError(report), report.hasItems());			
 	}
 	
@@ -136,7 +136,7 @@
 		buildModel("vm1", false, this.vdb, this.store, ddl);
 		buildTransformationMetadata();
 		ValidatorReport report = new ValidatorReport();
-		new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report);
+		new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator());
 		assertFalse(printError(report), report.hasItems());			
 	}
 	
@@ -146,7 +146,7 @@
 		buildModel("vm1", false, this.vdb, this.store, ddl);
 		buildTransformationMetadata();
 		ValidatorReport report = new ValidatorReport();
-		new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report);
+		new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator());
 		assertFalse(printError(report), report.hasItems());			
 	}
 	
@@ -155,7 +155,7 @@
 		buildModel("vm1", false, this.vdb, this.store, "create view g1 (e1 integer, e2 varchar(12)) AS select * from pm1.g1; create view g2 AS select * from pm1.g1;");
 		buildTransformationMetadata();
 		ValidatorReport report = new ValidatorReport();
-		new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report);
+		new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator());
 		assertTrue(printError(report), report.hasItems());		
 	}
 	
@@ -170,7 +170,7 @@
 		buildTransformationMetadata();
 		
 		ValidatorReport report = new ValidatorReport();
-		report = MetadataValidator.validate(this.vdb, this.store);
+		report = new MetadataValidator().validate(this.vdb, this.store);
 		assertFalse(printError(report), report.hasItems());
 		
 		assertNotNull(this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getPrimaryKey());
@@ -189,7 +189,7 @@
 		buildTransformationMetadata();
 		
 		ValidatorReport report = new ValidatorReport();
-		report = MetadataValidator.validate(this.vdb, this.store);
+		report = new MetadataValidator().validate(this.vdb, this.store);
 		assertFalse(printError(report), report.hasItems());
 		
 		assertNotNull(this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getPrimaryKey());
@@ -208,7 +208,7 @@
 		buildTransformationMetadata();
 		
 		ValidatorReport report = new ValidatorReport();
-		report = MetadataValidator.validate(this.vdb, this.store);
+		report = new MetadataValidator().validate(this.vdb, this.store);
 		assertFalse(printError(report), report.hasItems());
 		
 		assertNotNull(this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getPrimaryKey());
@@ -228,7 +228,7 @@
 		buildTransformationMetadata();
 		
 		ValidatorReport report = new ValidatorReport();
-		report = MetadataValidator.validate(this.vdb, this.store);
+		report = new MetadataValidator().validate(this.vdb, this.store);
 		assertTrue(printError(report), report.hasItems());
 	}	
 	
@@ -245,7 +245,7 @@
 		buildTransformationMetadata();
 		
 		ValidatorReport report = new ValidatorReport();
-		report = MetadataValidator.validate(this.vdb, this.store);
+		report = new MetadataValidator().validate(this.vdb, this.store);
 		assertFalse(printError(report), report.hasItems());
 	}	
 	
@@ -261,7 +261,7 @@
 		buildTransformationMetadata();
 		
 		ValidatorReport report = new ValidatorReport();
-		report = MetadataValidator.validate(this.vdb, this.store);
+		report = new MetadataValidator().validate(this.vdb, this.store);
 		assertFalse(printError(report), report.hasItems());
 		assertNotNull("pm1.G1", store.getSchema("vm1").getTable("G2").getMaterializedTable());
 		assertEquals("G1", store.getSchema("vm1").getTable("G2").getMaterializedTable().getName());
@@ -293,8 +293,7 @@
 		
 		buildTransformationMetadata();
 		
-		ValidatorReport report = new ValidatorReport();
-		report = MetadataValidator.validate(this.vdb, this.store);
+		ValidatorReport report = new MetadataValidator().validate(this.vdb, this.store);
 		assertFalse(printError(report), report.hasItems());
 	}	
 }

Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestDDLParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestDDLParser.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestDDLParser.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -244,7 +244,7 @@
 		modelOne.setName("model"); //$NON-NLS-1$
 		vdb.addModel(modelOne);
 
-		ValidatorReport report = MetadataValidator.validate(vdb, s.asMetadataStore());
+		ValidatorReport report = new MetadataValidator().validate(vdb, s.asMetadataStore());
 		
 		assertFalse(report.hasItems());
 		
@@ -275,7 +275,7 @@
 		modelOne.setName("model"); //$NON-NLS-1$
 		vdb.addModel(modelOne);
 
-		ValidatorReport report = MetadataValidator.validate(vdb, s.asMetadataStore());
+		ValidatorReport report = new MetadataValidator().validate(vdb, s.asMetadataStore());
 		
 		assertTrue(report.hasItems());
 	}	
@@ -304,7 +304,7 @@
 		MetadataStore s = f1.asMetadataStore();
 		f2.mergeInto(s);
 
-		ValidatorReport report = MetadataValidator.validate(vdb, s);
+		ValidatorReport report = new MetadataValidator().validate(vdb, s);
 		
 		assertFalse(report.hasItems());
 		
@@ -316,17 +316,13 @@
 		assertEquals(fk.getPrimaryKey().getColumns(), s.getSchema("model").getTable("G1").getColumns());
 	}	
 	
-	@Test
+	@Test(expected=ParseException.class)
 	public void testViewWithoutPlan() throws Exception {
 		String ddl = "CREATE View G1( e1 integer, e2 varchar)";
-		try {
-			MetadataStore mds = new MetadataStore();
-			MetadataFactory mf = new MetadataFactory(null, 1, "model", getDataTypes(), new Properties(), null); 
-			parser.parseDDL(mf,ddl);
-			mf.mergeInto(mds);
-			fail("should fail define a view with out a plan");
-		} catch(ParseException e) {
-		}
+		MetadataStore mds = new MetadataStore();
+		MetadataFactory mf = new MetadataFactory(null, 1, "model", getDataTypes(), new Properties(), null); 
+		parser.parseDDL(mf,ddl);
+		mf.mergeInto(mds);
 	}	
 	
 	@Test
@@ -618,8 +614,8 @@
 		parser.parseDDL(mf, ddl);
 		mf.mergeInto(mds);
 		
-		assertTrue(mds.getNamespaces().keySet().contains("teiid"));
-		assertEquals("http://teiid.org", mds.getNamespaces().get("teiid"));
+		assertTrue(mf.getNamespaces().keySet().contains("teiid"));
+		assertEquals("http://teiid.org", mf.getNamespaces().get("teiid"));
 	}		
 
 	public static MetadataFactory helpParse(String ddl, String model) throws ParseException {

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -92,11 +92,8 @@
         }
 		
 		boolean preview = deployment.isPreview();
-		if (!preview) {
-			List<String> errors = deployment.getValidityErrors();
-			if (errors != null && !errors.isEmpty()) {
-				throw new DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50074, deployment));
-			}
+		if (!preview && deployment.hasErrors()) {
+			throw new DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50074, deployment));
 		}
 		
 		// make sure the translator defined exists in configuration; otherwise add as error

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -52,7 +52,6 @@
 import org.jboss.msc.value.InjectedValue;
 import org.teiid.adminapi.AdminProcessingException;
 import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.VDB;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.adminapi.impl.VDBMetadataParser;
@@ -245,10 +244,7 @@
 			this.objectReplicatorInjector.getValue().stop(gts);
 		}		
 		getVDBRepository().removeListener(this.vdbListener);
-		VDBMetaData runtimeMetadata = getVDBRepository().removeVDB(this.vdb.getName(), this.vdb.getVersion());
-		if (runtimeMetadata != null) {
-			runtimeMetadata.setStatus(VDB.Status.REMOVED);
-		}
+		getVDBRepository().removeVDB(this.vdb.getName(), this.vdb.getVersion());
 		final ServiceController<?> controller = context.getController().getServiceContainer().getService(TeiidServiceNames.vdbFinishedServiceName(vdb.getName(), vdb.getVersion()));
         if (controller != null) {
             controller.setMode(ServiceController.Mode.REMOVE);

Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -37,7 +37,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.concurrent.Semaphore;
 
 import org.jboss.vfs.VirtualFile;
 import org.jboss.vfs.VirtualFileFilter;
@@ -149,7 +148,6 @@
 	private HashSet<VirtualFile> indexFiles = new HashSet<VirtualFile>();
 	private LinkedHashMap<String, Resource> vdbEntries;
 	private boolean loaded = false;
-	private Semaphore lock = new Semaphore(1);
 	
 	public IndexMetadataStore() {
 		
@@ -221,62 +219,57 @@
     		}
     	}
     }
-    public void load(Collection<Datatype> systemDatatypes) throws IOException {
-    	load(null, systemDatatypes);
-    	Collection<AbstractMetadataRecord> modelRecords = getByType(MetadataConstants.RECORD_TYPE.MODEL).values();
-    	for (AbstractMetadataRecord record:modelRecords) {
-    		Schema s = (Schema) record;
-    		load(s.getName(), systemDatatypes);
-    	}
-    }
     
 	public void load(String modelName, Collection<Datatype> systemDatatypes) throws IOException {
 		// there are multiple threads trying to load this, since the initial index lading is not 
 		// optimized for multi-thread loading this locking to sync will work
-		try {
-			this.lock.acquire();
-		} catch (InterruptedException e) {
-		}
-		
-		if (!this.loaded) {
-			if (systemDatatypes == null) {
-				loadSystemDatatypes(this);
-			}
-	    	ArrayList<Index> tmp = new ArrayList<Index>();
-			for (VirtualFile f : indexFiles) {
-				Index index = new Index(f, true);
-				index.setDoCache(true);
-	            tmp.add(index);
-			}
-			this.indexes = tmp.toArray(new Index[tmp.size()]);
-			loadAll();
-			//force close, since we cached the index files
-			for (Index index : tmp) {
-				index.close(); 
-			}
-			Map<String, AbstractMetadataRecord> uuidToRecord = getByType(MetadataConstants.RECORD_TYPE.DATATYPE);
-			if (systemDatatypes != null) {
-				for (Datatype datatype : systemDatatypes) {
-					uuidToRecord.put(datatype.getUUID(), datatype);
+		synchronized (this) {
+			if (!this.loaded) {
+				if (systemDatatypes == null) {
+					loadSystemDatatypes(this);
 				}
-			} else {
-				for (Datatype datatype : getDatatypes().values()) {
-					uuidToRecord.put(datatype.getUUID(), datatype);
+		    	ArrayList<Index> tmp = new ArrayList<Index>();
+				for (VirtualFile f : indexFiles) {
+					Index index = new Index(f, true);
+					index.setDoCache(true);
+		            tmp.add(index);
 				}
+				this.indexes = tmp.toArray(new Index[tmp.size()]);
+				loadAll();
+				//force close, since we cached the index files
+				for (Index index : tmp) {
+					index.close(); 
+				}
+				Map<String, AbstractMetadataRecord> uuidToRecord = getByType(MetadataConstants.RECORD_TYPE.DATATYPE);
+				if (systemDatatypes != null) {
+					for (Datatype datatype : systemDatatypes) {
+						uuidToRecord.put(datatype.getUUID(), datatype);
+					}
+				} else {
+					for (Datatype datatype : getDatatypes().values()) {
+						uuidToRecord.put(datatype.getUUID(), datatype);
+					}
+				}
+				for (AbstractMetadataRecord datatypeRecordImpl : uuidToRecord.values()) {
+					addDatatype((Datatype) datatypeRecordImpl);
+				}
+				this.loaded = true;
 			}
-			for (AbstractMetadataRecord datatypeRecordImpl : uuidToRecord.values()) {
-				addDatatype((Datatype) datatypeRecordImpl);
-			}
-			this.loaded = true;
 		}
 		
-		this.lock.release();
-
-		if (this.loaded) {
-			getModels(modelName);
-			getTables(modelName);
-			getProcedures(modelName);
-		}
+    	// the index map below is keyed by uuid not modelname, so map lookup is not possible
+    	Collection<AbstractMetadataRecord> modelRecords = getByType(MetadataConstants.RECORD_TYPE.MODEL).values();
+    	for (AbstractMetadataRecord modelRecord:modelRecords) {
+    		Schema s = (Schema) modelRecord;
+    		if (modelName == null || s.getName().equalsIgnoreCase(modelName)) {
+    			addSchema(s);
+    			getTables(s);
+    			getProcedures(s);
+    			if (modelName != null) {
+    				break;
+    			}
+    		}
+    	}
     }
 
 	public static void loadSystemDatatypes(MetadataStore ms) throws IOException {
@@ -357,25 +350,24 @@
 		return this.vdbEntries;
 	}
 	
-    private void getModels(String modelName) {
-    	// the index map below is keyed by uuid not modelname, so map lookup is not possible
-    	Collection<AbstractMetadataRecord> modelRecords = getByType(MetadataConstants.RECORD_TYPE.MODEL).values();
-    	for (AbstractMetadataRecord modelRecord:modelRecords) {
-    		Schema s = (Schema) modelRecord;
-    		if (s.getName().equalsIgnoreCase(modelName)) {
-    			addSchema((Schema) modelRecord);
-    		}
-    	}
+	/**
+	 * override for thread safety
+	 */
+    @Override
+    public synchronized void addSchema(Schema schema) {
+    	super.addSchema(schema);
     }
+
+	/**
+	 * override for thread safety
+	 */
+    @Override
+    public synchronized Schema getSchema(String name) {
+    	return super.getSchema(name);
+    }
     
-    private void getTables(String modelName) {
-    	Schema model  = getSchemas().get(modelName);
-    	
-    	if (model == null) {
-    		return;
-    	}
-    	
-    	Map<Character, List<AbstractMetadataRecord>> entries = schemaEntries.get(modelName);
+    private void getTables(Schema model) {
+    	Map<Character, List<AbstractMetadataRecord>> entries = schemaEntries.get(model.getName());
 		if (entries == null) {
 			return;
 		}
@@ -495,12 +487,7 @@
         return record;
     }
     
-    private void getProcedures(String modelName) {
-    	Schema model  = getSchemas().get(modelName);
-    	if (model == null) {
-    		return;
-    	}
-    	
+    private void getProcedures(Schema model) {
 		Map<Character, List<AbstractMetadataRecord>> entries = schemaEntries.get(model.getName());
 		if (entries == null) {
 			return;

Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -112,7 +112,7 @@
     		// it is hard to event when the test is done, otherwise we need to elevate the VFS to top
     	}
     	IndexMetadataStore store =  new IndexMetadataStore(root);
-    	store.load(dataTypes);
+    	store.load(null, dataTypes);
     	return store;
 
 	}	

Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -206,20 +206,26 @@
 	}
 	
 	private MetadataStore getMetadataStore() {
-		if (this.children == null || this.children.isEmpty()) {
-			return this.store;
-		}		
-		
 		MetadataStore mergedStore = new MetadataStore();
 		if (this.store != null) {
-			mergedStore.merge(this.store);
+			//the order of the models is important for resolving ddl
+			//TODO we might consider not using the intermediate MetadataStore
+			for (ModelMetaData model : this.vdb.getModelMetaDatas().values()) {
+				Schema s = this.store.getSchemas().get(model.getName());
+				if (s != null) {
+					mergedStore.addSchema(s);					
+				}
+			}
+			mergedStore.addDataTypes(store.getDatatypes().values());
 		}
-		for (CompositeVDB child:this.children.values()) {
-			MetadataStore childStore = child.getMetadataStore();
-			if ( childStore != null) {
-				mergedStore.merge(childStore);
-			}
-		}		
+		if (this.children != null && !this.children.isEmpty()) {
+			for (CompositeVDB child:this.children.values()) {
+				MetadataStore childStore = child.getMetadataStore();
+				if ( childStore != null) {
+					mergedStore.merge(childStore);
+				}
+			}		
+		}
 		return mergedStore;
 	}
 		

Modified: trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -63,7 +63,7 @@
 			}
 			
 			IndexMetadataStore idxStore = new IndexMetadataStore(mountPoint);
-			idxStore.load(null);
+			idxStore.load(null, null);
 			
 			// uri conversion is only to remove the spaces in URL, note this only with above kind situation  
 			this.vdbRepository.setSystemStore(idxStore);

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -35,7 +35,7 @@
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.VDB.Status;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.SourceMappingMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
@@ -250,10 +250,15 @@
 	
 	public VDBMetaData removeVDB(String vdbName, int vdbVersion) {
 		VDBKey key = new VDBKey(vdbName, vdbVersion);
+		return removeVDB(key);
+	}
+
+	private VDBMetaData removeVDB(VDBKey key) {
 		CompositeVDB removed = this.vdbRepo.remove(key);
 		if (removed == null) {
 			return null;
 		}
+		removed.getVDB().setStatus(Status.REMOVED);
 		notifyRemove(key.getName(), key.getVersion(), removed);
 		return removed.getVDB();
 	}	
@@ -270,40 +275,40 @@
 	}
 	
 	public void finishDeployment(String name, int version) {
-		CompositeVDB v = this.vdbRepo.get(new VDBKey(name, version));
+		VDBKey key = new VDBKey(name, version);
+		CompositeVDB v = this.vdbRepo.get(key);
 		if (v == null) {
 			return;
 		}
-		boolean valid = false;
 		v.metadataLoadFinished();
-		VDBMetaData metdataAwareVDB = v.getVDB();			
-		synchronized (metdataAwareVDB) {
-			ValidatorReport report = MetadataValidator.validate(metdataAwareVDB, metdataAwareVDB.removeAttachment(MetadataStore.class));
-			
-			if (!report.hasItems()) {
-				valid  = true;					
-			}
-			else {
-				LogManager.logWarning(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version));
-			}
-			
-			// check the data sources available
-			if (valid) {
-				valid = hasValidDataSources(metdataAwareVDB);
-			}
-			
-			if (valid) {
-				metdataAwareVDB.setStatus(VDB.Status.ACTIVE);
-			}
-			else {
-				metdataAwareVDB.setStatus(VDB.Status.INVALID);
-			}
-			LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,name, version, metdataAwareVDB.getStatus()));
+		VDBMetaData metadataAwareVDB = v.getVDB();			
+		synchronized (metadataAwareVDB) {
+			ValidatorReport report = new MetadataValidator().validate(metadataAwareVDB, metadataAwareVDB.removeAttachment(MetadataStore.class));
+
+			if (report.hasItems()) {
+				LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version));
+				if (!v.getVDB().isPreview()) {
+					processMetadataValidatorReport(key, report);
+					if (v.getVDB().getStatus() == Status.REMOVED) {
+						return;
+					}
+				}
+			} 
+			metadataAwareVDB.setStatus(Status.ACTIVE);
+			LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,name, version, metadataAwareVDB.getStatus()));
 			notifyFinished(name, version, v);
 		}
 	}
 	
-	boolean hasValidDataSources(VDBMetaData vdb) {
+	/**
+	 * @param key 
+	 * @param report  
+	 */
+	protected void processMetadataValidatorReport(VDBKey key, ValidatorReport report) {
+		this.removeVDB(key);
+	}
+
+	void validateDataSources(VDBMetaData vdb) {
 		ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
 		
 		for (ModelMetaData model:vdb.getModelMetaDatas().values()) {
@@ -321,7 +326,6 @@
 				}
 	    	}			
 		}
-		return vdb.getValidityErrors().isEmpty();
 	}
 	
 	

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -27,7 +27,6 @@
 import org.teiid.adminapi.AdminProcessingException;
 import org.teiid.adminapi.Model;
 import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.VDB.Status;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.adminapi.impl.VDBTranslatorMetaData;
@@ -84,7 +83,6 @@
 			
 			boolean dsReplaced = false;
 			if (!cm.getConnectionName().equals(dsName)){
-				markInvalid(vdb);
 				String msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40076, vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName), dsName);
 				model.addRuntimeError(msg);
 				cm = new ConnectorManager(translatorName, dsName); 
@@ -119,14 +117,6 @@
 		}
 	}
 
-	private void markInvalid(VDBMetaData vdb) {
-		if (vdb.getStatus() == Status.LOADING) {
-			vdb.setStatus(Status.INCOMPLETE);
-		} else if (vdb.getStatus() == Status.ACTIVE){
-			vdb.setStatus(Status.INVALID);
-		}
-	}
-	
 	public void resourceAdded(String resourceName, boolean translator) {
 		for (VDBMetaData vdb:getVDBRepository().getVDBs()) {
 			if (vdb.getStatus() == VDB.Status.ACTIVE) {
@@ -150,7 +140,7 @@
 					String status = cm.getStausMessage();
 					if (status != null && status.length() > 0) {
 						model.addRuntimeError(status);
-						LogManager.logInfo(LogConstants.CTX_RUNTIME, status);					
+						LogManager.logInfo(LogConstants.CTX_RUNTIME, status);
 					} else {
 						//get the pending metadata load
 						Runnable r = model.removeAttachment(Runnable.class);
@@ -176,11 +166,6 @@
 						getExecutor().execute(runnable);
 					}
 				} else if (valid) {
-					if (vdb.getStatus() == Status.INVALID) {
-						vdb.setStatus(VDB.Status.ACTIVE);
-					} else {
-						vdb.setStatus(VDB.Status.LOADING);
-					}
 					LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,vdb.getName(), vdb.getVersion(), vdb.getStatus()));
 				}
 			}
@@ -195,7 +180,6 @@
 					
 					String sourceName = getSourceName(resourceName, model, translator);
 					if (sourceName != null) {
-						markInvalid(vdb);
 						String msg = null;
 						if (translator) {
 							msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40005, vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName));

Modified: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -54,6 +54,7 @@
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.common.buffer.TupleBufferCache;
 import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.BundleUtil.Event;
 import org.teiid.deployers.CompositeVDB;
 import org.teiid.deployers.UDFMetaData;
 import org.teiid.deployers.VDBLifeCycleListener;
@@ -92,6 +93,8 @@
 import org.teiid.query.metadata.TransformationMetadata.Resource;
 import org.teiid.query.tempdata.GlobalTableStore;
 import org.teiid.query.tempdata.GlobalTableStoreImpl;
+import org.teiid.query.validator.ValidatorFailure;
+import org.teiid.query.validator.ValidatorReport;
 import org.teiid.services.AbstractEventDistributorFactoryService;
 import org.teiid.services.BufferServiceImpl;
 import org.teiid.services.SessionServiceImpl;
@@ -102,6 +105,7 @@
 import org.teiid.transport.ClientServiceRegistryImpl;
 import org.teiid.transport.LocalServerConnection;
 import org.teiid.transport.LogonImpl;
+import org.teiid.vdb.runtime.VDBKey;
 
 /**
  * A simplified server environment for embedded use.
@@ -189,8 +193,28 @@
 
 	}
 	
+	private static class VDBValidationError extends TeiidRuntimeException {
+		
+		private VDBValidationError(Event event, String message) {
+			super(event, message);
+		}
+	}
+	
 	protected DQPCore dqp = new DQPCore();
-	protected VDBRepository repo = new VDBRepository();
+	/**
+	 * Custom vdb repository that will immediately throw exceptions for metadata validation errors
+	 */
+	protected VDBRepository repo = new VDBRepository() {
+		@Override
+		protected void processMetadataValidatorReport(VDBKey key, ValidatorReport report) {
+			if (throwMetadataErrors) {
+				super.processMetadataValidatorReport(key, report); //remove
+				ValidatorFailure firstFailure = report.getItems().iterator().next();
+				throw new VDBValidationError(RuntimePlugin.Event.TEIID40095, firstFailure.getMessage());
+			}
+		}
+	};
+	protected boolean throwMetadataErrors = true;
 	private ConcurrentHashMap<String, ExecutionFactory<?, ?>> translators = new ConcurrentHashMap<String, ExecutionFactory<?, ?>>();
 	private ConcurrentHashMap<String, ConnectionFactoryProvider<?>> connectionFactoryProviders = new ConcurrentHashMap<String, ConnectionFactoryProvider<?>>();
 	protected SessionServiceImpl sessionService = new SessionServiceImpl();
@@ -442,20 +466,24 @@
 	 * @throws VirtualDatabaseException
 	 * @throws TranslatorException
 	 */
-	public void deployVDB(String name, List<ModelMetaData> models)
+	public void deployVDB(String name, ModelMetaData... models)
 			throws ConnectorManagerException, VirtualDatabaseException, TranslatorException {
 		checkStarted();
 		VDBMetaData vdb = new VDBMetaData();
 		vdb.setDynamic(true);
 		vdb.setName(name);
-		vdb.setModels(models);
+		vdb.setModels(Arrays.asList(models));
 		cmr.createConnectorManagers(vdb, this);
 		MetadataStore metadataStore = new MetadataStore();
 		UDFMetaData udfMetaData = new UDFMetaData();
 		udfMetaData.setFunctionClassLoader(Thread.currentThread().getContextClassLoader());
 		this.assignMetadataRepositories(vdb, null);
 		repo.addVDB(vdb, metadataStore, new LinkedHashMap<String, Resource>(), udfMetaData, cmr);
-		this.loadMetadata(vdb, cmr, metadataStore);
+		try {
+			this.loadMetadata(vdb, cmr, metadataStore);
+		} catch (VDBValidationError e) {
+			throw new VirtualDatabaseException(RuntimePlugin.Event.valueOf(e.getCode()), e.getMessage());
+		}
 	}
 	
 	/**

Modified: trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -107,6 +107,6 @@
     	TEIID40092,
     	TEIID40093, //no sources
     	TEIID40094, //invalid metadata repso
-    	
+    	TEIID40095, //deployment failed
     }
 }

Modified: trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -27,7 +27,6 @@
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.Statement;
-import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -36,6 +35,7 @@
 import org.junit.Test;
 import org.teiid.adminapi.Model.Type;
 import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.deployers.VirtualDatabaseException;
 import org.teiid.jdbc.TeiidDriver;
 import org.teiid.language.Command;
 import org.teiid.language.QueryExpression;
@@ -173,7 +173,7 @@
 		mmd1.setSchemaSourceType("ddl");
 		mmd1.setSchemaText("create view \"my-view\" OPTIONS (UPDATABLE 'true') as select * from \"my-table\"");
 
-		es.deployVDB("test", Arrays.asList(mmd, mmd1));
+		es.deployVDB("test", mmd, mmd1);
 		
 		TeiidDriver td = es.getDriver();
 		Connection c = td.connect("jdbc:teiid:test", null);
@@ -185,5 +185,47 @@
 		s.execute("update \"my-view\" set \"my-column\" = 'a'");
 		assertEquals(2, s.getUpdateCount());
 	}
+	
+	@Test(expected=VirtualDatabaseException.class) public void testDeploymentError() throws Exception {
+		EmbeddedConfiguration ec = new EmbeddedConfiguration();
+		ec.setUseDisk(false);
+		es.start(ec);
+		
+		ModelMetaData mmd1 = new ModelMetaData();
+		mmd1.setName("virt");
+		mmd1.setModelType(Type.VIRTUAL);
+		mmd1.setSchemaSourceType("ddl");
+		mmd1.setSchemaText("create view \"my-view\" OPTIONS (UPDATABLE 'true') as select * from \"my-table\"");
 
+		es.deployVDB("test", mmd1);
+	}
+	
+	@Test public void testValidationOrder() throws Exception {
+		EmbeddedConfiguration ec = new EmbeddedConfiguration();
+		ec.setUseDisk(false);
+		es.start(ec);
+		
+		ModelMetaData mmd1 = new ModelMetaData();
+		mmd1.setName("b");
+		mmd1.setModelType(Type.VIRTUAL);
+		mmd1.setSchemaSourceType("ddl");
+		mmd1.setSchemaText("create view v as select 1");
+
+		ModelMetaData mmd2 = new ModelMetaData();
+		mmd2.setName("a");
+		mmd2.setModelType(Type.VIRTUAL);
+		mmd2.setSchemaSourceType("ddl");
+		mmd2.setSchemaText("create view v1 as select * from v");
+
+		//We need mmd1 to validate before mmd2, reversing the order will result in an exception
+		es.deployVDB("test", mmd1, mmd2);
+		
+		try {
+			es.deployVDB("test2", mmd2, mmd1);
+			fail();
+		} catch (VirtualDatabaseException e) {
+			
+		}
+	}
+
 }

Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -27,6 +27,7 @@
 import org.teiid.adminapi.Admin;
 import org.teiid.adminapi.AdminException;
 import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.VDB.Status;
 
 @SuppressWarnings("nls")
 public class AdminUtil {
@@ -71,7 +72,7 @@
 				first = false;
 			}
 			VDB vdb = admin.getVDB(vdbName, vdbVersion);
-			if (vdb != null && !vdb.getStatus().isLoading()) {
+			if (vdb != null && vdb.getStatus() != Status.LOADING) {
 				return true;
 			}
 		} while (System.currentTimeMillis() < waitUntil);

Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -86,7 +86,7 @@
 		VDB vdb = admin.getVDB("bqt", 1);
 		assertFalse(vdb.isValid());
 		assertTrue(AdminUtil.waitForVDBLoad(admin, "bqt", 1, 3));
-		assertEquals(Status.INVALID, vdb.getStatus());
+		assertFalse(vdb.isValid());
 
 		Properties props = new Properties();
 		props.setProperty("connection-url","jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
@@ -105,7 +105,6 @@
 		admin.deleteDataSource("Oracle11_PushDS");
 		vdb = admin.getVDB("bqt", 1);
 		assertFalse(vdb.isValid());
-		assertEquals(Status.INVALID, vdb.getStatus());
 	}
 
 	@Test

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	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -30,6 +30,7 @@
 import javax.transaction.TransactionManager;
 
 import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.Model.Type;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.VDBImportMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
@@ -191,6 +192,7 @@
 
 	private ModelMetaData addModel(VDBMetaData vdbMetaData, Schema schema) {
 		ModelMetaData model = new ModelMetaData();
+		model.setModelType(schema.isPhysical()?Type.PHYSICAL:Type.VIRTUAL);
 		model.setName(schema.getName());
 		vdbMetaData.addModel(model);
 		model.addSourceMapping("source", "translator", "jndi:source");
@@ -213,4 +215,8 @@
 		return services;
 	}
 	
+	public void setThrowMetadataErrors(boolean throwMetadataErrors) {
+		this.throwMetadataErrors = throwMetadataErrors;
+	}
+	
 }

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -26,7 +26,9 @@
 import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.teiid.core.util.UnitTestUtil;
 
@@ -37,12 +39,20 @@
 public class TestCase3473 {
 
     private DatabaseMetaData dbmd;
+    private static FakeServer server;
+    
+    @BeforeClass public static void oneTimeSetup() throws Exception {
+    	server = new FakeServer(true);
+    	server.deployVDB("test", UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb");
+    }
+    
+    @AfterClass public static void oneTimeTeardown() throws Exception {
+    	server.stop();
+    }
  
     ////////////////////Query Related Methods///////////////////////////
 
     @Before public void setUp() throws Exception {
-    	FakeServer server = new FakeServer(true);
-    	server.deployVDB("test", UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb");
     	Connection conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$
     	dbmd = conn.getMetaData();
     }

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -179,7 +179,7 @@
     	MetadataFactory m2 = createMetadataFactory("portfolio", new Properties());
 
     	QueryParser.getQueryParser().parseDDL(m2, ddl2);
-    	
+    	m2.getSchema().setPhysical(false);
     	m2.mergeInto(ms);
     	
     	server.deployVDB("test", ms);

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -119,7 +119,7 @@
     static Connection conn = null;
     
     DatabaseMetaData dbmd;
-    private Map expectedMap = new HashMap();
+    private Map<String, Object> expectedMap = new HashMap<String, Object>();
 
     // constant 
     private static final int NO_LIMIT = 0;
@@ -147,6 +147,7 @@
     @BeforeClass
     public static void oneTimeSetUp() throws Exception {
     	FakeServer server = new FakeServer(true);
+    	server.setThrowMetadataErrors(false); //there are invalid views due to aggregate datatype changes
     	server.deployVDB("QT_Ora9DS", UnitTestUtil.getTestDataPath()+"/QT_Ora9DS_1.vdb");
         conn = server.createConnection("jdbc:teiid:QT_Ora9DS"); //$NON-NLS-1$ //$NON-NLS-2$
     }
@@ -154,7 +155,7 @@
     /** Test all the non-query methods */
     @Test
     public void testMethodsWithoutParams() throws Exception {
-        Class dbmdClass = dbmd.getClass();
+        Class<?> dbmdClass = dbmd.getClass();
         // non-query Methods return String, boolean or int
         Method[] methods = dbmdClass.getDeclaredMethods();
 
@@ -168,9 +169,9 @@
                 Object expectedReturn = expectedMap.get(methods[i].getName());
                 Object[] params = null;
                 
-                if (expectedReturn instanceof List) {
+                if (expectedReturn instanceof List<?>) {
                     // has input parameters
-                    List returned = (List) expectedReturn;
+                    List<?> returned = (List) expectedReturn;
                     params = (Object[]) returned.get(1);
                     //SYS.out.println(" params == " + params[0]);
                     expectedValue = returned.get(0);
@@ -191,10 +192,10 @@
     /** Test all the methods that throw exception */ 
     @Test
     public void testMethodsWithExceptions() throws Exception {
-        Class dbmdClass = dbmd.getClass();
+        Class<?> dbmdClass = dbmd.getClass();
         Method[] methods = dbmdClass.getDeclaredMethods();
         
-        expectedMap = new HashMap(); //none expected
+        expectedMap = new HashMap<String, Object>(); //none expected
         //SYS.out.println(" -- total method == " + methods.length + ", non-query == " + expectedMap.size());
         for (int i =0; i< methods.length; i++) {
             if (expectedMap.containsKey(methods[i].getName())) {
@@ -768,7 +769,7 @@
     }
 
     private void helpTestMethodsWithParams(String methodName, boolean returned, Object[] params) throws Exception {
-        Class dbmdClass = dbmd.getClass();
+        Class<?> dbmdClass = dbmd.getClass();
         Method[] methods = dbmdClass.getDeclaredMethods();
 
         for (int i = 0; i < methods.length; i++) {
@@ -782,7 +783,7 @@
 
     //////////////////////Expected Result//////////////////
 
-    private Map getExpected() {
+    private Map<String, Object> getExpected() {
         Map<String, Object> expected = new HashMap<String, Object>();
         // return type -- boolean
         expected.put("allProceduresAreCallable", Boolean.TRUE); //$NON-NLS-1$

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -3,6 +3,8 @@
 import java.sql.SQLException;
 import java.util.Arrays;
 
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.teiid.adminapi.impl.VDBImportMetadata;
 import org.teiid.core.util.UnitTestUtil;
@@ -14,8 +16,18 @@
 	
 	private static final String VDB1 = "PartsSupplier"; //$NON-NLS-1$
 	private static final String VDB2 = "QT_Ora9DS"; //$NON-NLS-1$
-	FakeServer server = new FakeServer(true);
-	
+
+	private FakeServer server;
+    
+    @Before public void setup() throws Exception {
+    	server = new FakeServer(true);
+    	server.setThrowMetadataErrors(false); //test vdb has errors
+    }
+    
+    @After public void teardown() throws Exception {
+    	server.stop();
+    }
+    
 	@Test
     public void testMerge() throws Throwable {
 		

Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -53,7 +53,7 @@
     	VDBRepository vdbRepository = new VDBRepository();
     	vdbRepository.setSystemStore(VDBMetadataFactory.getSystem());
     	MetadataFactory mf = new MetadataFactory(null, 1, "foo", vdbRepository.getBuiltinDatatypes(), new Properties(), null);
-    	
+    	mf.getSchema().setPhysical(false);
     	Table mat = mf.addTable("mat");
     	mat.setVirtual(true);
     	mat.setMaterialized(true);

Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java	2012-06-19 18:50:25 UTC (rev 4190)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java	2012-06-20 15:57:10 UTC (rev 4191)
@@ -51,6 +51,7 @@
     
     @BeforeClass public static void oneTimeSetup() throws Exception {
     	server = new FakeServer(true);
+    	server.setThrowMetadataErrors(false); //this vdb has invalid update procedures
     	server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/xml-vp/xmlvp_1.vdb");
     }
     



More information about the teiid-commits mailing list