Author: tejones
Date: 2010-06-07 18:17:39 -0400 (Mon, 07 Jun 2010)
New Revision: 2188
Modified:
trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
trunk/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-1105: Added Translator Override table and properties to the VDB tab
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-06-07 16:50:55
UTC (rev 2187)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-06-07 22:17:39
UTC (rev 2188)
@@ -42,6 +42,7 @@
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.CompositeValueSupport;
import org.jboss.metatype.api.values.EnumValueSupport;
import org.jboss.metatype.api.values.GenericValue;
import org.jboss.metatype.api.values.GenericValueSupport;
@@ -64,6 +65,7 @@
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.teiid.adminapi.impl.PropertyMetadata;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.comm.ConnectionConstants;
import org.teiid.rhq.plugin.util.PluginConstants;
@@ -98,13 +100,13 @@
protected void setOperationArguments(String name,
Configuration configuration, Map<String, Object> valueMap) {
// Parameter logic for VDB Metrics
- String key = VDB.NAME;
+ String key = VDB.NAME;
valueMap.put(key, this.resourceConfiguration.getSimpleValue("name",
null));
- String version = VDB.VERSION;
- valueMap.put(version, this.resourceConfiguration.getSimpleValue("version",
- null));
-
+ String version = VDB.VERSION;
+ valueMap.put(version, this.resourceConfiguration.getSimpleValue(
+ "version", null));
+
// Parameter logic for VDB Operations
if (name.equals(VDB.Operations.KILL_REQUEST)) {
valueMap.put(Operation.Value.REQUEST_ID, configuration.getSimple(
@@ -144,7 +146,7 @@
protected void setMetricArguments(String name, Configuration configuration,
Map<String, Object> valueMap) {
// Parameter logic for VDB Metrics
- String key = VDB.NAME;
+ String key = VDB.NAME;
valueMap.put(key, this.resourceConfiguration.getSimpleValue("name",
null));
}
@@ -274,18 +276,19 @@
sourceMappingList.add(singleSourceModelsPropertyList);
sourceMappingList.add(multiSourceModelsPropertyList);
PropertyMap model = null;
- Iterator<List<Property>> sourceMappingListIterator =
sourceMappingList.iterator();
+ Iterator<List<Property>> sourceMappingListIterator = sourceMappingList
+ .iterator();
while (sourceMappingListIterator.hasNext()) {
List<Property> sourceList = sourceMappingListIterator.next();
for (int i = 0; i < sourceList.size(); i++) {
model = (PropertyMap) sourceList.get(i);
String sourceName = ((PropertySimple) model
.get("sourceName")).getStringValue(); //$NON-NLS-1$
- if (sourceName.equals("See below")) continue; //This is a multisource
model which we will handle separately
+ if (sourceName.equals("See below"))
+ continue; // This is a multisource model which we will
+ // handle separately
String modelName = ((PropertySimple) model.get("name")) //$NON-NLS-1$
- .getStringValue();
- String translatorName = ((PropertySimple) model
- .get("translatorName")).getStringValue(); //$NON-NLS-1$
+ .getStringValue();
String dsName = ((PropertySimple) model.get("jndiName")) //$NON-NLS-1$
.getStringValue();
@@ -309,13 +312,6 @@
String sName = ProfileServiceUtil.getSimpleValue(
mo, "name", String.class);//$NON-NLS-1$
if (sName.equals(sourceName)) {
-
- ManagedProperty translatorProperty = mo
- .getProperty("translatorName"); //$NON-NLS-1$
- translatorProperty.setValue(ProfileServiceUtil
- .wrap(SimpleMetaType.STRING,
- translatorName));
-
// set the jndi name for the ds.
ManagedProperty jndiProperty = mo
.getProperty("connectionJndiName"); //$NON-NLS-1$
@@ -382,6 +378,8 @@
configuration.put(new PropertySimple("status", vdbStatus));
configuration.put(new PropertySimple("url", vdbURL));
+ getTranslators(mcVdb, configuration);
+
getModels(mcVdb, configuration);
return configuration;
@@ -563,4 +561,88 @@
}
}
+ /**
+ * @param mcVdb
+ * @param configuration
+ * @throws Exception
+ */
+ private void getTranslators(ManagedComponent mcVdb,
+ Configuration configuration) {
+ // Get models from VDB
+ ManagedProperty property = mcVdb.getProperty("overrideTranslators");
+ if (property == null) {
+ return;
+ }
+ List<ManagedObject> translators = (List<ManagedObject>) MetaValueFactory
+ .getInstance().unwrap(property.getValue());
+ CollectionValueSupport valueSupport = (CollectionValueSupport) property
+ .getValue();
+ MetaValue[] metaValues = valueSupport.getElements();
+
+ PropertyList translatorsList = new PropertyList("translators");
+ configuration.put(translatorsList);
+
+ for (MetaValue value : metaValues) {
+ GenericValueSupport genValueSupport = (GenericValueSupport) value;
+ ManagedObjectImpl managedObject = (ManagedObjectImpl) genValueSupport
+ .getValue();
+
+ String translatorName = ProfileServiceUtil.getSimpleValue(
+ managedObject, "name", String.class);
+ String translatorType = ProfileServiceUtil.getSimpleValue(
+ managedObject, "type", String.class);
+ ManagedProperty properties = managedObject.getProperty("property");
+
+ if (properties != null) {
+ List<PropertyMetadata> props = (List<PropertyMetadata>) MetaValueFactory
+ .getInstance().unwrap(properties.getValue());
+ for (PropertyMetadata propertyMetaData : props) {
+ String propertyName = propertyMetaData.getName();
+ String propertyValue = propertyMetaData.getValue();
+ PropertyMap translatorMap = null;
+
+ translatorMap = new PropertyMap("translatorMap",
+ new PropertySimple("name", translatorName),
+ new PropertySimple("type", translatorType),
+ new PropertySimple("propertyName", propertyName),
+ new PropertySimple("propertyValue", propertyValue));
+ // Only want translator name and value to show up for the first row,
+ // so we will blank them out here.
+ translatorName = "";
+ translatorType = "";
+ translatorsList.add(translatorMap);
+ }
+ }
+ }
+ }
+
+ /**
+ * @param <T>
+ * @param pValue
+ * @param list
+ */
+ public static <T> void getPropertyValues(MetaValue pValue,
+ Collection<Map<String, String>> list) {
+ Map<String, String> map = new HashMap<String, String>();
+ list.add(map);
+ MetaType metaType = pValue.getMetaType();
+ if (metaType.isCollection()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
+ CompositeValueSupport compValue = ((CompositeValueSupport) value);
+ for (MetaValue propValue : compValue.values()) {
+ String propertyName = ((CompositeValueSupport) propValue)
+ .get("name").toString();
+ String propertyValue = ((CompositeValueSupport) propValue)
+ .get("value").toString();
+ map.put("name", propertyName);
+ map.put("value", propertyValue);
+ }
+ }
+ } else {
+ throw new IllegalStateException(pValue
+ + " is not a Collection type");
+ }
+ }
+
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-06-07
16:50:55 UTC (rev 2187)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-06-07
22:17:39 UTC (rev 2188)
@@ -106,7 +106,7 @@
null // Process info from a process scan
);
- // Get plugin config map for models
+ // Get plugin config map for properties
Configuration configuration = detail.getPluginConfiguration();
configuration.put(new PropertySimple("name", vdbName));
Modified: trunk/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-06-07 16:50:55 UTC (rev
2187)
+++ trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-06-07 22:17:39 UTC (rev
2188)
@@ -467,6 +467,23 @@
<c:simple-property name="url" type="string"
description="The Virtual Database URL" required="false"
readOnly="true" />
</c:group>
+ <c:group name="Translators" displayName="Translators"
hiddenByDefault="false">
+ <c:list-property name="translators" displayName="Overrides"
readOnly="true"
+ description="The translator overrides for this VDB">
+ <c:map-property name="map" description="Translator Overrides for
this VDB">
+ <c:simple-property name="name" displayName="Name"
+ description="Name of this translator instance"
required="true" readOnly="true" />
+ <c:simple-property name="type"
+ displayName="Translator type" description="Translator type"
+ required="false" readOnly="true" />
+ <c:simple-property name="propertyName"
+ displayName="Property Name" description="Property Name"
+ required="false" readOnly="true"/>
+ <c:simple-property name="propertyValue" displayName="Property
Value"
+ description="Property Value" required="false" />
+ </c:map-property>
+ </c:list-property>
+ </c:group>
<c:group name="Models" displayName="Models"
hiddenByDefault="false">
<c:list-property name="singleSourceModels" readOnly="true"
description="The source models for this VDB">