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

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed May 23 17:51:54 EDT 2012


Author: shawkins
Date: 2012-05-23 17:51:53 -0400 (Wed, 23 May 2012)
New Revision: 4137

Added:
   trunk/admin/src/main/java/org/teiid/adminapi/VDBImport.java
   trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBImportMetadata.java
Modified:
   trunk/admin/src/main/java/org/teiid/adminapi/Admin.java
   trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
   trunk/admin/src/main/java/org/teiid/adminapi/VDB.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/main/resources/org/teiid/adminapi/i18n.properties
   trunk/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
   trunk/admin/src/test/resources/parser-test-vdb.xml
   trunk/admin/src/test/resources/vdb-describe.txt
   trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
   trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
   trunk/client/src/main/resources/vdb-deployer.xsd
   trunk/documentation/javadocs/
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
   trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
   trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java
   trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java
   trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
   trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java
   trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
   trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
   trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
   trunk/engine/src/main/resources/org/teiid/query/i18n.properties
   trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
   trunk/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidConfiguration.java
   trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
   trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
   trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
   trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java
   trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java
   trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java
   trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java
Log:
TEIID-1366 introducing the concept of an imported vdb to replace merge vdb

Modified: trunk/admin/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/Admin.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/main/java/org/teiid/adminapi/Admin.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -249,17 +249,6 @@
     void setAnyAuthenticatedForDataRole(String vdbName, int vdbVersion, String dataRole, boolean anyAuthenticated) throws AdminException;
     
     /**
-     * Merge the Source VDB into Target VDB. Both Source and Target VDBs must be present for this method to
-     * succeed. The changes will not be persistent between server restarts.
-     * @param sourceVDBName
-     * @param sourceVDBVersion
-     * @param targetVDBName
-     * @param targetVDBVersion
-     */
-    void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException;
-
-    
-    /**
      * Creates a JCA data source
      * @param deploymentName - name of the source
      * @param templateName - template of data source

Modified: trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -1203,25 +1203,6 @@
 		}
 
 		@Override
-		public void mergeVDBs(String sourceVDBName, int sourceVDBVersion,
-				String targetVDBName, int targetVDBVersion)
-				throws AdminException {
-			final ModelNode request = buildRequest("teiid", "merge-vdbs", 
-					"source-vdb-name", sourceVDBName, 
-					"source-vdb-name", String.valueOf(sourceVDBVersion),
-					"target-vdb-name", targetVDBName, 
-					"target-vdb-version", String.valueOf(targetVDBVersion));//$NON-NLS-1$
-	        try {
-	            ModelNode outcome = this.connection.execute(request);
-	            if (!Util.isSuccess(outcome)) {
-	                 throw new AdminProcessingException(AdminPlugin.Event.TEIID70037, Util.getFailureDescription(outcome));
-	            }
-	        } catch (Exception e) {
-	        	 throw new AdminProcessingException(AdminPlugin.Event.TEIID70038, e, e.getMessage());
-	        }			
-		}
-
-		@Override
 		public void addDataRoleMapping(String vdbName, int vdbVersion, String dataRole, String mappedRoleName) throws AdminException {
 	        final ModelNode request = buildRequest("teiid", "add-data-role", 
 	        		"vdb-name", vdbName,

Modified: trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/VDB.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/main/java/org/teiid/adminapi/VDB.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -65,12 +65,6 @@
     public int getVersion();
     
     /**
-     * Get the URL for the VDB
-     * @return
-     */
-    public String getUrl();
-    
-    /**
      * Get the description of the VDB
      * @return
      */
@@ -99,4 +93,10 @@
      * @return
      */
     public List<Translator> getOverrideTranslators();
+    
+    /**
+     * Get the list of vdb imports
+     * @return
+     */
+    public List<? extends VDBImport> getVDBImports();
 }

Added: trunk/admin/src/main/java/org/teiid/adminapi/VDBImport.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/VDBImport.java	                        (rev 0)
+++ trunk/admin/src/main/java/org/teiid/adminapi/VDBImport.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+public interface VDBImport {
+
+	String getName();
+
+	int getVersion();
+
+	boolean isImportDataPolicies();
+
+}
\ No newline at end of file


Property changes on: trunk/admin/src/main/java/org/teiid/adminapi/VDBImport.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBImportMetadata.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBImportMetadata.java	                        (rev 0)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBImportMetadata.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -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.adminapi.impl;
+
+import org.teiid.adminapi.VDBImport;
+
+public class VDBImportMetadata extends AdminObjectImpl implements VDBImport {
+	
+	private static final long serialVersionUID = 8827106139518843217L;
+	
+	private String name;
+	private int version = 1;
+	private boolean importDataPolicies = true;
+	
+	public String getName() {
+		return name;
+	}
+	
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	public int getVersion() {
+		return version;
+	}
+	
+	public void setVersion(int version) {
+		this.version = version;
+	}
+	
+	public boolean isImportDataPolicies() {
+		return importDataPolicies;
+	}
+	
+	public void setImportDataPolicies(boolean importDataPolicies) {
+		this.importDataPolicies = importDataPolicies;
+	}
+
+}


Property changes on: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBImportMetadata.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -21,8 +21,8 @@
  */
 package org.teiid.adminapi.impl;
 
-import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -33,7 +33,6 @@
 import org.teiid.adminapi.Translator;
 import org.teiid.adminapi.VDB;
 import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-import org.teiid.core.util.StringUtil;
 
 
 public class VDBMetaData extends AdminObjectImpl implements VDB {
@@ -71,18 +70,20 @@
 		public String getKey(DataPolicyMetadata entry) {
 			return entry.getName();
 		}
-	});	
+	});
 	
+	private List<VDBImportMetadata> imports = new ArrayList<VDBImportMetadata>(2);
+	
 	private int version = 1;
 	
 	protected String description;
 	
-	private String fileUrl = null;
 	private boolean dynamic = false;
 	private VDB.Status status = VDB.Status.INACTIVE;
 	private ConnectionType connectionType = VDB.ConnectionType.BY_VERSION;
 	private boolean removed;
 	private long queryTimeout = Long.MIN_VALUE;
+	private Set<String> importedModels = Collections.emptySet();
 
 	public String getName() {
 		return super.getName();
@@ -131,7 +132,6 @@
 		this.status = Status.valueOf(s);
 	}
 	
-	
 	@Override
 	public int getVersion() {
 		return this.version;
@@ -142,33 +142,6 @@
 	}	
 		
 	@Override
-	public String getUrl() {
-		return this.fileUrl;
-	}
-	
-	public void setUrl(String url) {
-		this.fileUrl = url;
-	}
-	
-	public void setUrl(URL url) {
-		this.setUrl(url.toExternalForm());
-		String path = url.getPath();
-		if (path.endsWith("/")) { //$NON-NLS-1$
-			path = path.substring(0, path.length() - 1);
-		}
-		String fileName = StringUtil.getLastToken(path, "/"); //$NON-NLS-1$
-		String[] parts = fileName.split("\\."); //$NON-NLS-1$
-		if (parts[0].equalsIgnoreCase(getName()) && parts.length >= 3) {
-			try {
-				int fileVersion = Integer.parseInt(parts[parts.length - 2]);
-				this.setVersion(fileVersion);
-			} catch (NumberFormatException e) {
-				
-			}
-		}
-	}
-
-	@Override
 	public List<Model> getModels(){
 		return new ArrayList<Model>(this.models.getMap().values());
 	}
@@ -286,12 +259,6 @@
 		return list;
 	}
 	
-	// This one manages the JAXB binding
-	@Override
-	public List<PropertyMetadata> getJAXBProperties(){
-		return super.getJAXBProperties();
-	}
-	
 	public boolean isDynamic() {
 		return dynamic;
 	}
@@ -317,8 +284,8 @@
 		}
 	}	
 	
-	public void addDataPolicy(DataPolicyMetadata policy){
-		this.dataPolicies.getMap().put(policy.getName(), policy);
+	public DataPolicyMetadata addDataPolicy(DataPolicyMetadata policy){
+		return this.dataPolicies.getMap().put(policy.getName(), policy);
 	}
 	
 	public DataPolicyMetadata getDataPolicy(String policyName) {
@@ -343,4 +310,16 @@
 		}
 		return queryTimeout;
 	}	
+	
+	public List<VDBImportMetadata> getVDBImports() {
+		return imports;
+	}
+	
+	public Set<String> getImportedModels() {
+		return importedModels;
+	}
+	
+	public void setImportedModels(Set<String> importedModels) {
+		this.importedModels = importedModels;
+	}
 }

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -29,9 +29,9 @@
 import org.teiid.adminapi.AdminPlugin;
 import org.teiid.adminapi.DataPolicy;
 import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
 import org.teiid.adminapi.Request.ProcessingState;
 import org.teiid.adminapi.Request.ThreadState;
-import org.teiid.adminapi.Translator;
 import org.teiid.adminapi.VDB.ConnectionType;
 import org.teiid.adminapi.VDB.Status;
 import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
@@ -42,8 +42,8 @@
 	private static final String CONNECTIONTYPE = "connection-type"; //$NON-NLS-1$
 	private static final String STATUS = "status"; //$NON-NLS-1$
 	private static final String VERSION = "vdb-version"; //$NON-NLS-1$
-	private static final String URL = "url"; //$NON-NLS-1$
 	private static final String MODELS = "models"; //$NON-NLS-1$
+	private static final String IMPORT_VDBS = "import-vdbs"; //$NON-NLS-1$
 	private static final String OVERRIDE_TRANSLATORS = "override-translators"; //$NON-NLS-1$
 	private static final String VDB_DESCRIPTION = "vdb-description"; //$NON-NLS-1$
 	private static final String PROPERTIES = "properties"; //$NON-NLS-1$
@@ -62,8 +62,6 @@
 		node.get(CONNECTIONTYPE).set(vdb.getConnectionType().toString());
 		node.get(STATUS).set(vdb.getStatus().toString());
 		node.get(VERSION).set(vdb.getVersion());
-		if (vdb.getUrl() != null) {
-		}
 		if (vdb.getDescription() != null) {
 			node.get(VDB_DESCRIPTION).set(vdb.getDescription());
 		}
@@ -78,6 +76,15 @@
 			}
 		}
 		
