[teiid-commits] teiid SVN: r1865 - in branches/JCA: client/src/main/resources and 14 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Feb 19 18:36:37 EST 2010


Author: rareddy
Date: 2010-02-19 18:36:36 -0500 (Fri, 19 Feb 2010)
New Revision: 1865

Added:
   branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java
   branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
   branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java
   branches/JCA/client/src/main/resources/vdb-deployer.xsd
   branches/JCA/client/src/test/java/org/teiid/adminapi/
   branches/JCA/client/src/test/java/org/teiid/adminapi/impl/
   branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
Removed:
   branches/JCA/client/src/test/java/com/metamatrix/admin/api/objects/
   branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/client/
   branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/authorization/service/
   branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/membership/service/
   branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/membership/spi/file/
   branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/membership/spi/ldap/
   branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/
   branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/
   branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/
   branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/services/
   branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/membership/service/
   branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/membership/spi/file/
   branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/membership/spi/ldap/
   branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/
Modified:
   branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
   branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java
   branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
   branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
Log:
TEIID-998: Adding the schema file, and XML annotations to the vdb metadata objects to confirm to new VDB deployment XML file

Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java	2010-02-19 21:57:25 UTC (rev 1864)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java	2010-02-19 23:36:36 UTC (rev 1865)
@@ -22,18 +22,27 @@
 package org.teiid.adminapi.impl;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
 import org.teiid.adminapi.AdminObject;
 