+		// IMPORT-VDBS
+		List<VDBImportMetadata> imports = vdb.getVDBImports();
+		if (imports != null && !imports.isEmpty()) {
+			ModelNode importNodes = node.get(IMPORT_VDBS);		
+			for(VDBImportMetadata vdbImport:imports) {
+				importNodes.add(VDBImportMapper.INSTANCE.wrap(vdbImport, new ModelNode()));
+			}
+		}
+		
 		// MODELS
 		Map<String, ModelMetaData> models = vdb.getModelMetaDatas();
 		if (models != null && !models.isEmpty()) {
@@ -126,9 +133,6 @@
 		if (node.has(VERSION)) {
 			vdb.setVersion(node.get(VERSION).asInt());
 		}
-		if (node.has(URL)) {
-			vdb.setUrl(node.get(URL).asString());
-		}
 		if(node.has(VDB_DESCRIPTION)) {
 			vdb.setDescription(node.get(VDB_DESCRIPTION).asString());
 		}
@@ -147,6 +151,17 @@
 			}
 		}
 		
+		// IMPORT-VDBS
+		if (node.get(IMPORT_VDBS).isDefined()) {
+			List<ModelNode> modelNodes = node.get(IMPORT_VDBS).asList();
+			for(ModelNode modelNode:modelNodes) {
+				VDBImportMetadata vdbImport = VDBImportMapper.INSTANCE.unwrap(modelNode);
+				if (vdbImport != null) {
+					vdb.getVDBImports().add(vdbImport);	
+				}
+			}
+		}
+		
 		// MODELS
 		if (node.get(MODELS).isDefined()) {
 			List<ModelNode> modelNodes = node.get(MODELS).asList();
@@ -201,7 +216,6 @@
 		node.get(STATUS).get(ALLOWED).set(statusAllowed);
 		
 		addAttribute(node, VERSION, ModelType.INT, true);
-		addAttribute(node, URL, ModelType.STRING, false);
 		addAttribute(node, VDB_DESCRIPTION, ModelType.STRING, false);
 		addAttribute(node, DYNAMIC, ModelType.BOOLEAN, false);
 		
@@ -210,6 +224,11 @@
 		props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
 		PropertyMetaDataMapper.INSTANCE.describe(props.get(VALUE_TYPE));
 
+		ModelNode vdbImports = node.get(IMPORT_VDBS);	
+		vdbImports.get(TYPE).set(ModelType.LIST);
+		VDBImportMapper.INSTANCE.describe(vdbImports.get(VALUE_TYPE));
+		vdbImports.get(DESCRIPTION).set(AdminPlugin.Util.getString(IMPORT_VDBS+DOT_DESC));
+		
 		ModelNode models = node.get( MODELS);	
 		models.get(TYPE).set(ModelType.LIST);
 		ModelMetadataMapper.INSTANCE.describe(models.get(VALUE_TYPE));
@@ -386,6 +405,54 @@
 	}	
 	
 	/**
+	 * vdb import mapper
+	 */
+	public static class VDBImportMapper implements MetadataMapper<VDBImportMetadata>{
+		private static final String VDB_NAME = "import-vdb-name"; //$NON-NLS-1$
+		private static final String VDB_VERSION = "import-vdb-version"; //$NON-NLS-1$
+		private static final String IMPORT_POLICIES = "import-policies"; //$NON-NLS-1$
+		
+		public static VDBImportMapper INSTANCE = new VDBImportMapper();
+		
+		@Override
+		public ModelNode wrap(VDBImportMetadata obj, ModelNode node) {
+			if (obj == null) {
+				return null;
+			}
+			
+			node.get(VDB_NAME).set(obj.getName());
+			node.get(VDB_VERSION).set(obj.getVersion());
+			node.get(IMPORT_POLICIES).set(obj.isImportDataPolicies());
+			return node;
+		}
+		
+		public VDBImportMetadata unwrap(ModelNode node) {
+			if (node == null) {
+				return null;
+			}
+			
+			VDBImportMetadata vdbImport = new VDBImportMetadata();
+			if (node.has(VDB_NAME)) {
+				vdbImport.setName(node.get(VDB_NAME).asString());
+			}
+			if (node.has(VDB_VERSION)) {
+				vdbImport.setVersion(node.get(VDB_VERSION).asInt());
+			}
+			if (node.has(IMPORT_POLICIES)) {
+				vdbImport.setImportDataPolicies(node.get(IMPORT_POLICIES).asBoolean());
+			}
+			return vdbImport;
+		}
+		
+		public ModelNode describe(ModelNode node) {
+			addAttribute(node, VDB_NAME, ModelType.STRING, true);
+			addAttribute(node, VDB_VERSION, ModelType.INT, true);
+			addAttribute(node, IMPORT_POLICIES, ModelType.BOOLEAN, false);
+			return node; 
+		}
+	}	
+	
+	/**
 	 * validation error mapper
 	 */
 	public static class ValidationErrorMapper implements MetadataMapper<ValidationError>{
@@ -710,30 +777,8 @@
 			permissions.get(TYPE).set(ModelType.LIST);
 			permissions.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_PERMISSIONS+DOT_DESC));
 			
-			ModelNode create = permissions.get(VALUE_TYPE, ALLOW_CREATE);
-			create.get(DESCRIPTION).set(AdminPlugin.Util.getString(ALLOW_CREATE+DOT_DESC));
-			create.get(TYPE).set(ModelType.STRING);
+			PermissionMetaDataMapper.INSTANCE.describe(permissions.get(VALUE_TYPE));
 			
-			ModelNode read = permissions.get(VALUE_TYPE, ALLOW_READ);
-			read.get(DESCRIPTION).set(AdminPlugin.Util.getString(ALLOW_READ+DOT_DESC));
-			read.get(TYPE).set(ModelType.STRING);
-
-			ModelNode update = permissions.get(VALUE_TYPE, ALLOW_UPDATE);
-			update.get(DESCRIPTION).set(AdminPlugin.Util.getString(ALLOW_UPDATE+DOT_DESC));
-			update.get(TYPE).set(ModelType.STRING);
-
-			ModelNode delete = permissions.get(VALUE_TYPE, ALLOW_DELETE);
-			delete.get(DESCRIPTION).set(AdminPlugin.Util.getString(ALLOW_DELETE+DOT_DESC));
-			delete.get(TYPE).set(ModelType.STRING);
-
-			ModelNode execute = permissions.get(VALUE_TYPE, ALLOW_EXECUTE);
-			execute.get(DESCRIPTION).set(AdminPlugin.Util.getString(ALLOW_EXECUTE+DOT_DESC));
-			execute.get(TYPE).set(ModelType.STRING);
-
-			ModelNode alter = permissions.get(VALUE_TYPE, ALLOW_ALTER);
-			alter.get(DESCRIPTION).set(AdminPlugin.Util.getString(ALLOW_ALTER+DOT_DESC));
-			alter.get(TYPE).set(ModelType.STRING);
-			
 			ModelNode roleNames = node.get(MAPPED_ROLE_NAMES);
 			roleNames.get(TYPE).set(ModelType.LIST);
 			roleNames.get(DESCRIPTION).set(AdminPlugin.Util.getString(MAPPED_ROLE_NAMES+DOT_DESC));

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -24,10 +24,19 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.*;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
 
 import javax.xml.XMLConstants;
-import javax.xml.stream.*;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
@@ -36,6 +45,7 @@
 import org.teiid.adminapi.AdminPlugin;
 import org.teiid.adminapi.DataPolicy;
 import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.VDBImport;
 import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
 import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
 import org.teiid.core.types.XMLType;
@@ -110,6 +120,15 @@
 				parseDataRole(reader, policy);
 				vdb.addDataPolicy(policy);
 				break;
+			case IMPORT_VDB:
+				VDBImportMetadata vdbImport = new VDBImportMetadata();
+				Properties props = getAttributes(reader);
+				vdbImport.setName(props.getProperty(Element.NAME.getLocalName()));
+				vdbImport.setVersion(Integer.parseInt(props.getProperty(Element.VERSION.getLocalName())));
+				vdbImport.setImportDataPolicies(Boolean.parseBoolean(props.getProperty(Element.IMPORT_POLICIES.getLocalName(), "true")));
+				vdb.getVDBImports().add(vdbImport);
+				ignoreTillEnd(reader);
+				break;
 			case ENTRY:
 				// this is designer specific.
 				break;
@@ -124,6 +143,11 @@
         }		
 	}
 
+	private static void ignoreTillEnd(XMLStreamReader reader)
+			throws XMLStreamException {
+		while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+	}
+
 	private static void parseProperty(XMLStreamReader reader, AdminObjectImpl anObj)
 			throws XMLStreamException {
 		if (reader.getAttributeCount() > 0) {
@@ -141,7 +165,7 @@
 			}
 			anObj.addProperty(key, value);
 		}
-		while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+		ignoreTillEnd(reader);
 	}
 	
 	private static void parseDataRole(XMLStreamReader reader, DataPolicyMetadata policy) throws XMLStreamException {
@@ -253,7 +277,7 @@
 				String translatorName = sourceProps.getProperty(Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName());
 				String connectionName = sourceProps.getProperty(Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName());
 				model.addSourceMapping(name, translatorName, connectionName);
-				while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+				ignoreTillEnd(reader);
 				break;
 			case VALIDATION_ERROR:
 				Properties validationProps = getAttributes(reader);
@@ -305,6 +329,8 @@
 	    PROPERTY("property"),
 	    VALUE("value"),
 	    MODEL("model"),
+	    IMPORT_VDB("import-vdb"),
+	    IMPORT_POLICIES("import-data-policies"),
 	    TYPE("type"),
 	    VISIBLE("visible"),
 	    PATH("path"),
@@ -374,6 +400,14 @@
 		}
 		writeProperties(writer, vdb.getProperties());
 
+		for (VDBImport vdbImport : vdb.getVDBImports()) {
+			writer.writeStartElement(Element.IMPORT_VDB.getLocalName());
+			writer.writeAttribute(Element.NAME.getLocalName(), vdbImport.getName());
+			writer.writeAttribute(Element.VERSION.getLocalName(), String.valueOf(vdbImport.getVersion()));
+			writer.writeAttribute(Element.IMPORT_POLICIES.getLocalName(), String.valueOf(vdbImport.isImportDataPolicies()));
+			writer.writeEndElement();
+		}
+		
 		// models
 		Collection<ModelMetaData> models = vdb.getModelMetaDatas().values();
 		for (ModelMetaData model:models) {
@@ -498,7 +532,7 @@
 	}
 	
 	private static void writeProperties(final XMLStreamWriter writer, Properties props)  throws XMLStreamException  {
-		Enumeration keys = props.propertyNames();
+		Enumeration<?> keys = props.propertyNames();
 		while (keys.hasMoreElements()) {
 	        writer.writeStartElement(Element.PROPERTY.getLocalName());
 			String key = (String)keys.nextElement();
@@ -515,8 +549,4 @@
         writer.writeEndElement();
     }     
 
-    private static void writeAttribute(final XMLStreamWriter writer, final Element element, final String value) throws XMLStreamException {
-        writer.writeAttribute(element.getLocalName(),value);
-    }     
-    
 }

Modified: trunk/admin/src/main/resources/org/teiid/adminapi/i18n.properties
===================================================================
--- trunk/admin/src/main/resources/org/teiid/adminapi/i18n.properties	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/main/resources/org/teiid/adminapi/i18n.properties	2012-05-23 21:51:53 UTC (rev 4137)
@@ -23,15 +23,22 @@
 module-name.describe=Translator's Module name
 allow-create-temp-tables.describe=Allows create of temporary table
 any-authenticated.describe=Indicates if the role is mapped to any authenticated user
-policy-name.describe=Resource Name, for which permission defined
+policy-name.describe=Name of the policy
 properties.describe=properties
 source-mappings.describe=Model to source mapping
 validity-errors.describe=Model validation errors
 models.describe=Models inside a virtual database
+import-vdbs.describe=Imported vdbs
+import-vdb-name.describe=Name of the Virtual Database to import
+import-vdb-version.describe=Version of the Virtual Database to import
+import-policies.describe=Whether to import associated data policies
 override-translators.describe=Overridden translators for the Virtual Database
 data-policies.describe=Data access policies defined for the Virtual Database
 data-permissions.describe=Permissions defined for data access
 mapped-role-names.describe=Policy name to role name mapping
+policy-description.describe=Description of the policy
+vdb-description.describe=Description of the Virtual Database
+resource-name.describe=Resource path name for this permission
 
 execution-id.describe=Unique Identifier for Request
 session-id.describe=Session Identifier

Modified: trunk/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- trunk/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -23,9 +23,9 @@
 
 import static org.junit.Assert.*;
 
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -35,6 +35,7 @@
 import org.teiid.adminapi.DataPolicy;
 import org.teiid.adminapi.Model;
 import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.VDBImport;
 import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
 import org.teiid.core.util.ObjectConverterUtil;
 import org.teiid.core.util.PropertiesUtils;
@@ -71,6 +72,11 @@
 		assertNotNull(vdb.getModel("model-two")); //$NON-NLS-1$
 		assertNull(vdb.getModel("model-unknown")); //$NON-NLS-1$
 		
+		assertEquals(1, vdb.getVDBImports().size());
+		VDBImport vdbImport = vdb.getVDBImports().get(0);
+		assertEquals("x", vdbImport.getName());
+		assertEquals(2, vdbImport.getVersion());
+		
 		modelOne = vdb.getModel("model-one"); //$NON-NLS-1$
 		assertEquals("model-one", modelOne.getName()); //$NON-NLS-1$
 		assertEquals("s1", modelOne.getSourceNames().get(0)); //$NON-NLS-1$
@@ -133,6 +139,11 @@
 		vdb.addProperty("vdb-property", "vdb-value"); //$NON-NLS-1$ //$NON-NLS-2$
 		vdb.addProperty("vdb-property2", "vdb-value2"); //$NON-NLS-1$ //$NON-NLS-2$
 		
+		VDBImportMetadata vdbImport = new VDBImportMetadata();
+		vdbImport.setName("x");
+		vdbImport.setVersion(2);
+		vdb.getVDBImports().add(vdbImport);
+		
 		ModelMetaData modelOne = new ModelMetaData();
 		modelOne.setName("model-one"); //$NON-NLS-1$
 		modelOne.addSourceMapping("s1", "translator", "java:mybinding"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -190,18 +201,11 @@
 	public void testAdminMOCreation() {
 		VDBMetaData vdb = new VDBMetaData();
 		
-		PropertiesUtils.setBeanProperty(vdb, "url", "http://teiid.org/myvdb.vdb");
+		PropertiesUtils.setBeanProperty(vdb, "name", "x");
 		
-		assertEquals("http://teiid.org/myvdb.vdb", vdb.getUrl());
+		assertEquals("x", vdb.getName());
 	}
 	
-	@Test public void testSetUrlVersion() throws MalformedURLException {
-		VDBMetaData vdb = new VDBMetaData();
-		vdb.setName("foo");
-		vdb.setUrl(new URL("file:///x/foo.2.vdb"));
-		assertEquals(2, vdb.getVersion());
-	}
-	
 	@Test public void testVDBMetaDataMapper() {
 		VDBMetaData vdb = buildVDB();
 		

Modified: trunk/admin/src/test/resources/parser-test-vdb.xml
===================================================================
--- trunk/admin/src/test/resources/parser-test-vdb.xml	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/test/resources/parser-test-vdb.xml	2012-05-23 21:51:53 UTC (rev 4137)
@@ -2,6 +2,7 @@
     <description>vdb description</description>
     <property name="vdb-property2" value="vdb-value2"></property>
     <property name="vdb-property" value="vdb-value"></property>
+    <import-vdb name="x" version="2"/>
     <model name="model-one" type="PHYSICAL" visible="false">
         <description>model description</description>
         <property name="model-prop" value="model-value-override"></property>

Modified: trunk/admin/src/test/resources/vdb-describe.txt
===================================================================
--- trunk/admin/src/test/resources/vdb-describe.txt	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/admin/src/test/resources/vdb-describe.txt	2012-05-23 21:51:53 UTC (rev 4137)
@@ -36,18 +36,11 @@
         "description" : "The Virtual Database Version",
         "required" : true
     },
-    "url" : {
-        "type" : {
-            "TYPE_MODEL_VALUE" : "STRING"
-        },
-        "description" : "The Virtual Database URL",
-        "required" : false
-    },
     "vdb-description" : {
         "type" : {
             "TYPE_MODEL_VALUE" : "STRING"
         },
-        "description" : "<Missing message for key \"vdb-description.describe\" in: org.teiid.adminapi.i18n>",
+        "description" : "Description of the Virtual Database",
         "required" : false
     },
     "dynamic" : {
@@ -79,6 +72,35 @@
             }
         }
     },
+    "import-vdbs" : {
+        "type" : {
+            "TYPE_MODEL_VALUE" : "LIST"
+        },
+        "value-type" : {
+            "import-vdb-name" : {
+                "type" : {
+                    "TYPE_MODEL_VALUE" : "STRING"
+                },
+                "description" : "Name of the Virtual Database to import",
+                "required" : true
+            },
+            "import-vdb-version" : {
+                "type" : {
+                    "TYPE_MODEL_VALUE" : "INT"
+                },
+                "description" : "Version of the Virtual Database to import",
+                "required" : true
+            },
+            "import-policies" : {
+                "type" : {
+                    "TYPE_MODEL_VALUE" : "BOOLEAN"
+                },
+                "description" : "Whether to import associated data policies",
+                "required" : false
+            }
+        },
+        "description" : "Imported vdbs"
+    },
     "models" : {
         "type" : {
             "TYPE_MODEL_VALUE" : "LIST"
@@ -276,14 +298,14 @@
                 "type" : {
                     "TYPE_MODEL_VALUE" : "STRING"
                 },
-                "description" : "Resource Name, for which permission defined",
+                "description" : "Name of the policy",
                 "required" : true
             },
             "policy-description" : {
                 "type" : {
                     "TYPE_MODEL_VALUE" : "STRING"
                 },
-                "description" : "<Missing message for key \"policy-description.describe\" in: org.teiid.adminapi.i18n>",
+                "description" : "Description of the policy",
                 "required" : false
             },
             "allow-create-temp-tables" : {
@@ -306,41 +328,54 @@
                 },
                 "description" : "Permissions defined for data access",
                 "value-type" : {
-                    "allow-create" : {
-                        "description" : "create allowed",
+                    "resource-name" : {
                         "type" : {
                             "TYPE_MODEL_VALUE" : "STRING"
-                        }
+                        },
+                        "description" : "Resource path name for this permission",
+                        "required" : true
                     },
-                    "allow-read" : {
-                        "description" : "read allowed",
+                    "allow-create" : {
                         "type" : {
-                            "TYPE_MODEL_VALUE" : "STRING"
-                        }
+                            "TYPE_MODEL_VALUE" : "BOOLEAN"
+                        },
+                        "description" : "create allowed",
+                        "required" : false
                     },
+                    "allow-delete" : {
+                        "type" : {
+                            "TYPE_MODEL_VALUE" : "BOOLEAN"
+                        },
+                        "description" : "delete allowed",
+                        "required" : false
+                    },
                     "allow-update" : {
+                        "type" : {
+                            "TYPE_MODEL_VALUE" : "BOOLEAN"
+                        },
                         "description" : "update allowed",
-                        "type" : {
-                            "TYPE_MODEL_VALUE" : "STRING"
-                        }
+                        "required" : false
                     },
-                    "allow-delete" : {
-                        "description" : "delete allowed",
+                    "allow-read" : {
                         "type" : {
-                            "TYPE_MODEL_VALUE" : "STRING"
-                        }
+                            "TYPE_MODEL_VALUE" : "BOOLEAN"
+                        },
+                        "description" : "read allowed",
+                        "required" : false
                     },
                     "allow-execute" : {
+                        "type" : {
+                            "TYPE_MODEL_VALUE" : "BOOLEAN"
+                        },
                         "description" : "execute allowed",
-                        "type" : {
-                            "TYPE_MODEL_VALUE" : "STRING"
-                        }
+                        "required" : false
                     },
                     "allow-alter" : {
+                        "type" : {
+                            "TYPE_MODEL_VALUE" : "BOOLEAN"
+                        },
                         "description" : "alter allowed",
-                        "type" : {
-                            "TYPE_MODEL_VALUE" : "STRING"
-                        }
+                        "required" : false
                     }
                 }
             },