-public class AdminObjectImpl implements AdminObject, Serializable {
+ at XmlAccessorType(XmlAccessType.NONE)
+public abstract class AdminObjectImpl implements AdminObject, Serializable {
 
 	private static final long serialVersionUID = -6381303538713462682L;
-	String name;
-	Properties properties;
+	
+	private String name;
+		
+	private List<PropertyMetadata> properties;
+	
 	private transient Map<String, Object> attachments = Collections.synchronizedMap(new HashMap<String, Object>());
 		
 	@Override
@@ -47,23 +56,50 @@
 
 	@Override
 	public Properties getProperties() {
+		if (this.properties == null) {
+			return null;
+		}
+		
+		Properties props = new Properties();
+		for (PropertyMetadata p:this.properties) {
+			props.setProperty(p.getName(), p.getValue());
+		}
+		return props;
+	}
+	
+	protected List<PropertyMetadata> getPropertiesDirect(){
 		return this.properties;
 	}
+	
+	protected void setPropertiesDirect(List<PropertyMetadata> props){
+		this.properties = props;
+	}	
 
 	@Override
 	public String getPropertyValue(String name) {
-		return this.properties.getProperty(name);
+		if (this.properties == null) {
+			return null;
+		}
+		
+		for (PropertyMetadata p:this.properties) {
+			if (p.getName().equals(name)) {
+				return p.getValue();
+			}
+		}
+		return null;
 	}
 
-	public void setProperties(Properties properties) {
-		this.properties = new Properties(properties);
+	public void setProperties(Properties props) {
+		for (String key:props.stringPropertyNames()) {
+			addProperty(key, props.getProperty(key));
+		}
 	}
 	
 	public void addProperty(String key, String value) {
 		if (this.properties == null) {
-			this.properties = new Properties();
+			this.properties = new ArrayList<PropertyMetadata>();
 		}
-		this.properties.setProperty(key, value);
+		this.properties.add(new PropertyMetadata(key, value));
 	}
 	
 	   /**
@@ -144,5 +180,6 @@
 		      if (result == null)
 		         return null;
 		      return result;  
-	   }		   
+	   }		
+	   	   
 }

Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java	2010-02-19 21:57:25 UTC (rev 1864)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java	2010-02-19 23:36:36 UTC (rev 1865)
@@ -60,6 +60,6 @@
 	}
 	
 	public String toString() {
-		return name;
+		return getName();
 	}
 }

Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java	                        (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java	2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,163 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+
+
+/**
+ * <pre>
+ * &lt;complexType>
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         &lt;element name="resource-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         &lt;element name="allow-create" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         &lt;element name="allow-read" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         &lt;element name="allow-update" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         &lt;element name="allow-delete" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         &lt;choice minOccurs="0">
+ *           &lt;element name="security-role-name" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
+ *           &lt;element name="security-role-ref" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         &lt;/choice>
+ *       &lt;/sequence>
+ *       &lt;attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "", propOrder = {
+    "description",
+    "resourceName",
+    "allowCreate",
+    "allowRead",
+    "allowUpdate",
+    "allowDelete",
+    "securityRoleNames",
+    "securityRoleRef"
+})
+ at ManagementObject
+public class DataRoleMetadata {
+
+    @XmlAttribute(name = "name", required = true)
+    protected String name;
+	@XmlElement(name = "description")
+    protected String description;
+    @XmlElement(name = "resource-name", required = true)
+    protected String resourceName;
+    @XmlElement(name = "allow-create")
+    protected Boolean allowCreate;
+    @XmlElement(name = "allow-read")
+    protected Boolean allowRead;
+    @XmlElement(name = "allow-update")
+    protected Boolean allowUpdate;
+    @XmlElement(name = "allow-delete")
+    protected Boolean allowDelete;
+    @XmlElement(name = "security-role-name")
+    protected List<String> securityRoleNames;
+    @XmlElement(name = "security-role-ref")
+    protected String securityRoleRef;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String value) {
+        this.name = value;
+    }
+    
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String value) {
+        this.description = value;
+    }
+
+    public String getResourceName() {
+        return resourceName;
+    }
+
+    public void setResourceName(String value) {
+        this.resourceName = value;
+    }
+
+    public Boolean isAllowCreate() {
+        return allowCreate;
+    }
+
+    public void setAllowCreate(Boolean value) {
+        this.allowCreate = value;
+    }
+
+    public Boolean isAllowRead() {
+        return allowRead;
+    }
+
+    public void setAllowRead(Boolean value) {
+        this.allowRead = value;
+    }
+
+    public Boolean isAllowUpdate() {
+        return allowUpdate;
+    }
+
+    public void setAllowUpdate(Boolean value) {
+        this.allowUpdate = value;
+    }
+
+    public Boolean isAllowDelete() {
+        return allowDelete;
+    }
+
+    public void setAllowDelete(Boolean value) {
+        this.allowDelete = value;
+    }
+
+    public List<String> getSecurityRoleNames() {
+        if (this.securityRoleNames == null) {
+            this.securityRoleNames = new ArrayList<String>();
+        }
+        return this.securityRoleNames;
+    }
+
+    public String getSecurityRoleRef() {
+        return securityRoleRef;
+    }
+
+    public void setSecurityRoleRef(String value) {
+        this.securityRoleRef = value;
+    }
+}

Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java	2010-02-19 21:57:25 UTC (rev 1864)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java	2010-02-19 23:36:36 UTC (rev 1865)
@@ -26,6 +26,12 @@
 import java.util.List;
 import java.util.Properties;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.managed.api.annotation.ManagementObjectID;
@@ -35,12 +41,43 @@
 
 import com.metamatrix.core.vdb.ModelType;
 
+/**
+ * <pre>
+ * &lt;complexType>
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="property" type="{}property" maxOccurs="unbounded" minOccurs="0"/>
+ *         &lt;choice minOccurs="0">
+ *           &lt;element name="connector-name" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
+ *           &lt;element name="connector-ref" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         &lt;/choice>
+ *       &lt;/sequence>
+ *       &lt;attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.NONE)
+ at XmlType(name = "", propOrder = {
+    "propertiesDirect",
+    "connectorBindings",
+    "connectorReference"
+})
 @ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="model"))
 public class ModelMetaData extends AdminObjectImpl implements Model {
 
 	private static final long serialVersionUID = 3714234763056162230L;
+	
+	@XmlElement(name = "connector-name")
 	private List<String> connectorBindings = new ArrayList<String>(); 
-    private String modelType = ""; //$NON-NLS-1$
+	
+    @XmlElement(name = "connector-ref")
+    protected String connectorReference;	
+    
+	private String modelType = ""; //$NON-NLS-1$
 	private String modelURI = ""; //$NON-NLS-1$
     private boolean supportsMultiSourceBindings = false;
     private String path;
@@ -49,16 +86,31 @@
     
 	@ManagementProperty(description="Model Name", readOnly=true)
 	@ManagementObjectID(type="model")
+	@XmlAttribute(name = "name", required = true)
 	public String getName() {
 		return super.getName();
 	}    
 
+	// This is needed by JAXB
+	public void setName(String name) {
+		super.setName(name);
+	}
 	
     @ManagementProperty(description="Connector Bindings for model")
     public List<String> getConnectorBindingNames(){
 		return this.connectorBindings;
 	}
+    
+    @ManagementProperty(description="Connector Binding Reference")
+    public String getConnectorReference() {
+		return connectorReference;
+	}
 
+
+	public void setConnectorReference(String connectorReference) {
+		this.connectorReference = connectorReference;
+	}    
+
 	@Override
 	@ManagementProperty(description = "Is Model Source model", readOnly=true)
     public boolean isSource() {
@@ -110,6 +162,17 @@
         return new Properties(super.getProperties());
     }		
 	
+	@Override
+	@XmlElement(name = "property", type = PropertyMetadata.class)
+	protected List<PropertyMetadata> getPropertiesDirect(){
+		return super.getPropertiesDirect();
+	}
+	
+	// This is needed by the JAXB
+	protected void setPropertiesDirect(List<PropertyMetadata> props){
+		super.setPropertiesDirect(props);
+	}	
+	
 	public void addConnectorBinding(String binding) {
 		this.connectorBindings.add(binding);
 	}
@@ -141,7 +204,7 @@
     }      
     
     public String toString() {
-    	return name + connectorBindings;
+    	return getName() + connectorBindings;
     }
     
     public Visibility getVisibility(){

Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java	                        (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java	2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,76 @@
+/*
+ * 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 javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <pre>
+ * &lt;complexType name="property">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.NONE)
+ at XmlType(name = "property")
+public class PropertyMetadata {
+
+    @XmlAttribute(name = "name", required = true)
+    protected String name;
+    @XmlAttribute(name = "value", required = true)
+    protected String value;
+    
+    public PropertyMetadata() {
+    }
+    
+    public PropertyMetadata(String key, String value) {
+ 	   this.name = key;
+ 	   this.value = value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public void setValue(String value) {
+		this.value = value;
+	}
+}
\ No newline at end of file

Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java	                        (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java	2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,82 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+
+
+/**
+ * <pre>
+ * &lt;complexType name="reference-mapping">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="ref-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.NONE)
+ at XmlType(name = "reference-mapping", propOrder = {
+    "refName",
+    "names"
+})
+ at ManagementObject
+public class ReferenceMappingMetadata {
+
+    @XmlElement(name = "ref-name", required = true)
+    protected String refName;
+ 
+    @XmlElement(name = "name", required = true)
+    protected List<String> names;
+
+    public String getRefName() {
+        return refName;
+    }
+
+    public void setRefName(String value) {
+        this.refName = value;
+    }
+
+    public List<String> getNames() {
+        if (this.names == null) {
+            this.names = new ArrayList<String>();
+        }
+        return this.names;
+    }
+    
+    public void addName(String name) {
+    	getNames().add(name);
+    }
+}

Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java	2010-02-19 21:57:25 UTC (rev 1864)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java	2010-02-19 23:36:36 UTC (rev 1865)
@@ -25,8 +25,16 @@
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Properties;
 import java.util.Set;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.managed.api.annotation.ManagementObjectID;
@@ -39,16 +47,41 @@
 import com.metamatrix.core.vdb.ModelType;
 
 @ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="vdb"))
+ at XmlAccessorType(XmlAccessType.NONE)
+ at XmlType(name = "", propOrder = {
+    "description",
+    "propertiesDirect",
+    "models",
+    "connectorMappings",
+    "dataRoles",
+    "securityRoleMappings"
+})
+ at XmlRootElement(name = "vdb")
 public class VDBMetaData extends AdminObjectImpl implements VDB {
-
 	private static final long serialVersionUID = -4723595252013356436L;
+	
+	@XmlElement(name = "model", required = true, type = ModelMetaData.class)
 	private HashSet<ModelMetaData> models = new HashSet<ModelMetaData>();
-	private String fileUrl = null;
+	 
+	@XmlAttribute(name = "version", required = true)
 	private int version = 1;
-	private Status status;
+	
+	@XmlElement(name = "description")
 	private String description;
-	private List<String> errors;
 	
+    @XmlElement(name = "connector-mapping")
+    protected List<ReferenceMappingMetadata> connectorMappings;
+    
+	@XmlElement(name = "data-role")
+    protected List<DataRoleMetadata> dataRoles;
+    
+    @XmlElement(name = "security-role-mapping")
+    protected List<ReferenceMappingMetadata> securityRoleMappings;	
+	
+    private List<String> errors;
+	private String fileUrl = null;
+	private Status status;
+	
 	public VDBMetaData() {
 		// auto add sytem model.
 		ModelMetaData system = new ModelMetaData();
@@ -64,10 +97,16 @@
 
 	@ManagementProperty(description="Name of the VDB", readOnly=true)
 	@ManagementObjectID(type="vdb")
+	@XmlAttribute(name = "name", required = true)
 	public String getName() {
 		return super.getName();
 	}
 	
+	// This needed by JAXB marshaling
+	public void setName(String name) {
+		super.setName(name);
+	} 
+	
 	@Override
 	@ManagementProperty(description="VDB Status", readOnly=true)
 	public Status getStatus() {
@@ -158,7 +197,7 @@
     } 	
     
 	public String toString() {
-		return this.name + models;
+		return getName() + models;
 	}
 
 	@ManagementOperation(description = "Get the model with given name")		
@@ -180,4 +219,46 @@
 		}
 		return list;
 	}
+	
+	@ManagementProperty(description="Connector reference mappings", managed=true)
+    public List<ReferenceMappingMetadata> getConnectorMappings() {
+		return this.connectorMappings;
+	}	
+    
+    public void addConnectorMapping(ReferenceMappingMetadata data) {
+    	if (this.connectorMappings == null) {
+    		this.connectorMappings = new ArrayList<ReferenceMappingMetadata>();
+    	}
+    	this.connectorMappings.add(data);
+    }
+    
+    @ManagementProperty(description="Security refrence mappings", managed=true)
+	public List<ReferenceMappingMetadata> getSecurityRoleMappings() {
+		return securityRoleMappings;
+	}    
+	
+	public void addSecurityRoleMapping(ReferenceMappingMetadata data) {
+		if (this.securityRoleMappings == null) {
+			this.securityRoleMappings = new ArrayList<ReferenceMappingMetadata>();
+		}
+		this.securityRoleMappings.add(data);
+	}
+	
+	@Override
+	@ManagementProperty(description = "Properties", readOnly=true)
+    public Properties getProperties() {
+        return new Properties(super.getProperties());
+    }		
+	
+	@Override
+	@XmlElement(name = "property", type = PropertyMetadata.class)
+	protected List<PropertyMetadata> getPropertiesDirect(){
+		return super.getPropertiesDirect();
+	}
+	
+	// This is needed by the JAXB
+	protected void setPropertiesDirect(List<PropertyMetadata> props){
+		super.setPropertiesDirect(props);
+	}	
+	
 }

Added: branches/JCA/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- branches/JCA/client/src/main/resources/vdb-deployer.xsd	                        (rev 0)
+++ branches/JCA/client/src/main/resources/vdb-deployer.xsd	2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
+	<xs:element name="vdb">
+		<xs:annotation>
+			<xs:documentation>Describes the configuration for a VDB</xs:documentation>
+		</xs:annotation>
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element name="description" type="xs:string" minOccurs="0"/>
+				<xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
+				<xs:element name="model" maxOccurs="unbounded">
+					<xs:complexType>
+						<xs:sequence>
+							<xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
+							<xs:choice minOccurs="0">
+								<xs:element name="connector-name" type="xs:string" maxOccurs="unbounded"/>
+								<xs:element name="connector-ref" type="xs:string"/>
+							</xs:choice>
+						</xs:sequence>
+						<xs:attribute name="name" type="xs:string" use="required"/>
+					</xs:complexType>
+				</xs:element>
+				<xs:element name="connector-mapping" type="reference-mapping" minOccurs="0" maxOccurs="unbounded"/>
+				<xs:element name="data-role" minOccurs="0" maxOccurs="unbounded">
+					<xs:complexType>
+						<xs:sequence>
+							<xs:element name="description" type="xs:string" minOccurs="0"/>
+							<xs:element name="resource-name" type="xs:string"/>
+							<xs:element name="allow-create" type="xs:boolean" minOccurs="0"/>
+							<xs:element name="allow-read" type="xs:boolean" minOccurs="0"/>
+							<xs:element name="allow-update" type="xs:boolean" minOccurs="0"/>
+							<xs:element name="allow-delete" type="xs:boolean" minOccurs="0"/>
+							<xs:choice minOccurs="0">
+								<xs:element name="security-role-name" type="xs:string" maxOccurs="unbounded"/>
+								<xs:element name="security-role-ref" type="xs:string"/>
+							</xs:choice>
+						</xs:sequence>
+						<xs:attribute name="name" type="xs:string" use="required"/>
+					</xs:complexType>
+				</xs:element>
+				<xs:element name="security-role-mapping" type="reference-mapping" minOccurs="0" maxOccurs="unbounded"/>
+			</xs:sequence>
+			<xs:attribute name="name" type="xs:string" use="required"/>
+			<xs:attribute name="version" type="xs:int" use="required"/>
+		</xs:complexType>
+	</xs:element>
+	<xs:complexType name="property">
+		<xs:annotation>
+			<xs:documentation> property</xs:documentation>
+		</xs:annotation>
+		<xs:attribute name="name" type="xs:string" use="required"/>
+		<xs:attribute name="value" type="xs:string" use="required"/>
+	</xs:complexType>
+	<xs:complexType name="reference-mapping">
+		<xs:sequence>
+			<xs:element name="ref-name" type="xs:string"/>
+			<xs:element name="name" type="xs:string" maxOccurs="unbounded"/>
+		</xs:sequence>
+	</xs:complexType>
+</xs:schema>

Added: branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java	                        (rev 0)
+++ branches/JCA/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java	2010-02-19 23:36:36 UTC (rev 1865)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.junit.Test;
+
+
+public class TestVDBMetaData {
+
+	@Test
+	public void testMarshellUnmarshell() throws Exception {
+		
+		VDBMetaData vdb = new VDBMetaData();
+		vdb.setName("myVDB");
+		vdb.setDescription("vdb description");
+		vdb.setVersion(1);
+		vdb.addProperty("vdb-property", "vdb-value");
+		
+		ModelMetaData modelOne = new ModelMetaData();
+		modelOne.setName("model-one");
+		modelOne.addConnectorBinding("java:mybinding");
+		modelOne.setModelType("physical");
+		modelOne.addProperty("model-prop", "model-value");
+		
+		vdb.addModel(modelOne);
+		
+		ModelMetaData modelTwo = new ModelMetaData();
+		modelTwo.setName("model-two");
+		modelTwo.setConnectorReference("binding-two-ref");
+		modelTwo.addProperty("model-prop", "model-value");
+		
+		vdb.addModel(modelTwo);
+		
+		ReferenceMappingMetadata ref = new ReferenceMappingMetadata();
+		ref.setRefName("binding-two-ref");
+		ref.addName("java:binding-one");
+		ref.addName("java:binding-two");
+		vdb.addConnectorMapping(ref);
+		
+		JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
+		Marshaller marshell = jc.createMarshaller();
+		marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
+		
+		StringWriter sw = new StringWriter();
+		marshell.marshal(vdb, sw);
+		Unmarshaller un = jc.createUnmarshaller();
+
+		//System.out.println(sw.toString());
+		
+		vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
+		
+		assertEquals("myVDB", vdb.getName());
+		assertEquals("vdb description", vdb.getDescription());
+		assertEquals(1, vdb.getVersion());
+		assertEquals("vdb-value", vdb.getPropertyValue("vdb-property"));
+		
+		assertNotNull(vdb.getModel("model-one"));
+		assertNotNull(vdb.getModel("model-two"));
+		assertNull(vdb.getModel("model-unknown"));
+		
+		modelOne = vdb.getModel("model-one");
+		assertEquals("model-one", modelOne.getName());
+		assertTrue(modelOne.getConnectorBindingNames().contains("java:mybinding"));
+		assertEquals("", modelOne.getModelType()); // this is not persisted in the XML
+		assertEquals("model-value", modelOne.getPropertyValue("model-prop"));
+
+		
+		modelTwo = vdb.getModel("model-two");
+		assertEquals("model-two", modelTwo.getName());
+		assertTrue(modelTwo.getConnectorBindingNames().isEmpty());
+		assertEquals("binding-two-ref", modelTwo.getConnectorReference());
+		assertEquals("", modelTwo.getModelType()); // this is not persisted in the XML
+		assertEquals("model-value", modelTwo.getPropertyValue("model-prop"));
+		
+		
+		assertTrue(vdb.getConnectorMappings().size()==1);
+		ref = vdb.getConnectorMappings().get(0);
+		
+		assertEquals("binding-two-ref", ref.getRefName());
+		assertTrue(ref.getNames().contains("java:binding-one"));
+		assertTrue(ref.getNames().contains("java:binding-two"));
+	}
+}



More information about the teiid-commits mailing list