Modified: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -33,17 +33,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminFactory;
-import org.teiid.adminapi.CacheStatistics;
-import org.teiid.adminapi.PropertyDefinition;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.Session;
-import org.teiid.adminapi.Transaction;
-import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.WorkerPoolStatistics;
+import org.teiid.adminapi.*;
 import org.teiid.adminapi.VDB.ConnectionType;
 import org.teiid.adminshell.Help.Doc;
 
@@ -266,15 +256,6 @@
 		getAdmin().terminateTransaction(transactionId);
 	}
 	
-	@Doc(text = "Merge two vdbs")
-	public static void mergeVDBs(
-			@Doc(text = "source vdb name") String sourceVDBName, 
-			@Doc(text = "source vdb version") int sourceVDBVersion,
-			@Doc(text = "target vdb name") String targetVDBName, 
-			@Doc(text = "target vdb version") int targetVDBVersion) throws AdminException {
-		getAdmin().mergeVDBs(sourceVDBName, sourceVDBVersion, targetVDBName, targetVDBVersion);
-	}
-	
 	@Doc(text = "Checks if a translator exists")
 	public static boolean hasTranslator(@Doc(text = "deployed name") String factoryName) throws AdminException {
 	    Collection<? extends Translator> bindings = getAdmin().getTranslators();

Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html	2012-05-23 21:51:53 UTC (rev 4137)
@@ -26,6 +26,7 @@
 </UL>
 <H2><A NAME="Highlights"></A>Highlights</H2>
 <UL>
+  <li><B>VDB Reuse</B> a vdb.xml can now declare imported vdbs to reuse metadata.
 </UL>
 
 <h2><a name="Compatibility">Compatibility Issues</a></h2>
@@ -33,7 +34,6 @@
   <li>Support for named parameter syntax using param=value has been deprecated, since it is ambiguous with a comparison predicate boolean value expression.  param<b>=></b>value should be used instead.  
   <li>Support for using the FROM clause post item hints MAKEDEP/MAKENOTDEP has been deprecated.  Use the pre item comment hint syntax instead, e.g. /*+ MAKEDEP */ tbl
   <li>decodeinteger/decodestring have been deprecated.  A CASE expression should be used instead.
-  <li>allowCreateTemporaryTablesByDefault and allowFunctionCallsByDefault are now set to false. When data roles are in use the user must explicitly grant these options to the user on VDB
 </ul>
 
 <h4>from 8.0</h4>
@@ -42,7 +42,8 @@
   <li>MetadataFactory no longer extends Schema.  Use the MetadataFactory.getSchema method to get the target Schema.
   <li>DDL created VIRTUAL pushdown functions should be referenced in the ExecutionFactory.getSupportedFunctions by their full <schema>.<function> name.
   <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 quailified name.
+  <li>FunctionMethod.getFullName returns the proper schema, not category qualified name.
+  <li>VDB.getUrl has been removed.
 <ul>
 
 <h4>from 7.x</h4>
@@ -63,6 +64,7 @@
   <li>VARBINARY, OPTIONS, and OUT were added as reserved words.
   <li>AbstractMetadataRecord and its sub-classes use a case-insensitive map for properties rather than a LinkedHashMap.  Thus, property key lookups are now case-insensitive.
   <li>Removed the unused ExecutionFactory methods supportsBetweenCriteria and supportsCaseExpression.    
+  <li>allowCreateTemporaryTablesByDefault and allowFunctionCallsByDefault are now set to false. When data roles are in use the user must explicitly grant these options to the user on VDB
 </ul>
 
 <h4>from 7.7</h4>

Modified: trunk/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- trunk/client/src/main/resources/vdb-deployer.xsd	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/client/src/main/resources/vdb-deployer.xsd	2012-05-23 21:51:53 UTC (rev 4137)
@@ -8,6 +8,16 @@
 			<xs:sequence>
 				<xs:element name="description" type="xs:string" minOccurs="0"/>
 				<xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
+				<xs:element name="import-vdb" maxOccurs="unbounded" minOccurs="0">
+					<xs:annotation>
+                        <xs:documentation>An imported VDB is reused in the context of this VDB.</xs:documentation>
+                    </xs:annotation>
+                    <xs:complexType>
+						<xs:attribute name="import-data-policies" type="xs:boolean" default="true" />
+						<xs:attribute name="name" type="xs:string" use="required" />
+						<xs:attribute name="version" type="xs:integer" use="required" />
+					</xs:complexType>
+				</xs:element>
 				<xs:element name="model" maxOccurs="unbounded" minOccurs="0">
                     <xs:annotation>
                         <xs:documentation>A model defines the alias for the Schema the data being integrated. In the Designer
@@ -145,6 +155,11 @@
 			<xs:selector xpath="model"/>
 			<xs:field xpath="@name"/>
 		</xs:unique>
+		<xs:unique name="importUnique">
+			<xs:selector xpath="import-vdb"/>
+			<xs:field xpath="@name"/>
+			<xs:field xpath="@version"/>
+		</xs:unique>
 	</xs:element>
 	<xs:complexType name="property">
 		<xs:annotation>


Property changes on: trunk/documentation/javadocs
___________________________________________________________________
Modified: svn:ignore
   - .project

.settings

   + .project

.settings

bin


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	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -404,6 +404,13 @@
 						if (target == null) {
 							 throw new TeiidProcessingException(QueryPlugin.Event.TEIID30549, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30549, uuid));
 						}
+						AbstractMetadataRecord schema = target;
+						while (!(schema instanceof Schema) && schema.getParent() != null) {
+							schema = schema.getParent();
+						}
+						if (schema instanceof Schema && vdb.getImportedModels().contains(((Schema)schema).getName())) {
+							throw new TeiidProcessingException(QueryPlugin.Event.TEIID31098, QueryPlugin.Util.getString("ValidationVisitor.invalid_alter", uuid)); //$NON-NLS-1$
+						}
 						if (getMetadataRepository(target, vdb) != null) {
 							getMetadataRepository(target, vdb).setProperty(vdbName, vdbVersion, target, key, strVal);
 						}

Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -557,6 +557,7 @@
     	TEIID31094,
     	TEIID31095,
     	TEIID31096,
-    	TEIID31097
+    	TEIID31097,
+    	TEIID31098, //alter imported
 	}
 }

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -26,6 +26,7 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 import org.teiid.api.exception.query.QueryMetadataException;
 import org.teiid.core.TeiidComponentException;
@@ -513,5 +514,10 @@
 	public QueryMetadataInterface getSessionMetadata() {
 		return null;
 	}
+	
+	@Override
+	public Set<String> getImportedModels() {
+		return Collections.emptySet();
+	}
     
 }

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -25,6 +25,7 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 import org.teiid.api.exception.query.QueryMetadataException;
 import org.teiid.core.TeiidComponentException;
@@ -372,5 +373,10 @@
 	public QueryMetadataInterface getSessionMetadata() {
 		return actualMetadata.getSessionMetadata();
 	}
+	
+	@Override
+	public Set<String> getImportedModels() {
+		return actualMetadata.getImportedModels();
+	}
 
 }

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -331,7 +331,7 @@
 						}
 						
 						String referenceTableName = fk.getReferenceTableName();
-						if (referenceTableName == null && fk.getPrimaryKey() == null){
+						if (referenceTableName == null){
 							log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31091, t.getName()));
 							continue;
 						}

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -25,6 +25,7 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 import org.teiid.api.exception.query.QueryMetadataException;
 import org.teiid.core.TeiidComponentException;
@@ -643,4 +644,6 @@
 	boolean hasProcedure(String name) throws TeiidComponentException;
 
 	QueryMetadataInterface getSessionMetadata();
+
+	Set<String> getImportedModels();
 }

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -34,6 +34,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 
 import org.jboss.vfs.VirtualFile;
 import org.teiid.adminapi.impl.VDBMetaData;
@@ -1086,4 +1087,12 @@
 		tm.procedureCache = this.procedureCache; 
 		return tm;
 	}
+	
+	@Override
+	public Set<String> getImportedModels() {
+		if (this.vdbMetaData == null) {
+			return Collections.emptySet();
+		}
+		return this.vdbMetaData.getImportedModels();
+	}
 }
\ No newline at end of file

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -286,11 +286,6 @@
          * @since 5.0
          */
         QUERY_FUNCTIONS_IN_GROUP_BY,
-        /**
-         * Support indicates connector can accept queries with searched CASE WHEN <criteria> ... END
-         * 
-         * @since 4.2
-         */
         BATCHED_UPDATES,
         BULK_UPDATE,
         /**

Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -1330,6 +1330,7 @@
     	try {
 			QueryResolver.validateProjectedSymbols(obj.getTarget(), getMetadata(), obj.getDefinition());
 			Validator.validate(obj.getDefinition(), getMetadata(), this);
+			validateAlterTarget(obj);
 		} catch (QueryValidatorException e) {
 			handleValidationError(e.getMessage(), obj.getDefinition());
 		} catch (TeiidComponentException e) {
@@ -1337,9 +1338,16 @@
 		}
     }
 
+	private void validateAlterTarget(Alter<?> obj) {
+		if (getMetadata().getImportedModels().contains(obj.getTarget().getSchema())) {
+			handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_alter", obj.getTarget()), obj.getTarget()); //$NON-NLS-1$
+		}
+	}
+
     @Override
     public void visit(AlterProcedure obj) {
     	GroupSymbol gs = obj.getTarget();
+    	validateAlterTarget(obj);
     	try {
 	    	if (!gs.isProcedure() || !getMetadata().isVirtualModel(getMetadata().getModelID(gs.getMetadataID()))) {
 	    		handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.not_a_procedure", gs), gs); //$NON-NLS-1$
@@ -1402,6 +1410,7 @@
     
     @Override
     public void visit(AlterTrigger obj) {
+    	validateAlterTarget(obj);
     	validateGroupSupportsUpdate(obj.getTarget());
 		try {
 			if (obj.getDefinition() != null) {

Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-05-23 21:51:53 UTC (rev 4137)
@@ -187,6 +187,7 @@
 ValidationVisitor.union_insert = Select into is not allowed under a set operation: {0}.
 ValidationVisitor.multisource_insert = A multi-source table, {0}, cannot be used in an INSERT with query expression or SELECT INTO statement.
 ValidationVisitor.invalid_encoding = Invalid encoding: {0}.
+ValidationVisitor.invalid_alter=Cannot alter an object {0} from an imported model.
 TEIID30376=The specified change set {0} against an inherently updatable view does not map to a key preserving group.
 TEIID30239=Inserts with query expressions cannot be performed against a partitioned UNION view {0}.
 TEIID30241=Could not determine INSERT target for a partitioned UNION view {0} with values {1}.

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -122,7 +122,6 @@
 		// teiid level admin api operation handlers
 		new GetTranslator().register(teiidSubsystem);
 		new ListTranslators().register(teiidSubsystem);
-		new MergeVDBs().register(teiidSubsystem);
 		new ListVDBs().register(teiidSubsystem);
 		new GetVDB().register(teiidSubsystem);
 		new CacheTypes().register(teiidSubsystem);

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -629,65 +629,6 @@
 	}	
 }
 
-class MergeVDBs extends BaseOperationHandler<VDBRepository>{
-	
-	protected MergeVDBs() {
-		super("merge-vdbs"); //$NON-NLS-1$
-	}
-	
-	@Override
-	protected VDBRepository getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
-        ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
-        return VDBRepository.class.cast(sc.getValue());	
-	}
-	
-	@Override
-	protected void executeOperation(OperationContext context, VDBRepository repo, ModelNode operation) throws OperationFailedException {
-		if (!operation.hasDefined(OperationsConstants.SOURCE_VDBNAME)) {
-			throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBNAME+MISSING)));
-		}
-		if (!operation.hasDefined(OperationsConstants.SOURCE_VDBVERSION)) {
-			throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBVERSION+MISSING)));
-		}
-		
-		if (!operation.hasDefined(OperationsConstants.TARGET_VDBNAME)) {
-			throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBNAME+MISSING)));
-		}
-		if (!operation.hasDefined(OperationsConstants.TARGET_VDBVERSION)) {
-			throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBVERSION+MISSING)));
-		}
-				
-		String sourceVDBName = operation.get(OperationsConstants.SOURCE_VDBNAME).asString();
-		int sourceVDBversion = operation.get(OperationsConstants.SOURCE_VDBVERSION).asInt();
-		String targetVDBName = operation.get(OperationsConstants.TARGET_VDBNAME).asString();
-		int targetVDBversion = operation.get(OperationsConstants.TARGET_VDBVERSION).asInt();
-		try {
-			repo.mergeVDBs(sourceVDBName, sourceVDBversion, targetVDBName, targetVDBversion);
-		} catch (AdminException e) {
-			throw new OperationFailedException(new ModelNode().set(e.getMessage()));
-		}
-	}
-	
-	protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME, TYPE).set(ModelType.STRING);
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME, REQUIRED).set(true);
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SOURCE_VDBNAME));
-		
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION, TYPE).set(ModelType.STRING);
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION, REQUIRED).set(true);
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SOURCE_VDBVERSION));
-
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME, TYPE).set(ModelType.STRING);
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME, REQUIRED).set(true);
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TARGET_VDBNAME));
-
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION, TYPE).set(ModelType.STRING);
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION, REQUIRED).set(true);
-		operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TARGET_VDBVERSION));
-		operationNode.get(REPLY_PROPERTIES).setEmptyObject();
-	}	
-}
-
 class ExecuteQuery extends TeiidOperationHandler{
 	
 	protected ExecuteQuery() {

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -37,6 +37,7 @@
 	public static ServiceName SYSTEM_VDB = ServiceName.JBOSS.append("teiid", "system.vdb");//$NON-NLS-1$ //$NON-NLS-2$
 	public static ServiceName AUTHORIZATION_VALIDATOR = ServiceName.JBOSS.append("teiid", "authorization-validator");//$NON-NLS-1$ //$NON-NLS-2$
 	private static ServiceName VDB_SVC_BASE = ServiceName.JBOSS.append("teiid", "vdb"); //$NON-NLS-1$ //$NON-NLS-2$
+	private static ServiceName VDB_FINISHED_SVC_BASE = ServiceName.JBOSS.append("teiid", "vdb-finished"); //$NON-NLS-1$ //$NON-NLS-2$
 	public static ServiceName OBJECT_SERIALIZER = ServiceName.JBOSS.append("teiid", "object-serializer"); //$NON-NLS-1$ //$NON-NLS-2$
 	public static ServiceName CACHE_RESULTSET = ServiceName.JBOSS.append("teiid", "cache", "resultset"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	public static ServiceName CACHE_PREPAREDPLAN = ServiceName.JBOSS.append("teiid", "cache", "prepared-plan"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -53,6 +54,10 @@
 		return VDB_SVC_BASE.append(vdbName, String.valueOf(version)); 
 	}
 	
+	public static ServiceName vdbFinishedServiceName(String vdbName, int version) {
+		return VDB_FINISHED_SVC_BASE.append(vdbName, String.valueOf(version)); 
+	}
+	
 	public static ServiceName executorServiceName(String poolName) {
 		return ServiceName.JBOSS.append("thread", "executor", poolName); //$NON-NLS-1$ //$NON-NLS-2$
 	}

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -50,10 +50,11 @@
 import org.jboss.msc.service.ServiceController.State;
 import org.teiid.adminapi.Model;
 import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.VDBImport;
 import org.teiid.adminapi.impl.ModelMetaData;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.adminapi.impl.VDBTranslatorMetaData;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.deployers.UDFMetaData;
 import org.teiid.deployers.VDBRepository;
@@ -170,6 +171,10 @@
 			}
 		});
 		
+		for (VDBImport vdbImport : deployment.getVDBImports()) {
+			vdbService.addDependency(TeiidServiceNames.vdbFinishedServiceName(vdbImport.getName(), vdbImport.getVersion()));
+		}
+		
 		// adding the translator services is redundant, however if one is removed then it is an issue.
 		for (Model model:deployment.getModels()) {
 			List<String> sourceNames = model.getSourceNames();

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -142,8 +142,6 @@
 		}
 		
 		try {
-			vdb.setUrl(file.toURL());		
-			
 			// build the metadata store
 			if (imf != null) {
 				imf.addEntriesPlusVisibilities(file, vdb);

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -37,6 +37,9 @@
 import javax.xml.stream.XMLStreamException;
 
 import org.jboss.msc.service.Service;
+import org.jboss.msc.service.ServiceBuilder;
+import org.jboss.msc.service.ServiceContainer;
+import org.jboss.msc.service.ServiceController;
 import org.jboss.msc.service.StartContext;
 import org.jboss.msc.service.StartException;
 import org.jboss.msc.service.StopContext;
@@ -125,7 +128,7 @@
 		}
 
 		createConnectorManagers(cmr, repo, this.vdb);
-		
+		final ServiceBuilder<Void> vdbService = addVDBFinishedService(context);
 		this.vdbListener = new VDBLifeCycleListener() {
 			@Override
 			public void added(String name, int version, CompositeVDB vdb) {
@@ -151,6 +154,7 @@
 					}
 				}
 				vdbInstance.addAttchment(GlobalTableStore.class, gts);
+				vdbService.install();
 			}
 		};
 		
@@ -192,6 +196,32 @@
 		}
 	}
 
+	private ServiceBuilder<Void> addVDBFinishedService(StartContext context) {
+		ServiceContainer serviceContainer = context.getController().getServiceContainer();
+		final ServiceController<?> controller = serviceContainer.getService(TeiidServiceNames.vdbFinishedServiceName(vdb.getName(), vdb.getVersion()));
+        if (controller != null) {
+            controller.setMode(ServiceController.Mode.REMOVE);
+        }
+        return serviceContainer.addService(TeiidServiceNames.vdbFinishedServiceName(vdb.getName(), vdb.getVersion()), new Service<Void>() {
+			@Override
+			public Void getValue() throws IllegalStateException,
+					IllegalArgumentException {
+				return null;
+			}
+
+			@Override
+			public void start(StartContext context)
+					throws StartException {
+				
+			}
+
+			@Override
+			public void stop(StopContext context) {
+				
+			}
+		});
+	}
+
 	@Override
 	public void stop(StopContext context) {
 		// stop object replication
@@ -202,7 +232,10 @@
 		getVDBRepository().removeListener(this.vdbListener);
 		getVDBRepository().removeVDB(this.vdb.getName(), this.vdb.getVersion());
 		this.vdb.setRemoved(true);
-
+		final ServiceController<?> controller = context.getController().getServiceContainer().getService(TeiidServiceNames.vdbFinishedServiceName(vdb.getName(), vdb.getVersion()));
+        if (controller != null) {
+            controller.setMode(ServiceController.Mode.REMOVE);
+        }
 		LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50026, this.vdb));
 	}
 

Modified: trunk/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidConfiguration.java
===================================================================
--- trunk/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidConfiguration.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidConfiguration.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -202,13 +202,13 @@
         Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
         
         List<String> opNames = getList(result);
-        assertEquals(39, opNames.size());
+        assertEquals(38, opNames.size());
 		String[] ops = { "add","add-anyauthenticated-role","add-data-role","assign-datasource",
 				"cache-statistics","cache-types","cancel-request","change-vdb-connection-type",
 				"clear-cache","describe","execute-query","get-plan","get-translator","get-vdb",
 				"list-long-running-requests","list-requests","list-requests-per-session",
 				"list-requests-per-vdb","list-sessions","list-transactions","list-translators",
-				"list-vdbs","mark-datasource-available","merge-vdbs","read-attribute",
+				"list-vdbs","mark-datasource-available","read-attribute",
 				"read-children-names","read-children-resources","read-children-types",
 				"read-operation-description","read-operation-names","read-rar-description",
 				"read-resource","read-resource-description","remove-anyauthenticated-role",

Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -27,9 +27,11 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.TreeSet;
 
 import org.teiid.adminapi.DataPolicy;
 import org.teiid.adminapi.Model;
+import org.teiid.adminapi.VDBImport;
 import org.teiid.adminapi.impl.DataPolicyMetadata;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.VDBMetaData;
@@ -43,10 +45,12 @@
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.metadata.TransformationMetadata;
 import org.teiid.query.metadata.TransformationMetadata.Resource;
+import org.teiid.runtime.RuntimePlugin;
 import org.teiid.vdb.runtime.VDBKey;
 
-
-
+/**
+ * Represents the runtime state of a vdb that may aggregate several vdbs.
+ */
 public class CompositeVDB {
 	private VDBMetaData vdb;
 	private MetadataStore store;
@@ -57,11 +61,8 @@
 	private ConnectorManagerRepository cmr;
 	private FunctionTree systemFunctions;
 	private boolean metadataloadFinished = false;
-	private boolean modified;
+	private VDBMetaData mergedVDB;
 	
-	// used as cached item to avoid rebuilding
-	private volatile VDBMetaData mergedVDB;
-	
 	public CompositeVDB(VDBMetaData vdb, MetadataStore metadataStore, LinkedHashMap<String, Resource> visibilityMap, UDFMetaData udf, FunctionTree systemFunctions, ConnectorManagerRepository cmr, MetadataStore... additionalStores) {
 		this.vdb = vdb;
 		this.store = metadataStore;
@@ -70,53 +71,9 @@
 		this.systemFunctions = systemFunctions;
 		this.cmr = cmr;
 		this.additionalStores = additionalStores;
-		this.mergedVDB = buildVDB();
+		this.mergedVDB = vdb;
 	}
 	
-	synchronized void addChild(CompositeVDB child) {
-		if (this.children == null) {
-			this.children = new LinkedHashMap<VDBKey, CompositeVDB>();
-		}
-		VDBMetaData childVDB = child.getVDB();
-		this.children.put(new VDBKey(childVDB.getName(), childVDB.getVersion()), child);
-		modified = true;
-		update();
-	}
-	
-	synchronized void removeChild(VDBKey child) {
-		if (this.children != null) {
-			this.children.remove(child);
-		}
-		modified = true;
-		update();
-	}	
-	
-	private synchronized void update() {
-		if (!this.metadataloadFinished) {
-			return;
-		}
-		VDBMetaData newVDB = mergedVDB;
-		if (modified) {
-			newVDB = buildVDB();
-		}
-		
-		MetadataStore mergedStore = getMetadataStore();
-		
-		for (ModelMetaData model:newVDB.getModelMetaDatas().values()) {
-			MetadataRepository repo = model.getAttachment(MetadataRepository.class);
-			if (repo instanceof DefaultMetadataRepository) {
-				updateFromMetadataRepository(newVDB, mergedStore.getSchema(model.getName()), (DefaultMetadataRepository)repo);
-			}
-		}
-		
-		TransformationMetadata metadata = buildTransformationMetaData(newVDB, getVisibilityMap(), mergedStore, getUDF(), systemFunctions, this.additionalStores);
-		newVDB.addAttchment(QueryMetadataInterface.class, metadata);
-		newVDB.addAttchment(TransformationMetadata.class, metadata);
-		newVDB.addAttchment(MetadataStore.class, mergedStore);
-		this.mergedVDB = newVDB;
-		this.modified = false;
-	}
-	
 	private static TransformationMetadata buildTransformationMetaData(VDBMetaData vdb, LinkedHashMap<String, Resource> visibilityMap, MetadataStore store, UDFMetaData udf, FunctionTree systemFunctions, MetadataStore[] additionalStores) {
 		Collection <FunctionTree> udfs = new ArrayList<FunctionTree>();
 		if (udf != null) {			
@@ -144,18 +101,10 @@
 		return this.mergedVDB;
 	}
 	
-	synchronized boolean hasChildVdb(VDBKey child) {
-		if (this.children != null) {
-			return this.children.containsKey(child);
-		}
-		return false;
-	}
-	
-	VDBMetaData buildVDB() {
-		
-		if (this.children == null || this.children.isEmpty()) {
+	void buildCompositeState(VDBRepository vdbRepository) throws VirtualDatabaseException {
+		if (vdb.getVDBImports().isEmpty()) {
 			this.vdb.addAttchment(ConnectorManagerRepository.class, this.cmr);
-			return this.vdb;
+			return;
 		}
 		
 		VDBMetaData newMergedVDB = new VDBMetaData();
@@ -169,22 +118,35 @@
 		newMergedVDB.setConnectionType(this.vdb.getConnectionType());
 		ConnectorManagerRepository mergedRepo = new ConnectorManagerRepository();
 		mergedRepo.getConnectorManagers().putAll(this.cmr.getConnectorManagers());
-		
-		for (CompositeVDB child:this.children.values()) {
+		newMergedVDB.addAttchment(ConnectorManagerRepository.class, mergedRepo);
+		this.children = new LinkedHashMap<VDBKey, CompositeVDB>();
+		newMergedVDB.setImportedModels(new TreeSet<String>(String.CASE_INSENSITIVE_ORDER));
+		for (VDBImport vdbImport : vdb.getVDBImports()) {
+			CompositeVDB importedVDB = vdbRepository.getCompositeVDB(vdbImport.getName(), vdbImport.getVersion());
+			if (importedVDB == null) {
+				throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40083, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40083, vdb.getName(), vdb.getVersion(), vdbImport.getName(), vdbImport.getVersion()));
+			}
+			VDBMetaData childVDB = importedVDB.getVDB();
+			this.children.put(new VDBKey(childVDB.getName(), childVDB.getVersion()), importedVDB);
 			
-			// add models
-			for (Model m:child.getVDB().getModels()) {
-				newMergedVDB.addModel((ModelMetaData)m);
+			if (vdbImport.isImportDataPolicies()) {
+				for (DataPolicy role : importedVDB.getVDB().getDataPolicies()) {
+					if (vdb.addDataPolicy((DataPolicyMetadata)role) != null) {
+						throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40084, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40084, vdb.getName(), vdb.getVersion(), vdbImport.getName(), vdbImport.getVersion(), role.getName()));
+					}
+				}
 			}
 			
-			for (DataPolicy p:child.getVDB().getDataPolicies()) {
-				newMergedVDB.addDataPolicy((DataPolicyMetadata)p);
+			// add models
+			for (Model m:importedVDB.getVDB().getModels()) {
+				if (newMergedVDB.addModel((ModelMetaData)m) != null) {
+					throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40085, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40085, vdb.getName(), vdb.getVersion(), vdbImport.getName(), vdbImport.getVersion(), m.getName()));
+				}
+				newMergedVDB.getImportedModels().add(m.getName());
 			}
-			mergedRepo.getConnectorManagers().putAll(child.cmr.getConnectorManagers());
+			mergedRepo.getConnectorManagers().putAll(importedVDB.cmr.getConnectorManagers());
 		}
-
-		newMergedVDB.addAttchment(ConnectorManagerRepository.class, mergedRepo);
-		return newMergedVDB;
+		this.mergedVDB = newMergedVDB;
 	}
 	
 	private UDFMetaData getUDF() {
@@ -218,7 +180,7 @@
 		return mergedUDF;
 	}
 	
-	private synchronized LinkedHashMap<String, Resource> getVisibilityMap() {
+	private LinkedHashMap<String, Resource> getVisibilityMap() {
 		if (this.children == null || this.children.isEmpty()) {
 			return this.visibilityMap;
 		}
@@ -236,7 +198,7 @@
 		return mergedvisibilityMap;
 	}
 	
-	private synchronized MetadataStore getMetadataStore() {
+	private MetadataStore getMetadataStore() {
 		if (this.children == null || this.children.isEmpty()) {
 			return this.store;
 		}		
@@ -334,10 +296,24 @@
 	}	
 	
 	public synchronized void metadataLoadFinished() {
-		if (!this.metadataloadFinished) {
-			this.metadataloadFinished = true;
-			update();
+		if (this.metadataloadFinished) {
+			return;
 		}
+		this.metadataloadFinished = true;
+		
+		MetadataStore mergedStore = getMetadataStore();
+		
+		for (ModelMetaData model:vdb.getModelMetaDatas().values()) {
+			MetadataRepository repo = model.getAttachment(MetadataRepository.class);
+			if (repo instanceof DefaultMetadataRepository) {
+				updateFromMetadataRepository(mergedVDB, mergedStore.getSchema(model.getName()), (DefaultMetadataRepository)repo);
+			}
+		}
+		
+		TransformationMetadata metadata = buildTransformationMetaData(mergedVDB, getVisibilityMap(), mergedStore, getUDF(), systemFunctions, this.additionalStores);
+		mergedVDB.addAttchment(QueryMetadataInterface.class, metadata);
+		mergedVDB.addAttchment(TransformationMetadata.class, metadata);
+		mergedVDB.addAttchment(MetadataStore.class, mergedStore);
 	}
 	
 }

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -32,8 +32,6 @@
 import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminProcessingException;
 import org.teiid.adminapi.VDB;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.SourceMappingMetadata;
@@ -91,12 +89,17 @@
 			stores = new MetadataStore[] {this.systemStore, odbcStore};
 		}
 		CompositeVDB cvdb = new CompositeVDB(vdb, metadataStore, visibilityMap, udf, this.systemFunctionManager.getSystemFunctions(), cmr, stores);
-		this.vdbRepo.put(vdbId(vdb), cvdb); 
+		cvdb.buildCompositeState(this);
+		this.vdbRepo.put(vdbId(vdb), cvdb);
 		notifyAdd(vdb.getName(), vdb.getVersion(), cvdb);
 	}
 
+	CompositeVDB getCompositeVDB(String name, int version) {
+		return this.vdbRepo.get(new VDBKey(name, version));
+	}
+	
 	public VDBMetaData getVDB(String name, int version) {
-		CompositeVDB v = this.vdbRepo.get(new VDBKey(name, version));
+		CompositeVDB v = getCompositeVDB(name, version);
 		if (v != null) {
 			return v.getVDB();
 		}
@@ -211,48 +214,17 @@
 	public boolean removeVDB(String vdbName, int vdbVersion) {
 		VDBKey key = new VDBKey(vdbName, vdbVersion);
 		CompositeVDB removed = this.vdbRepo.remove(key);
-		if (removed != null) {
-			// if this VDB was part of another VDB; then remove them.
-			for (CompositeVDB other:this.vdbRepo.values()) {
-				synchronized (other) {
-					if (other.hasChildVdb(key)) {
-						notifyRemove(other.getVDB().getName(), other.getVDB().getVersion(), other);
-		
-						other.removeChild(key);
-		
-						notifyAdd(other.getVDB().getName(), other.getVDB().getVersion(), other);
-					}
-				}
-			}
-			notifyRemove(key.getName(), key.getVersion(), removed);
-			return true;
+		if (removed == null) {
+			return false;
 		}
-		return false;
+		notifyRemove(key.getName(), key.getVersion(), removed);
+		return true;
 	}	
 	
 	public Map<String, Datatype> getBuiltinDatatypes() {
 		return datatypeMap;
 	}
 	
-	public void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException{
-		CompositeVDB source = this.vdbRepo.get(new VDBKey(sourceVDBName, sourceVDBVersion));
-		if (source == null) {
-			 throw new AdminProcessingException(RuntimePlugin.Event.TEIID40037, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40037, sourceVDBName, sourceVDBVersion));
-		}
-		
-		CompositeVDB target = this.vdbRepo.get(new VDBKey(targetVDBName, targetVDBVersion));
-		if (target == null) {
-			 throw new AdminProcessingException(RuntimePlugin.Event.TEIID40038, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40038, sourceVDBName, sourceVDBVersion));
-		}		
-
-		notifyRemove(targetVDBName, targetVDBVersion, target);
-		// merge them
-		target.addChild(source);
-		
-		notifyAdd(targetVDBName, targetVDBVersion, target);
-		finishDeployment(targetVDBName, targetVDBVersion);		
-	}
-	
 	// this is called by mc
 	public void start() {
 		if (this.odbcEnabled) {
@@ -262,10 +234,13 @@
 	
 	public void finishDeployment(String name, int version) {
 		CompositeVDB v = this.vdbRepo.get(new VDBKey(name, version));
-		if (v!= null) {
-			boolean valid = false;
-			v.metadataLoadFinished();
-			VDBMetaData metdataAwareVDB = v.getVDB();			
+		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()) {
@@ -286,7 +261,6 @@
 			else {
 				metdataAwareVDB.setStatus(VDB.Status.INACTIVE);
 			}
-				
 			LogManager.logInfo(LogConstants.CTX_RUNTIME, (VDB.Status.ACTIVE == metdataAwareVDB.getStatus())?RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,name, version):RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40006,name, version));
 			notifyFinished(name, version, v);
 		}

Modified: trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -112,5 +112,8 @@
     	TEIID40080,
     	TEIID40081,
     	TEIID40082,
+    	TEIID40083, //vdb import does not exist
+    	TEIID40084, //imported role conflict
+    	TEIID40085, //imported model conflict
     }
 }

Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties	2012-05-23 21:51:53 UTC (rev 4137)
@@ -96,4 +96,8 @@
 TEIID40041=Invalid Session. Session may have been terminated. Re-connect and try again.
 TEIID40042=Invalid Session. Session may have been terminated. Re-connect and try again. 
 TEIID40072=Model {0} is defined as VIRTUAL model, however it is defined with source mappings! check your vdb.xml file.
-TEIID40073=The metadata for the VDB {0}.{1} is loaded, however it is not valid. Check models for errors. Correct the metadata and re-deploy.
\ No newline at end of file
+TEIID40073=The metadata for the VDB {0}.{1} is loaded, however it is not valid. Check models for errors. Correct the metadata and re-deploy.
+
+TEIID40083={0}.{1} imports a non-existent VDB {2}.{3} 
+TEIID40084={0}.{1} imports a conflicting role {4} from {2}.{3}
+TEIID40085={0}.{1} imports a conflicting model {4} from {2}.{3}
\ No newline at end of file

Modified: trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -28,6 +28,7 @@
 
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.teiid.adminapi.impl.VDBImportMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.core.types.DataTypeManager;
 import org.teiid.dqp.internal.datamgr.ConnectorManager;
@@ -42,7 +43,6 @@
 import org.teiid.query.sql.lang.Command;
 import org.teiid.query.unittest.RealMetadataFactory;
 import org.teiid.translator.ExecutionFactory;
-import org.teiid.vdb.runtime.VDBKey;
 
 @SuppressWarnings("nls")
 public class TestCompositeVDB {
@@ -53,23 +53,30 @@
     	return vdb.getAttachment(TransformationMetadata.class);
 	}
 
-	private static CompositeVDB createCompositeVDB(MetadataStore metadataStore,	String vdbName) {
-		VDBMetaData vdbMetaData = new VDBMetaData();
-    	vdbMetaData.setName(vdbName); //$NON-NLS-1$
-    	vdbMetaData.setVersion(1);
-    	for (Schema schema : metadataStore.getSchemas().values()) {
-			vdbMetaData.addModel(RealMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
-		}
+	private static CompositeVDB createCompositeVDB(MetadataStore metadataStore,	String vdbName) throws VirtualDatabaseException {
+		VDBMetaData vdbMetaData = createVDBMetadata(metadataStore, vdbName);
     	
     	ConnectorManagerRepository cmr = new ConnectorManagerRepository();
     	cmr.addConnectorManager("source", getConnectorManager("FakeTranslator", "FakeConnection", getFuncsOne()));
     	cmr.addConnectorManager("source2", getConnectorManager("FakeTranslator2", "FakeConnection2", getFuncsTwo()));
     	
     	CompositeVDB cvdb = new CompositeVDB(vdbMetaData, metadataStore, null, null, RealMetadataFactory.SFM.getSystemFunctions(),cmr);
+    	cvdb.buildCompositeState(null);
     	cvdb.metadataLoadFinished();
 		return cvdb;
 	}
-	
+
+	private static VDBMetaData createVDBMetadata(MetadataStore metadataStore,
+			String vdbName) {
+		VDBMetaData vdbMetaData = new VDBMetaData();
+    	vdbMetaData.setName(vdbName); //$NON-NLS-1$
+    	vdbMetaData.setVersion(1);
+    	for (Schema schema : metadataStore.getSchemas().values()) {
+			vdbMetaData.addModel(RealMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
+		}
+		return vdbMetaData;
+	}
+
 	private static ConnectorManager getConnectorManager(String translatorName, String connectionName, List<FunctionMethod> funcs) {
 		final ExecutionFactory<Object, Object> ef = Mockito.mock(ExecutionFactory.class);
 		
@@ -107,13 +114,41 @@
     	return funcs;		
 	}
 	
-	
 	private void helpResolve(String sql) throws Exception {
 		TransformationMetadata metadata = createTransformationMetadata(RealMetadataFactory.exampleBQTCached().getMetadataStore(), "bqt");
 		Command command = QueryParser.getQueryParser().parseCommand(sql);
 		QueryResolver.resolveCommand(command, metadata);		
 	}
 	
+	@Test(expected=VirtualDatabaseException.class) public void testImportErrors() throws Exception {
+		VDBRepository repo = new VDBRepository();
+		repo.setSystemStore(RealMetadataFactory.example1Cached().getMetadataStore());
+		repo.setSystemFunctionManager(RealMetadataFactory.SFM);
+		MetadataStore metadataStore = RealMetadataFactory.exampleBQTCached().getMetadataStore();
+		VDBMetaData vdb = createVDBMetadata(metadataStore, "bqt");
+		repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
+		
+		vdb = createVDBMetadata(metadataStore, "bqt1");
+		VDBImportMetadata vdbImport = new VDBImportMetadata();
+		vdbImport.setName("foo");
+		vdb.getVDBImports().add(vdbImport);
+		
+		try {
+			//foo does not exist
+			repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
+			fail();
+		} catch (VirtualDatabaseException e) {
+			
+		}
+		
+		vdb = createVDBMetadata(metadataStore, "bqt1");
+		vdbImport.setName("bqt");
+		vdb.getVDBImports().add(vdbImport);
+		
+		//model conflict
+		repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
+	}
+	
 	@Test
 	public void testSourceMetadataStoreFunction() throws Exception {
 		helpResolve("SELECT bqt1.reverse(BQT1.SmallA.INTKEY) FROM BQT1.SmallA");
@@ -144,15 +179,4 @@
 		helpResolve("SELECT duplicate_func(BQT1.SmallA.INTKEY) FROM BQT1.SmallA");
 	}		
 	
-	@Test public void testRemoveChild() throws Exception {
-		CompositeVDB vdb = createCompositeVDB(RealMetadataFactory.exampleBQTStore(), "bqt");
-		VDBKey child = new VDBKey("foo", 1);
-		vdb.removeChild(child);
-		assertNotNull(vdb.getVDB());
-		assertFalse(vdb.hasChildVdb(child));
-		vdb.addChild(createCompositeVDB(RealMetadataFactory.exampleBusObjStore(), "foo"));
-		assertTrue(vdb.hasChildVdb(child));
-		assertNotNull(vdb.getVDB());
-	}
-	
 }

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-05-23 17:18:52 UTC (rev 4136)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -41,9 +41,9 @@
 import org.mockito.Mockito;
 import org.teiid.Replicated;
 import org.teiid.Replicated.ReplicationMode;
-import org.teiid.adminapi.AdminException;
 import org.teiid.adminapi.VDB;
 import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBImportMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.cache.Cache;
 import org.teiid.cache.CacheConfiguration;
@@ -98,6 +98,18 @@
 @SuppressWarnings({"nls"})
 public class FakeServer extends ClientServiceRegistryImpl implements ConnectionProfile {
 	
+	public static class DeployVDBParameter {
+		public Map<String, Collection<FunctionMethod>> udfs;
+		public MetadataRepository metadataRepo;
+		public List<VDBImportMetadata> vdbImports;
+
+		public DeployVDBParameter(Map<String, Collection<FunctionMethod>> udfs,
+				MetadataRepository metadataRepo) {
+			this.udfs = udfs;
+			this.metadataRepo = metadataRepo;
+		}
+	}
+	
 	public interface ReplicatedCache<K, V> extends Cache<K, V>  {
 		
 		@Replicated(replicateState=ReplicationMode.PULL)
@@ -366,52 +378,45 @@
 	}
 	
 	public void deployVDB(String vdbName, String vdbPath) throws Exception {
-		IndexMetadataStore imf = VDBMetadataFactory.loadMetadata(vdbName, new File(vdbPath).toURI().toURL());
-        deployVDB(vdbName, imf, null, null);		
+        deployVDB(vdbName, vdbPath, new DeployVDBParameter(null, null));		
 	}	
 
-	public void deployVDB(String vdbName, String vdbPath, MetadataRepository metadataRepo) throws Exception {
+	public void deployVDB(String vdbName, String vdbPath, DeployVDBParameter parameterObject) throws Exception {
 		IndexMetadataStore imf = VDBMetadataFactory.loadMetadata(vdbName, new File(vdbPath).toURI().toURL());
-        deployVDB(vdbName, imf, null, metadataRepo);		
+        deployVDB(vdbName, imf, parameterObject);		
 	}
 	
-	public void deployVDB(String vdbName, String vdbPath, Map<String, Collection<FunctionMethod>> udfs) throws Exception {
-		IndexMetadataStore imf = VDBMetadataFactory.loadMetadata(vdbName, new File(vdbPath).toURI().toURL());
-        deployVDB(vdbName, imf, udfs, null);		
-	}
-	
 	public void deployVDB(String vdbName, MetadataStore metadata) {
-		deployVDB(vdbName, metadata, null, null);
+		deployVDB(vdbName, metadata, new DeployVDBParameter(null, null));
 	}
 
-	public void deployVDB(String vdbName, MetadataStore metadata, Map<String, Collection<FunctionMethod>> udfs, MetadataRepository metadataRepo) {
+	public void deployVDB(String vdbName, MetadataStore metadata, DeployVDBParameter parameterObject) {
 		VDBMetaData vdbMetaData = new VDBMetaData();
         vdbMetaData.setName(vdbName);
         vdbMetaData.setStatus(VDB.Status.ACTIVE);
         
-        for (Schema schema : repo.getSystemStore().getSchemas().values()) {
-        	addModel(vdbMetaData, schema); 
-        }
-        
-        for (Schema schema : repo.getODBCStore().getSchemas().values()) {
-        	addModel(vdbMetaData, schema); 
-        }        
-        
         for (Schema schema : metadata.getSchemas().values()) {
         	ModelMetaData model = addModel(vdbMetaData, schema);
-        	if (metadataRepo != null) {
-        		model.addAttchment(MetadataRepository.class, metadataRepo);
+        	if (parameterObject.metadataRepo != null) {
+        		model.addAttchment(MetadataRepository.class, parameterObject.metadataRepo);
         	}
         }
                         
         try {
         	UDFMetaData udfMetaData = null;
-        	if (udfs != null) {
+        	if (parameterObject.udfs != null) {
         		udfMetaData = new UDFMetaData();
-        		for (Map.Entry<String, Collection<FunctionMethod>> entry : udfs.entrySet()) {
+        		for (Map.Entry<String, Collection<FunctionMethod>> entry : parameterObject.udfs.entrySet()) {
         			udfMetaData.addFunctions(entry.getKey(), entry.getValue());
         		}
         	}
+        	
+        	if (parameterObject.vdbImports != null) {
+        		for (VDBImportMetadata vdbImport : parameterObject.vdbImports) {
+					vdbMetaData.getVDBImports().add(vdbImport);
+				}
+        	}
+        	
 			this.repo.addVDB(vdbMetaData, metadata, (metadata instanceof IndexMetadataStore)?((IndexMetadataStore)metadata).getEntriesPlusVisibilities():null, udfMetaData, cmr);
 			this.repo.finishDeployment(vdbMetaData.getName(), vdbMetaData.getVersion());
 			this.repo.getVDB(vdbMetaData.getName(), vdbMetaData.getVersion()).setStatus(VDB.Status.ACTIVE);
@@ -440,11 +445,6 @@
 		this.repo.removeVDB(vdbName, 1);
 	}
 	
-	public void mergeVDBS(String sourceVDB, String targetVDB) throws AdminException {
-		this.repo.mergeVDBs(sourceVDB, 1, targetVDB, 1);
-		this.repo.getVDB(targetVDB, 1).setStatus(VDB.Status.ACTIVE);
-	}
-	
 	public ConnectionImpl createConnection(String embeddedURL) throws Exception {
 		final Properties p = new Properties();
 		TeiidDriver.parseURL(embeddedURL, p);

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -47,6 +47,7 @@
 import org.teiid.core.util.UnitTestUtil;
 import org.teiid.dqp.internal.datamgr.ConnectorManager;
 import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.jdbc.FakeServer.DeployVDBParameter;
 import org.teiid.language.Command;
 import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.FunctionParameter;
@@ -163,7 +164,7 @@
     	FunctionMethod function = new FunctionMethod("foo", null, FunctionCategoryConstants.MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, TestLocalConnections.class.getName(), "blocking", null, new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER), false, FunctionMethod.Determinism.NONDETERMINISTIC);
     	HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
     	udfs.put("test", Arrays.asList(function));
-    	server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb", udfs);
+    	server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb", new DeployVDBParameter(udfs, null));
 	}
 	
 	@AfterClass public static void oneTimeTearDown() {

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-05-23 17:18:52 UTC (rev 4136)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -1,9 +1,12 @@
 package org.teiid.jdbc;
 
 import java.sql.SQLException;
+import java.util.Arrays;
 
 import org.junit.Test;
+import org.teiid.adminapi.impl.VDBImportMetadata;
 import org.teiid.core.util.UnitTestUtil;
+import org.teiid.jdbc.FakeServer.DeployVDBParameter;
 
 
 @SuppressWarnings("nls")
@@ -47,25 +50,18 @@
        executeTest("select * from tables where schemaname='BQT1'", expectedBefore); //$NON-NLS-1$
        
        this.internalConnection.close();
-       
+
        server.deployVDB(VDB2, UnitTestUtil.getTestDataPath()+"/QT_Ora9DS_1.vdb");
+
+       DeployVDBParameter param = new DeployVDBParameter(null, null);
+       VDBImportMetadata vdbImport = new VDBImportMetadata();
+       vdbImport.setName(VDB2);
+       param.vdbImports = Arrays.asList(vdbImport);
+       server.removeVDB(VDB1);
+       server.deployVDB(VDB1, UnitTestUtil.getTestDataPath()+"/QT_Ora9DS_1.vdb", param);
        
-       server.mergeVDBS(VDB2, VDB1);
-       
        this.internalConnection = server.createConnection("jdbc:teiid:"+VDB1);
        executeTest("select * from tables where schemaname='BQT1' order by name", expectedAfter); //$NON-NLS-1$
-       
-       server.undeployVDB(VDB2);
-       
-       // since the connection is not closed; need to behave as if still merged
-       executeTest("select * from tables where schemaname='BQT1' order by name", expectedAfter); //$NON-NLS-1$
-       
-       // re-connect should behave as the original
-       this.internalConnection.close();
-       this.internalConnection = server.createConnection("jdbc:teiid:"+VDB1);
-       
-       executeTest("select * from tables where schemaname='BQT1'", expectedBefore); //$NON-NLS-1$
-       executeTest("select * from tables where schemaname ='PartsSupplier'", expected); //$NON-NLS-1$
     }
 	
     private void executeTest(String sql, String[] expected) throws SQLException{
@@ -92,7 +88,12 @@
         
         server.deployVDB(VDB2, UnitTestUtil.getTestDataPath()+"/QT_Ora9DS_1.vdb");
         
-        server.mergeVDBS(VDB2, "empty");
+        DeployVDBParameter param = new DeployVDBParameter(null, null);
+        VDBImportMetadata vdbImport = new VDBImportMetadata();
+        vdbImport.setName(VDB2);
+        param.vdbImports = Arrays.asList(vdbImport);
+        server.undeployVDB("empty");
+        server.deployVDB("empty", UnitTestUtil.getTestDataPath() + "/empty.vdb", param);
 
         String[] expectedAfter = {
         		"VDBName[string]    SchemaName[string]    Name[string]    Type[string]    NameInSource[string]    IsPhysical[boolean]    SupportsUpdates[boolean]    UID[string]    Cardinality[integer]    Description[string]    IsSystem[boolean]    IsMaterialized[boolean]    OID[integer]",

Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -40,6 +40,7 @@
 import org.teiid.core.util.UnitTestUtil;
 import org.teiid.jdbc.FakeServer;
 import org.teiid.jdbc.TeiidSQLException;
+import org.teiid.jdbc.FakeServer.DeployVDBParameter;
 import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.FunctionParameter;
 import org.teiid.metadata.FunctionMethod.Determinism;
@@ -69,7 +70,7 @@
     	server = new FakeServer();
     	HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
     	udfs.put("funcs", Arrays.asList(new FunctionMethod("pause", null, null, PushDown.CANNOT_PUSHDOWN, TestMatViews.class.getName(), "pause", null, new FunctionParameter("return", DataTypeManager.DefaultDataTypes.INTEGER), true, Determinism.NONDETERMINISTIC)));
-    	server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() + "/matviews.vdb", udfs);
+    	server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() + "/matviews.vdb", new DeployVDBParameter(udfs, null));
     	conn = server.createConnection("jdbc:teiid:matviews");
     }
 	

Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -37,6 +37,7 @@
 import org.mockito.stubbing.Answer;
 import org.teiid.core.util.UnitTestUtil;
 import org.teiid.jdbc.FakeServer;
+import org.teiid.jdbc.FakeServer.DeployVDBParameter;
 import org.teiid.metadata.DefaultMetadataRepository;
 import org.teiid.metadata.Procedure;
 import org.teiid.metadata.Table;
@@ -50,7 +51,7 @@
     
 	@BeforeClass public static void setUp() throws Exception {
     	FakeServer server = new FakeServer();    	
-    	server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/metadata.vdb", getMetadataRepo());
+    	server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/metadata.vdb", new DeployVDBParameter(null, getMetadataRepo()));
     	connection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$ //$NON-NLS-2$		
     }
 

Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java	2012-05-23 17:18:52 UTC (rev 4136)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java	2012-05-23 21:51:53 UTC (rev 4137)
@@ -41,6 +41,7 @@
 import org.teiid.core.util.UnitTestUtil;
 import org.teiid.dqp.internal.process.DQPConfiguration;
 import org.teiid.jdbc.FakeServer;
+import org.teiid.jdbc.FakeServer.DeployVDBParameter;
 import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.FunctionParameter;
 import org.teiid.metadata.FunctionMethod.Determinism;
@@ -145,7 +146,7 @@
 		server.start(new DQPConfiguration(), true);
     	HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
     	udfs.put("funcs", Arrays.asList(new FunctionMethod("pause", null, null, PushDown.CANNOT_PUSHDOWN, TestMatViews.class.getName(), "pause", null, new FunctionParameter("return", DataTypeManager.DefaultDataTypes.INTEGER), true, Determinism.NONDETERMINISTIC)));
-    	server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() + "/matviews.vdb", udfs);
+    	server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() + "/matviews.vdb", new DeployVDBParameter(udfs, null));
 		return server;
 	}
 	



More information about the teiid-commits mailing list