teiid SVN: r2153 - in trunk: build/kits/jboss-container/deploy/teiid and 5 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-05-25 12:27:10 -0400 (Tue, 25 May 2010)
New Revision: 2153
Added:
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplate.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplateInfo.java
Modified:
trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
trunk/client/src/main/java/org/teiid/adminapi/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplate.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplateInfo.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
Log:
TEIID-1080: adding "createDataSource, deleteDataSource, getDataSourceNames, getDataSourceTemplateNames" methods to the Admin API, to support the data source creation from the Designer. Added required templates for the jdbc to make the configuration simpler than what is provided by the container.
Modified: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-05-25 14:46:43 UTC (rev 2152)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-05-25 16:27:10 UTC (rev 2153)
@@ -74,7 +74,7 @@
currentName = connectionName;
Admin old = connections.put(connectionName, internalAdmin);
if (old != null) {
- System.out.println("Closing previous admin associated with " + connectionName);
+ System.out.println("Closing previous admin associated with " + connectionName); //$NON-NLS-1$
old.close();
}
}
@@ -97,7 +97,7 @@
fis = new FileInputStream("connection.properties"); //$NON-NLS-1$
props.load(fis);
} catch (IOException e) {
- log.log(Level.WARNING, "Could not load default connection properties.", e);
+ log.log(Level.WARNING, "Could not load default connection properties.", e); //$NON-NLS-1$
} finally {
if (fis != null) {
try {
@@ -109,12 +109,12 @@
p = props;
}
- @Doc(text = "Add a Translator")
- public static Translator addTranslator(
+ @Doc(text = "Create a Translator")
+ public static Translator createTranslator(
@Doc(text = "deployed name") String deployedName,
@Doc(text = "type name") String typeName,
Properties properties) throws AdminException {
- return getAdmin().addTranslator(deployedName, typeName, properties);
+ return getAdmin().createTranslator(deployedName, typeName, properties);
}
@Doc(text = "Adds a role to the specified policy")
@@ -189,10 +189,10 @@
return getAdmin().getTranslatorTemplateNames();
}
- @Doc(text = "Get all PropertyDefinitions for the given translator template")
+ @Doc(text = "Get all PropertyDefinitions for the given template")
public static Collection<PropertyDefinition> getTranslatorTemplatePropertyDefinitions(
@Doc(text = "template name") String templateName) throws AdminException {
- return getAdmin().getTranslatorTemplatePropertyDefinitions(templateName);
+ return getAdmin().getTemplatePropertyDefinitions(templateName);
}
@Doc(text = "Get the ProcessObject instances for the given identifier")
@@ -331,7 +331,7 @@
private static void writeFile(String deployedName, String fileName,
InputStream contents) throws IOException, AdminProcessingException {
if (contents == null) {
- throw new AdminProcessingException(deployedName + " not found for exporting");
+ throw new AdminProcessingException(deployedName + " not found for exporting");//$NON-NLS-1$
}
ObjectConverterUtil.write(contents, fileName);
}
@@ -359,11 +359,30 @@
}
}
}
+ @Doc(text = "Create a data source from supplied properties")
+ public static void createDataSource(@Doc(text = "deployed name")String deploymentName, @Doc(text = "template name")String templateName, @Doc(text = "properties")Properties properties) throws AdminException {
+ getAdmin().createDataSource(deploymentName, templateName, properties);
+ }
+
+ @Doc(text = "Delete data source")
+ public static void deleteDataSource(@Doc(text = "deployed name")String deployedName) throws AdminException{
+ getAdmin().deleteDataSource(deployedName);
+ }
+
+ @Doc(text = "Available data sources")
+ public static Collection<String> getDataSourceNames() throws AdminException{
+ return getAdmin().getDataSourceNames();
+ }
+ @Doc(text = "Available data source template names")
+ public static Set<String> getDataSourceTemplateNames() throws AdminException{
+ return getAdmin().getDataSourceTemplateNames();
+ }
+
@Doc(text = "Get the current Admin connection")
public static Admin getAdmin() {
if (internalAdmin == null) {
- throw new NullPointerException("Not connected. You must call a \"connectAsAdmin\" method or choose an active connection via \"useConnection\".");
+ throw new NullPointerException("Not connected. You must call a \"connectAsAdmin\" method or choose an active connection via \"useConnection\"."); //$NON-NLS-1$
}
return internalAdmin;
}
@@ -393,7 +412,7 @@
@Doc(text = "connection name") String name) {
Admin admin = connections.get(name);
if (admin == null) {
- System.out.println("Warning: connection is not active for " + name);
+ System.out.println("Warning: connection is not active for " + name); //$NON-NLS-1$
return;
}
internalAdmin = admin;
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml 2010-05-25 14:46:43 UTC (rev 2152)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml 2010-05-25 16:27:10 UTC (rev 2153)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!--
+
<bean name="connector-jdbc-xa-${project.version}" class="org.teiid.templates.connector.XaJdbcConnectorTemplate">
<property name="info"><inject bean="connector-jdbc-xa-templateinfo"/></property>
</bean>
@@ -10,13 +10,25 @@
<factory bean="DSDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.connector.XaJdbcConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-jdbc-xa-${project.version}</parameter>
+ <parameter class="java.lang.String">connector-jdbc-xa</parameter>
<parameter class="java.lang.String">Teiid JDBC XA Connector</parameter>
</constructor>
- <property name="rarName">connector-jdbc-${project.version}.rar</property>
</bean>
- -->
+ <bean name="connector-jdbc-${project.version}" class="org.teiid.templates.connector.LocalJdbcConnectorTemplate">
+ <property name="info"><inject bean="connector-jdbc-templateinfo"/></property>
+ </bean>
+
+ <bean name="connector-jdbc-templateinfo" class="org.teiid.templates.connector.LocalJdbcConnectorTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.LocalJdbcConnectorTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-jdbc</parameter>
+ <parameter class="java.lang.String">Teiid JDBC Connector</parameter>
+ </constructor>
+ </bean>
+
<bean name="connector-ldap-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
<property name="info"><inject bean="connector-ldap-templateinfo"/></property>
<property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
@@ -27,7 +39,7 @@
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
<parameter class="java.lang.String">connector-ldap-${project.version}</parameter>
- <parameter class="java.lang.String">Teiid LDAP Connector</parameter>
+ <parameter class="java.lang.String">LDAP Connection</parameter>
</constructor>
<property name="rarName">connector-ldap-${project.version}.rar</property>
</bean>
@@ -42,7 +54,7 @@
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
<parameter class="java.lang.String">connector-salesforce-${project.version}</parameter>
- <parameter class="java.lang.String">Teiid Salesforce Connector</parameter>
+ <parameter class="java.lang.String">Salesforce Connection</parameter>
</constructor>
<property name="rarName">connector-salesforce-${project.version}.rar</property>
</bean>
@@ -57,7 +69,7 @@
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
<parameter class="java.lang.String">connector-file-${project.version}</parameter>
- <parameter class="java.lang.String">Teiid File Connector</parameter>
+ <parameter class="java.lang.String">File Connection</parameter>
</constructor>
<property name="rarName">connector-file-${project.version}.rar</property>
</bean>
@@ -72,56 +84,9 @@
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
<parameter class="java.lang.String">connector-ws-${project.version}</parameter>
- <parameter class="java.lang.String">Teiid WS Connector</parameter>
+ <parameter class="java.lang.String">WS Connection</parameter>
</constructor>
<property name="rarName">connector-ws-${project.version}.rar</property>
</bean>
- <!--
- <bean name="connector-xmlsource-file-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
- <property name="info"><inject bean="connector-xmlsource-file-templateinfo"/></property>
- <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
- </bean>
- <bean name="connector-xmlsource-file-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-xmlsource-file-${project.version}</parameter>
- <parameter class="java.lang.String">Teiid XML File Connector</parameter>
- </constructor>
- <property name="rarName">connector-xmlsource-file-${project.version}.rar</property>
- </bean>
-
- <bean name="connector-xmlsource-soap-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
- <property name="info"><inject bean="connector-xmlsource-soap-templateinfo"/></property>
- <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
- </bean>
- <bean name="connector-xmlsource-soap-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-xmlsource-soap-${project.version}</parameter>
- <parameter class="java.lang.String">Teiid XML SOAP Connector</parameter>
- </constructor>
- <property name="rarName">connector-xmlsource-soap-${project.version}.rar</property>
- </bean>
-
- <bean name="connector-xml-http-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
- <property name="info"><inject bean="connector-xml-http-templateinfo"/></property>
- <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
- </bean>
- <bean name="connector-xml-http-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-xml-http-${project.version}</parameter>
- <parameter class="java.lang.String">Teiid XML HTTP Connector</parameter>
- </constructor>
- <property name="rarName">connector-xml-http-${project.version}.rar</property>
- </bean>
- -->
-
</deployment>
Modified: trunk/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-05-25 14:46:43 UTC (rev 2152)
+++ trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-05-25 16:27:10 UTC (rev 2153)
@@ -54,7 +54,7 @@
void setTranslatorProperty(String deployedName, String propertyName, String propertyValue) throws AdminException;
/**
- * Deploy a {@link Translator} to Configuration
+ * Create a {@link Translator}
*
* @param deployedName Translator name that will be added to Configuration
* @param templateName template name
@@ -62,7 +62,7 @@
* @throws AdminException
*/
- Translator addTranslator(String deployedName, String templateName, Properties properties) throws AdminException;
+ Translator createTranslator(String deployedName, String templateName, Properties properties) throws AdminException;
/**
* Delete the {@link Translator} from the Configuration
@@ -194,7 +194,7 @@
* @return
* @throws AdminException
*/
- Collection<PropertyDefinition> getTranslatorTemplatePropertyDefinitions(String templateName) throws AdminException;
+ Collection<PropertyDefinition> getTemplatePropertyDefinitions(String templateName) throws AdminException;
/**
@@ -286,4 +286,33 @@
*/
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
+ * @param properties - properties
+ * @throws AdminException
+ */
+ void createDataSource(String deploymentName, String templateName, Properties properties) throws AdminException;
+
+ /**
+ * Delete data source.
+ * @param deployedName
+ * @throws AdminException
+ */
+ void deleteDataSource(String deployedName) throws AdminException;
+
+ /**
+ * Returns the all names of all the data sources available in the configuration.
+ */
+ Collection<String> getDataSourceNames() throws AdminException;
+
+ /**
+ * Get the Datasource templates available in the configuration.
+ *
+ * @return Set of template names.
+ * @throws AdminException
+ */
+ Set<String> getDataSourceTemplateNames() throws AdminException;
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-05-25 14:46:43 UTC (rev 2152)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-05-25 16:27:10 UTC (rev 2153)
@@ -49,6 +49,7 @@
import org.jboss.metatype.api.values.CollectionValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.ProfileKey;
@@ -77,6 +78,7 @@
public class Admin extends TeiidAdmin {
private static final String TRANSLATOR_PREFIX = "translator-"; //$NON-NLS-1$
+ private static final String CONNECTOR_PREFIX = "connector-"; //$NON-NLS-1$
private static final ProfileKey DEFAULT_PROFILE_KEY = new ProfileKey(ProfileKey.DEFAULT);
private static final long serialVersionUID = 7081309086056911304L;
private static ComponentType VDBTYPE = new ComponentType("teiid", "vdb");//$NON-NLS-1$ //$NON-NLS-2$
@@ -85,6 +87,10 @@
private static ComponentType TRANSLATOR_TYPE = new ComponentType("teiid", "translator");//$NON-NLS-1$ //$NON-NLS-2$
private static AdminObjectBuilder AOB = new AdminObjectBuilder();
+ private static final String[] DS_TYPES = {"XA", "NoTx", "LocalTx"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] CF_TYPES = {"NoTx", "Tx"}; //$NON-NLS-1$ //$NON-NLS-2$
+
+
private ManagementView view;
private DeploymentManager deploymentMgr;
@@ -181,7 +187,7 @@
}
@Override
- public Translator addTranslator(String deploymentName, String typeName, Properties properties) throws AdminException {
+ public Translator createTranslator(String deploymentName, String typeName, Properties properties) throws AdminException {
try {
ManagedComponent mc = getView().getComponent(deploymentName, TRANSLATOR_TYPE);
if (mc != null) {
@@ -472,7 +478,7 @@
@Override
- public Collection<PropertyDefinition> getTranslatorTemplatePropertyDefinitions(String templateName) throws AdminException {
+ public Collection<PropertyDefinition> getTemplatePropertyDefinitions(String templateName) throws AdminException {
try {
DeploymentTemplateInfo info = getView().getTemplate(templateName);
if(info == null) {
@@ -671,4 +677,107 @@
throw new AdminComponentException(e.getMessage(), e);
}
}
+
+ private ManagedComponent getDatasource(String deployedName) throws Exception {
+ ManagedComponent mc = null;
+ for (String type:DS_TYPES) {
+ ComponentType ct = new ComponentType("DataSource", type); //$NON-NLS-1$
+ mc = getView().getComponent(deployedName, ct);
+ if (mc != null) {
+ return mc;
+ }
+ }
+ for (String type:CF_TYPES) {
+ ComponentType ct = new ComponentType("ConnectionFactory", type); //$NON-NLS-1$
+ mc = getView().getComponent(deployedName, ct);
+ if (mc != null) {
+ return mc;
+ }
+ }
+ return mc;
+ }
+
+
+ @Override
+ public void createDataSource(String deploymentName, String templateName, Properties properties) throws AdminException {
+ try {
+ ManagedComponent mc = getDatasource(deploymentName);
+ if (mc != null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("datasource_exists",deploymentName)); //$NON-NLS-1$;
+ }
+
+ DeploymentTemplateInfo info = getView().getTemplate(templateName);
+ if(info == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("datasource_template_not_found", templateName)); //$NON-NLS-1$
+ }
+
+ // template properties specific to the template
+ Map<String, ManagedProperty> propertyMap = info.getProperties();
+
+ // walk through the supplied properties and assign properly to template
+ for (String key:properties.stringPropertyNames()) {
+ ManagedProperty mp = propertyMap.get(key);
+ if (mp != null) {
+ String value = properties.getProperty(key);
+ if (!ManagedUtil.sameValue(mp.getDefaultValue(), value)){
+ mp.setValue(SimpleValueSupport.wrap(value));
+ }
+ }
+ }
+ info.getProperties().get("jndi-name").setValue(SimpleValueSupport.wrap(deploymentName)); //$NON-NLS-1$
+ getView().applyTemplate(deploymentName, info);
+ } catch (NoSuchDeploymentException e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ } catch(Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void deleteDataSource(String deployedName) throws AdminException {
+ try {
+ ManagedComponent mc = getDatasource(deployedName);
+ if (mc != null) {
+ ManagedUtil.removeArchive(getDeploymentManager(),mc.getDeployment().getName());
+ }
+ } catch (Exception e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ public Collection<String> getDataSourceNames() throws AdminException {
+ ArrayList<String> names = new ArrayList<String>();
+ try {
+ for (String type:DS_TYPES) {
+ ComponentType ct = new ComponentType("DataSource", type); //$NON-NLS-1$
+ Set<ManagedComponent> mcs = getView().getComponentsForType(ct);
+ for (ManagedComponent mc:mcs) {
+ names.add(((SimpleValue)mc.getProperty("jndi-name").getValue()).getValue().toString()); //$NON-NLS-1$
+ }
+ }
+ for (String type:CF_TYPES) {
+ ComponentType ct = new ComponentType("ConnectionFactory", type); //$NON-NLS-1$
+ Set<ManagedComponent> mcs = getView().getComponentsForType(ct);
+ for (ManagedComponent mc:mcs) {
+ names.add(((SimpleValue)mc.getProperty("jndi-name").getValue()).getValue().toString()); //$NON-NLS-1$
+ }
+ }
+ } catch (Exception e) {
+ throw new AdminComponentException(e);
+ }
+ return names;
+ }
+
+ @Override
+ public Set<String> getDataSourceTemplateNames() throws AdminException{
+ Set<String> names = getView().getTemplateNames();
+ HashSet<String> matched = new HashSet<String>();
+ for(String name:names) {
+ if (name.startsWith(CONNECTOR_PREFIX)) {
+ matched.add(name);
+ }
+ }
+ return matched;
+ }
}
Added: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplate.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplate.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplate.java 2010-05-25 16:27:10 UTC (rev 2153)
@@ -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.templates.connector;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.jboss.ManagedUtil;
+
+
+
+public class LocalJdbcConnectorTemplate extends org.jboss.resource.deployers.management.DsDataSourceTemplate {
+
+ @Override
+ public VirtualFile applyTemplate(DeploymentTemplateInfo values) throws Exception {
+
+ values.getProperties().get("connection-definition").setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "javax.sql.DataSource"));//$NON-NLS-1$ //$NON-NLS-2$
+ values.getProperties().get("dsType").setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "local-tx-datasource"));//$NON-NLS-1$ //$NON-NLS-2$
+
+ Map<String, String> configProperties = new HashMap<String, String>();
+ configProperties.put(ConnectorTemplateInfo.TEMPLATE_NAME, getInfo().getName());
+ values.getProperties().get("config-property").setValue(ManagedUtil.compositeValueMap(configProperties));//$NON-NLS-1$
+
+ Map<String, String> connectionProperties = new HashMap<String, String>();
+
+ ManagedProperty mp = values.getProperties().remove(LocalJdbcConnectorTemplateInfo.ADDITIONAL_CONNECTION_PROPS);
+ if (mp != null && mp.getValue() != null) {
+ XaJdbcConnectorTemplateInfo.parseProperties(ManagedUtil.stringValue(mp.getValue()), connectionProperties);
+ }
+
+ values.getProperties().get("connection-properties").setValue(ManagedUtil.compositeValueMap(connectionProperties));//$NON-NLS-1$
+
+ return super.applyTemplate(values);
+ }
+
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplateInfo.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplateInfo.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplateInfo.java 2010-05-25 16:27:10 UTC (rev 2153)
@@ -0,0 +1,125 @@
+/*
+ * 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.templates.connector;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.resource.deployers.management.DsDataSourceTemplateInfo;
+import org.teiid.adminapi.jboss.ExtendedPropertyInfo;
+import org.teiid.adminapi.jboss.ManagedUtil;
+import org.teiid.deployers.ManagedPropertyUtil;
+
+/**
+ * This template is to create a simplified local JDBC datasource
+ */
+public class LocalJdbcConnectorTemplateInfo extends DsDataSourceTemplateInfo implements ExtendedPropertyInfo {
+ private static final long serialVersionUID = 7618814758011974868L;
+ static final String ADDITIONAL_CONNECTION_PROPS = "addtional-connection-properties";//$NON-NLS-1$
+
+ public LocalJdbcConnectorTemplateInfo(String name, String description, Map<String, ManagedProperty> properties) {
+ super(name, description, properties);
+ }
+
+ public void start() {
+ populate();
+ }
+
+ @Override
+ public LocalJdbcConnectorTemplateInfo copy() {
+ LocalJdbcConnectorTemplateInfo copy = new LocalJdbcConnectorTemplateInfo(getName(), getDescription(), getProperties());
+ super.copy(copy);
+ copy.populate();
+ return copy;
+ }
+
+ private void populate() {
+ super.start();
+
+ ManagedProperty mp = this.getProperties().get("connection-definition");//$NON-NLS-1$
+ mp.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "javax.sql.DataSource"));//$NON-NLS-1$
+
+ mp = this.getProperties().get("dsType");//$NON-NLS-1$
+ mp.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "local-tx-datasource"));//$NON-NLS-1$
+
+ ManagedPropertyImpl dsTypeMP = buildConfigProperty();
+ addProperty(dsTypeMP);
+
+ addProperty(ConnectorTemplateInfo.buildTemplateProperty(getName()));
+
+ ManagedPropertyUtil.markAsTeiidProperty(this.getProperties().get("user-name")); //$NON-NLS-1$
+ ManagedPropertyUtil.markAsTeiidProperty(this.getProperties().get("password"));//$NON-NLS-1$
+ ManagedPropertyUtil.markAsTeiidProperty(this.getProperties().get("driver-class")); //$NON-NLS-1$
+ ManagedPropertyUtil.markAsTeiidProperty(this.getProperties().get("connection-url"));//$NON-NLS-1$
+
+ addProperty(ManagedPropertyUtil.createProperty(ADDITIONAL_CONNECTION_PROPS, SimpleMetaType.STRING,"Addtional Connection Properties", "Addtional Connection properties. (comma separated name value pairs)", false, false, null));//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ static ManagedPropertyImpl buildConfigProperty() {
+ DefaultFieldsImpl fields = new DefaultFieldsImpl("config-property");//$NON-NLS-1$
+ fields.setDescription("The config-property type"); //$NON-NLS-1$
+ fields.setMetaType(new MapCompositeMetaType (SimpleMetaType.STRING));
+ ManagedPropertyImpl dsTypeMP = new ManagedPropertyImpl(fields);
+ return dsTypeMP;
+ }
+
+
+ @Override
+ /**
+ * This is for updating a single property.
+ */
+ public void updateProperty(String name, String value, ManagedComponent main) {
+ if (name.equals(ADDITIONAL_CONNECTION_PROPS)) {
+ Map<String, String> map = new HashMap<String, String>();
+ parseProperties(value, map);
+
+ // update the container managed object.
+ MapCompositeValueSupport previousValues = (MapCompositeValueSupport)main.getProperty("connection-properties").getValue(); //$NON-NLS-1$
+ if (previousValues != null) {
+ for (String key:map.keySet()) {
+ previousValues.put(key, SimpleValueSupport.wrap(map.get(key)));
+ }
+ }
+ }
+ }
+
+ static void parseProperties(String str, Map<String, String> props) {
+ str = str.trim();
+ StringTokenizer st = new StringTokenizer(str, ","); //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String property = st.nextToken();
+ int index = property.indexOf('=');
+ if (index != -1 && property.length() > (index+1)) {
+ props.put(property.substring(0, index).trim(), property.substring(index+1).trim());
+ }
+ }
+ }
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/LocalJdbcConnectorTemplateInfo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplate.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplate.java 2010-05-25 14:46:43 UTC (rev 2152)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplate.java 2010-05-25 16:27:10 UTC (rev 2153)
@@ -21,11 +21,12 @@
*/
package org.teiid.templates.connector;
-import java.util.List;
+import java.util.HashMap;
import java.util.Map;
import org.jboss.managed.api.DeploymentTemplateInfo;
import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.virtual.VirtualFile;
import org.teiid.adminapi.jboss.ManagedUtil;
@@ -39,25 +40,25 @@
public VirtualFile applyTemplate(DeploymentTemplateInfo values) throws Exception {
XaJdbcConnectorTemplateInfo info = (XaJdbcConnectorTemplateInfo)getInfo();
+
+ values.getProperties().get("connection-definition").setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "javax.sql.DataSource"));//$NON-NLS-1$ //$NON-NLS-2$
+ values.getProperties().get("dsType").setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "xa-datasource"));//$NON-NLS-1$ //$NON-NLS-2$
- // combine connection factory specific properties.
- List<String> connectorPropNames = RaXmlPropertyConverter.getPropertyNames(info.getRarName());
- Map<String, String> props = ConnectorDeploymentTemplate.propertiesAsMap(values, connectorPropNames.toArray(new String[connectorPropNames.size()]), info.getName());
- props.put(ConnectorTemplateInfo.TEMPLATE_NAME, getInfo().getName());
- values.getProperties().get("config-property").setValue(ManagedUtil.compositeValueMap(props));//$NON-NLS-1$
+ Map<String, String> configProperties = new HashMap<String, String>();
+ configProperties.put(ConnectorTemplateInfo.TEMPLATE_NAME, getInfo().getName());
+ values.getProperties().get("config-property").setValue(ManagedUtil.compositeValueMap(configProperties));//$NON-NLS-1$
- // combine data source specific properties
- props = ConnectorDeploymentTemplate.propertiesAsMap(values, XaJdbcConnectorTemplateInfo.EXTENDED_DS_PROPERTIES, info.getName());
+ // Data source specific properties
+ Map<String, String> dsProps = ConnectorDeploymentTemplate.propertiesAsMap(values, XaJdbcConnectorTemplateInfo.EXTENDED_DS_PROPERTIES, info.getName());
ManagedProperty mp = values.getProperties().remove(XaJdbcConnectorTemplateInfo.ADDITIONAL_DS_PROPS);
if (mp != null && mp.getValue() != null) {
- XaJdbcConnectorTemplateInfo.parseProperties(ManagedUtil.stringValue(mp.getValue()), props);
+ XaJdbcConnectorTemplateInfo.parseProperties(ManagedUtil.stringValue(mp.getValue()), dsProps);
}
- values.getProperties().get("xa-datasource-properties").setValue(ManagedUtil.compositeValueMap(props));//$NON-NLS-1$
+ values.getProperties().get("xa-datasource-properties").setValue(ManagedUtil.compositeValueMap(dsProps));//$NON-NLS-1$
return super.applyTemplate(values);
}
-
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplateInfo.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplateInfo.java 2010-05-25 14:46:43 UTC (rev 2152)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplateInfo.java 2010-05-25 16:27:10 UTC (rev 2153)
@@ -22,7 +22,6 @@
package org.teiid.templates.connector;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -40,7 +39,7 @@
import org.teiid.deployers.ManagedPropertyUtil;
/**
- * This template is specific to XA data source combined with Teiid's JDBC connector.
+ * This template is to create a simplified XA JDBC datasource
*/
public class XaJdbcConnectorTemplateInfo extends DsDataSourceTemplateInfo implements ExtendedPropertyInfo {
@@ -52,8 +51,6 @@
static final String[] EXTENDED_DS_PROPERTIES = {SERVER_NAME, PORT_NUMBER,DATABASE_NAME};
- private String rarName;
-
public XaJdbcConnectorTemplateInfo(String name, String description, Map<String, ManagedProperty> properties) {
super(name, description, properties);
}
@@ -65,7 +62,6 @@
@Override
public XaJdbcConnectorTemplateInfo copy() {
XaJdbcConnectorTemplateInfo copy = new XaJdbcConnectorTemplateInfo(getName(), getDescription(), getProperties());
- copy.setRarName(getRarName());
super.copy(copy);
copy.populate();
return copy;
@@ -73,10 +69,6 @@
private void populate() {
super.start();
- List<ManagedProperty> props = RaXmlPropertyConverter.getAsManagedProperties(getRarName());
- for (ManagedProperty p:props) {
- addProperty(p);
- }
ManagedProperty mp = this.getProperties().get("connection-definition");//$NON-NLS-1$
mp.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "javax.sql.DataSource"));//$NON-NLS-1$
@@ -84,7 +76,6 @@
mp = this.getProperties().get("dsType");//$NON-NLS-1$
mp.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "xa-datasource"));//$NON-NLS-1$
-
ManagedPropertyImpl dsTypeMP = buildConfigProperty();
addProperty(dsTypeMP);
@@ -107,22 +98,12 @@
}
- public String getRarName() {
- return rarName;
- }
-
- public void setRarName(String rarName) {
- this.rarName = rarName;
- }
-
@Override
+ /**
+ * This is for updating a single property.
+ */
public void updateProperty(String name, String value, ManagedComponent main) {
- List<String> connectorNames = RaXmlPropertyConverter.getPropertyNames(getRarName());
- if (connectorNames.contains(name)) {
- ConnectorTemplateInfo.updateManagedConnectionFactory(name, value, main);
- //ConnectorTemplateInfo.updateConnectionFactory(name, value, cf);
- }
- else if (name.equals(DATABASE_NAME)||name.equals(PORT_NUMBER)||name.equals(SERVER_NAME)||name.equals(ADDITIONAL_DS_PROPS)) {
+ if (name.equals(DATABASE_NAME)||name.equals(PORT_NUMBER)||name.equals(SERVER_NAME)||name.equals(ADDITIONAL_DS_PROPS)) {
Map<String, String> map = new HashMap<String, String>();
if (name.equals(ADDITIONAL_DS_PROPS)) {
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-05-25 14:46:43 UTC (rev 2152)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-05-25 16:27:10 UTC (rev 2153)
@@ -43,4 +43,6 @@
failed_to_convert=Failed to convert from String value to {0} type
property_required_not_found="{0}" is required for the connector type "{1}", but was not supplied; There is no default value either.
invalid_class={0} invalid type of class specified. Must be of type org.teiid.connector.api.ConnectorEnvironment
-class_not_found=Class {0} not found.
\ No newline at end of file
+class_not_found=Class {0} not found.
+datasource_exists=Data source with name {0} already exists!
+datasource_template_not_found=Template {0} for creating the data source is not found.
\ No newline at end of file
Modified: trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-05-25 14:46:43 UTC (rev 2152)
+++ trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-05-25 16:27:10 UTC (rev 2153)
@@ -266,7 +266,7 @@
@Test
public void testTranslatorTemplateProperties() throws Exception {
- Collection<PropertyDefinition> defs = admin.getTranslatorTemplatePropertyDefinitions("translator-jdbc"+VERSION); //$NON-NLS-1$
+ Collection<PropertyDefinition> defs = admin.getTemplatePropertyDefinitions("translator-jdbc"+VERSION); //$NON-NLS-1$
for (PropertyDefinition pd:defs) {
System.out.println(pd.getName()+":"+pd.getPropertyTypeClassName()+":"+pd.getDefaultValue());
if (pd.getName().equals("ExtensionTranslationClassName")) { //$NON-NLS-1$
@@ -378,7 +378,7 @@
// test blank add
try {
- admin.addTranslator("foo", "translator-jdbc"+VERSION, props);
+ admin.createTranslator("foo", "translator-jdbc"+VERSION, props);
fail("must have failed because no exeuction factory set");
}catch(AdminException e) {
@@ -386,7 +386,7 @@
// test minimal correct add
props.setProperty("execution-factory-class", "org.teiid.translator.jdbc.JDBCExecutionFactory");
- admin.addTranslator("foo", "translator-jdbc"+VERSION, props);
+ admin.createTranslator("foo", "translator-jdbc"+VERSION, props);
// test set property
admin.setTranslatorProperty("foo", "TrimStrings", "true");
@@ -404,4 +404,32 @@
}
+ @Test
+ public void testCreateDataSource() throws Exception {
+
+ Properties p = new Properties();
+ p.setProperty("DatabaseName", "txntest");
+ p.setProperty("PortNumber", "3306");
+ p.setProperty("ServerName", "localhost");
+ p.setProperty("addtional-ds-properties", "foo=bar, t= x");
+ p.setProperty("user-name", "rareddy");
+ p.setProperty("password", "mm");
+ p.setProperty("xa-datasource-class", "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
+
+ admin.createDataSource("test-mysql","connector-jdbc-xa", p); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test
+ public void testCreateDriverSource() throws Exception {
+
+ Properties p = new Properties();
+ p.setProperty("connection-url", "jdbc:mysql://localhost:3306/txntest");
+ p.setProperty("addtional-connection-properties", "foo=bar, t= x");
+ p.setProperty("user-name", "rareddy");
+ p.setProperty("password", "mm");
+ p.setProperty("driver-class", "com.mysql.jdbc.Driver");
+
+ admin.createDataSource("test-mysql-driver","connector-jdbc", p); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
14 years, 7 months
teiid SVN: r2152 - in trunk: engine/src/main/java/org/teiid/query/optimizer/relational and 14 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-05-25 10:46:43 -0400 (Tue, 25 May 2010)
New Revision: 2152
Added:
trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseDependent.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedLoopJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/PartitionedSortJoin.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryFromClause.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
Log:
TEIID-1097 adding support for nested table references, which should be used as an alternative to procedural relational syntax where ever possible
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-05-25 14:46:43 UTC (rev 2152)
@@ -4,7 +4,7 @@
<title>SQL Support</title>
<para>
Teiid supports SQL for issuing queries and for defining view
- transformations; see also Procedure Language<!-- TODO:link -->
+ transformations; see also <link linkend="procedure_language">Procedure Language</link>
for how SQL is used in virtual procedures and update procedures.
</para>
<para>
@@ -569,7 +569,7 @@
input of the parameter.</para>
</listitem>
<listitem>
- <para>Input values are passed via criteria. Values can be passed by '=','is null', or 'in' predicates.
+ <para>Input values are passed via criteria. Values can be passed by '=','is null', or 'in' predicates. Disjuncts however are not allowed.
</para>
</listitem>
<listitem>
@@ -594,6 +594,12 @@
<para>The usage of 'in' or join criteria can result in
the procedure being executed multiple times.</para>
</note>
+ <note>
+ <title>Alternative Syntax</title>
+ <para>
+ None of issues listed in the syntax rules above exist if a <link linkend="nested_table">nested table reference</link> is used.
+ </para>
+ </note>
</sect2>
</sect1>
<sect1 id="temp_tables">
@@ -694,10 +700,11 @@
</para>
<itemizedlist>
<para>Example Syntax:</para>
- <listitem><para>FROM {table [AS alias]}</para></listitem>
- <listitem><para>FROM table1 [INNER|LEFT OUTER|RIGHT OUTER|FULL OUTER] JOIN table1 ON join-criteria</para></listitem>
- <listitem><para>FROM table1 CROSS JOIN table1</para></listitem>
- <listitem><para>FROM (subquery) [AS alias]</para></listitem>
+ <listitem><para>FROM table [[AS] alias]</para></listitem>
+ <listitem><para>FROM table1 [INNER|LEFT OUTER|RIGHT OUTER|FULL OUTER] JOIN table2 ON join-criteria</para></listitem>
+ <listitem><para>FROM table1 CROSS JOIN table2</para></listitem>
+ <listitem><para>FROM (subquery) [AS] alias</para></listitem>
+ <listitem><para>FROM <link linkend="nested_table">table(subquery)</link> [AS] alias</para></listitem>
<listitem><para>FROM table1 JOIN table2 MAKEDEP ON join-criteria</para></listitem>
<listitem><para>FROM table1 JOIN table2 MAKENOTDEP ON join-criteria</para></listitem>
<listitem><para>FROM table1 left outer join <link linkend="optional_join">/* optional */</link> table2 ON join-criteria</para></listitem>
@@ -712,6 +719,19 @@
metadata, and costing information.
</para>
</note>
+ <sect3 id="nested_table">
+ <title>Nested Table Reference</title>
+ <para>Nested tables may appear in the FROM clause with the TABLE keyword. They are an alternative to using a view with normal join semantics.
+ </para>
+ <para>A nested table may have correlated references to preceeding FROM clause
+ column references as long as INNER and LEFT OUTER joins are used. This is especially useful in cases where then nested expression is a procedure or function call.</para>
+ <para>Valid Example: select * from t1, TABLE(call proc(t1.x)) t2</para>
+ <para>Invalid Example: select * from TABLE(call proc(t1.x)) t2, t1</para>
+ <note>
+ <title>Multiple Execution</title>
+ <para>The usage of a correlated nested table may result in multiple executions of the table expression - once for each correlated row.</para>
+ </note>
+ </sect3>
</sect2>
<sect2 id="where_clause">
<title>WHERE Clause</title>
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -45,6 +45,7 @@
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.optimizer.relational.rules.CapabilitiesUtil;
+import org.teiid.query.optimizer.relational.rules.FrameUtil;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.relational.AccessNode;
import org.teiid.query.processor.relational.DependentAccessNode;
@@ -56,6 +57,7 @@
import org.teiid.query.processor.relational.LimitNode;
import org.teiid.query.processor.relational.MergeJoinStrategy;
import org.teiid.query.processor.relational.NestedLoopJoinStrategy;
+import org.teiid.query.processor.relational.NestedTableJoinStrategy;
import org.teiid.query.processor.relational.NullNode;
import org.teiid.query.processor.relational.PartitionedSortJoin;
import org.teiid.query.processor.relational.PlanExecutionNode;
@@ -212,7 +214,7 @@
List joinCrits = (List) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
String depValueSource = (String) node.getProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE);
SortOption leftSort = (SortOption)node.getProperty(NodeConstants.Info.SORT_LEFT);
- if(stype.equals(JoinStrategyType.MERGE) || stype.equals(JoinStrategyType.PARTITIONED_SORT)) {
+ if(stype == JoinStrategyType.MERGE || stype == JoinStrategyType.PARTITIONED_SORT) {
MergeJoinStrategy mjStrategy = null;
if (stype.equals(JoinStrategyType.PARTITIONED_SORT)) {
mjStrategy = new PartitionedSortJoin(leftSort, (SortOption)node.getProperty(NodeConstants.Info.SORT_RIGHT));
@@ -224,10 +226,21 @@
List rightExpressions = (List) node.getProperty(NodeConstants.Info.RIGHT_EXPRESSIONS);
jnode.setJoinExpressions(leftExpressions, rightExpressions);
joinCrits = (List) node.getProperty(NodeConstants.Info.NON_EQUI_JOIN_CRITERIA);
+ } else if (stype == JoinStrategyType.NESTED_TABLE) {
+ NestedTableJoinStrategy ntjStrategy = new NestedTableJoinStrategy();
+ jnode.setJoinStrategy(ntjStrategy);
+ Command command = (Command)FrameUtil.findJoinSourceNode(node.getFirstChild()).getProperty(NodeConstants.Info.NESTED_COMMAND);
+ if (command != null) {
+ ntjStrategy.setLeftMap(command.getCorrelatedReferences());
+ }
+ command = (Command)FrameUtil.findJoinSourceNode(node.getLastChild()).getProperty(NodeConstants.Info.NESTED_COMMAND);
+ if (command != null) {
+ ntjStrategy.setRightMap(command.getCorrelatedReferences());
+ }
} else {
NestedLoopJoinStrategy nljStrategy = new NestedLoopJoinStrategy();
jnode.setJoinStrategy(nljStrategy);
- }
+ }
Criteria joinCrit = Criteria.combineCriteria(joinCrits);
jnode.setJoinCriteria(joinCrit);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -671,6 +671,22 @@
GroupSymbol group = sfc.getGroupSymbol();
Command nestedCommand = sfc.getCommand();
node = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
+ if (sfc.isTable()) {
+ PlanNode rootJoin = parent;
+ while (rootJoin.getParent() != null && rootJoin.getParent().getType() == NodeConstants.Types.JOIN) {
+ rootJoin = rootJoin.getParent();
+ }
+ List<Reference> correlatedReferences = new ArrayList<Reference>();
+ CorrelatedReferenceCollectorVisitor.collectReferences(sfc, rootJoin.getGroups(), correlatedReferences);
+
+ if (!correlatedReferences.isEmpty()) {
+ SymbolMap map = new SymbolMap();
+ for (Reference reference : correlatedReferences) {
+ map.addMapping(reference.getExpression(), reference.getExpression());
+ }
+ sfc.getCommand().setCorrelatedReferences(map);
+ }
+ }
node.addGroup(group);
addNestedCommand(node, group, nestedCommand, nestedCommand, true);
hints.hasVirtualGroups = true;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -35,6 +35,7 @@
import java.util.Set;
import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.SubqueryContainer;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -42,6 +43,7 @@
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
@@ -311,6 +313,37 @@
return result;
}
+ public List<SymbolMap> getAllReferences() {
+ List<SymbolMap> refMaps = new ArrayList<SymbolMap>(getCorrelatedReferences());
+ refMaps.addAll(getExportedCorrelatedReferences());
+ return refMaps;
+ }
+
+ public List<SymbolMap> getExportedCorrelatedReferences() {
+ if (type != NodeConstants.Types.JOIN) {
+ return Collections.emptyList();
+ }
+ LinkedList<SymbolMap> result = new LinkedList<SymbolMap>();
+ for (PlanNode child : NodeEditor.findAllNodes(this, NodeConstants.Types.SOURCE, NodeConstants.Types.ACCESS)) {
+ Command command = (Command)child.getProperty(NodeConstants.Info.NESTED_COMMAND);
+ if (command == null || command.getCorrelatedReferences() == null) {
+ continue;
+ }
+ Set<GroupSymbol> correlationGroups = GroupsUsedByElementsVisitor.getGroups(command.getCorrelatedReferences().getValues());
+ PlanNode joinNode = NodeEditor.findParent(child, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE);
+ while (joinNode != null) {
+ if (joinNode.getGroups().containsAll(correlationGroups)) {
+ if (joinNode == this) {
+ result.add(command.getCorrelatedReferences());
+ }
+ break;
+ }
+ joinNode = NodeEditor.findParent(joinNode, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE);
+ }
+ }
+ return result;
+ }
+
public Set<ElementSymbol> getCorrelatedReferenceElements() {
List<SymbolMap> maps = getCorrelatedReferences();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -27,6 +27,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -164,25 +165,25 @@
static void convertNode(PlanNode node, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata)
throws QueryPlannerException {
- // Update groups for current node
- Set<GroupSymbol> groups = node.getGroups();
-
- boolean hasOld = groups.remove(oldGroup);
-
- int type = node.getType();
-
// Convert expressions from correlated subquery references;
- List<SymbolMap> refMaps = node.getCorrelatedReferences();
- boolean hasRefs = false;
+ List<SymbolMap> refMaps = node.getAllReferences();
+ LinkedList<Expression> correlatedExpression = new LinkedList<Expression>();
for (SymbolMap refs : refMaps) {
for (Map.Entry<ElementSymbol, Expression> ref : refs.asUpdatableMap().entrySet()) {
- hasRefs = true;
Expression expr = ref.getValue();
Expression convertedExpr = convertExpression(expr, symbolMap);
ref.setValue(convertedExpr);
+ correlatedExpression.add(convertedExpr);
}
}
+
+ // Update groups for current node
+ Set<GroupSymbol> groups = node.getGroups();
+ boolean hasOld = groups.remove(oldGroup);
+
+ int type = node.getType();
+
boolean singleMapping = newGroups != null && newGroups.size() == 1;
if(singleMapping) {
@@ -198,9 +199,7 @@
groups.clear();
}
- if (hasRefs) {
- groups.addAll(GroupsUsedByElementsVisitor.getGroups(node.getCorrelatedReferenceElements()));
- }
+ groups.addAll(GroupsUsedByElementsVisitor.getGroups(correlatedExpression));
if(type == NodeConstants.Types.SELECT) {
Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
@@ -365,7 +364,7 @@
* @param groups
* @return
*/
- static PlanNode findJoinSourceNode(PlanNode root) {
+ public static PlanNode findJoinSourceNode(PlanNode root) {
return findOriginatingNode(root, root.getGroups(), true);
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -81,6 +81,7 @@
private List<PlanNode> criteriaNodes = new ArrayList<PlanNode>();
private List<Collection<AccessPattern>> unsatisfiedAccessPatterns = new LinkedList<Collection<AccessPattern>>();
+ private boolean containsNestedTable;
private Map<ElementSymbol, Set<Collection<GroupSymbol>>> dependentCriteriaElements;
private Map<PlanNode, Set<PlanNode>> critieriaToSourceMap;
@@ -89,6 +90,14 @@
return joinRoot;
}
+ public void setContainsNestedTable(boolean containsNestedTable) {
+ this.containsNestedTable = containsNestedTable;
+ }
+
+ public boolean containsNestedTable() {
+ return containsNestedTable;
+ }
+
public List<Collection<AccessPattern>> getUnsatisfiedAccessPatterns() {
return unsatisfiedAccessPatterns;
}
@@ -240,7 +249,7 @@
PlanNode joinSourceRoot = entry.getValue();
//check to make sure that this group ordering satisfies the access patterns
- if (!this.unsatisfiedAccessPatterns.isEmpty()) {
+ if (!this.unsatisfiedAccessPatterns.isEmpty() || this.containsNestedTable) {
PlanNode joinSource = entry.getKey();
Collection<GroupSymbol> requiredGroups = (Collection<GroupSymbol>)joinSource.getProperty(NodeConstants.Info.REQUIRED_ACCESS_PATTERN_GROUPS);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -49,6 +49,7 @@
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
import org.teiid.query.sql.lang.AbstractSetCriteria;
+import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.CompoundCriteria;
import org.teiid.query.sql.lang.Criteria;
@@ -344,11 +345,15 @@
float cost = UNKNOWN_VALUE;
if(node.getChildCount() > 0) {
- PlanNode child = node.getFirstChild();
- Float childCostFloat = (Float)child.getProperty(NodeConstants.Info.EST_CARDINALITY);
- if (childCostFloat != null) {
- cost = childCostFloat.floatValue();
- }
+ Command command = (Command)node.getProperty(NodeConstants.Info.NESTED_COMMAND);
+ //only cost non-correlated TODO: a better estimate for correlated
+ if (command == null || command.getCorrelatedReferences() == null) {
+ PlanNode child = node.getFirstChild();
+ Float childCostFloat = (Float)child.getProperty(NodeConstants.Info.EST_CARDINALITY);
+ if (childCostFloat != null) {
+ cost = childCostFloat.floatValue();
+ }
+ }
}else {
GroupSymbol group = node.getGroups().iterator().next();
float cardinality = metadata.getCardinality(group.getMetadataID());
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -475,7 +475,7 @@
// Gather elements from correlated subquery references;
// currently only for SELECT or PROJECT nodes
- for (SymbolMap refs : node.getCorrelatedReferences()) {
+ for (SymbolMap refs : node.getAllReferences()) {
for (Expression expr : refs.asMap().values()) {
AggregateSymbolCollectorVisitor.getAggregates(expr, requiredSymbols, requiredSymbols);
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseDependent.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseDependent.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseDependent.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -154,8 +154,8 @@
for (PlanNode joinNode : NodeEditor.findAllNodes(root, NodeConstants.Types.JOIN, NodeConstants.Types.ACCESS)) {
CandidateJoin candidate = null;
- for (Iterator j = joinNode.getChildren().iterator(); j.hasNext();) {
- PlanNode child = (PlanNode)j.next();
+ for (Iterator<PlanNode> j = joinNode.getChildren().iterator(); j.hasNext();) {
+ PlanNode child = j.next();
child = FrameUtil.findJoinSourceNode(child);
if(child.hasBooleanProperty(NodeConstants.Info.MAKE_NOT_DEP) || !isValidJoin(joinNode, child, analysisRecord)) {
@@ -197,6 +197,13 @@
}
return false;
}
+
+ if (!joinNode.getExportedCorrelatedReferences().isEmpty()) {
+ if (analysisRecord.recordDebug()) {
+ analysisRecord.println("Rejecting dependent access node as parent join has a correlated nested table: "+ sourceNode.nodeToString()); //$NON-NLS-1$
+ }
+ return false;
+ }
// Check that join criteria exist
List jcrit = (List) joinNode.getProperty(NodeConstants.Info.JOIN_CRITERIA);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -42,9 +42,12 @@
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
+import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
import org.teiid.query.util.CommandContext;
@@ -64,6 +67,25 @@
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
TeiidComponentException {
+
+ for (PlanNode sourceNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE, NodeConstants.Types.ACCESS)) {
+ Command command = (Command)sourceNode.getProperty(NodeConstants.Info.NESTED_COMMAND);
+ if (command != null && command.getCorrelatedReferences() != null) {
+ Set<GroupSymbol> groups = GroupsUsedByElementsVisitor.getGroups(command.getCorrelatedReferences().getValues());
+ PlanNode joinNode = NodeEditor.findParent(sourceNode, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE);
+ while (joinNode != null) {
+ joinNode.setProperty(NodeConstants.Info.JOIN_STRATEGY, JoinStrategyType.NESTED_TABLE);
+ if (joinNode.getProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE) != null) {
+ //sanity check
+ throw new AssertionError("Cannot use a depenedent join when the join involves a correlated nested table."); //$NON-NLS-1$
+ }
+ if (joinNode.getGroups().containsAll(groups)) {
+ break;
+ }
+ joinNode = NodeEditor.findParent(joinNode, NodeConstants.Types.JOIN, NodeConstants.Types.SOURCE);
+ }
+ }
+ }
for (PlanNode joinNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.JOIN, NodeConstants.Types.ACCESS)) {
JoinStrategyType stype = (JoinStrategyType) joinNode.getProperty(NodeConstants.Info.JOIN_STRATEGY);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -41,6 +41,7 @@
import org.teiid.query.optimizer.relational.plantree.NodeConstants;
import org.teiid.query.optimizer.relational.plantree.NodeEditor;
import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.lang.OrderByItem;
@@ -88,6 +89,11 @@
if (virtualGroup.isProcedure()) {
return root;
}
+
+ Command command = (Command)frame.getProperty(NodeConstants.Info.NESTED_COMMAND);
+ if (command != null && command.getCorrelatedReferences() != null) {
+ return root; //correlated nested table commands should not be merged
+ }
PlanNode parentProject = NodeEditor.findParent(frame, NodeConstants.Types.PROJECT);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -47,9 +47,13 @@
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
import org.teiid.query.resolver.util.AccessPattern;
+import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
import org.teiid.query.util.CommandContext;
import org.teiid.query.util.Permutation;
import org.teiid.translator.ExecutionFactory.SupportedJoinCriteria;
@@ -122,6 +126,18 @@
joinRegion.initializeJoinInformation();
+ //account for nested table correlations
+ for (PlanNode joinSource : joinRegion.getJoinSourceNodes().keySet()) {
+ Command command = (Command)joinSource.getProperty(NodeConstants.Info.NESTED_COMMAND);
+ if (command != null) {
+ SymbolMap map = command.getCorrelatedReferences();
+ if (map !=null) {
+ joinSource.setProperty(NodeConstants.Info.REQUIRED_ACCESS_PATTERN_GROUPS, GroupsUsedByElementsVisitor.getGroups(map.getValues()));
+ joinRegion.setContainsNestedTable(true);
+ }
+ }
+ }
+
//check for unsatisfied dependencies
if (joinRegion.getUnsatisfiedAccessPatterns().isEmpty()) {
continue;
@@ -197,7 +213,7 @@
for (Iterator accessNodeIter = accessMap.entrySet().iterator(); accessNodeIter.hasNext();) {
Map.Entry entry = (Map.Entry)accessNodeIter.next();
- List accessNodes = (List)entry.getValue();
+ List<PlanNode> accessNodes = (List)entry.getValue();
if (accessNodes.size() < 2) {
continue;
@@ -205,14 +221,14 @@
for (int i = accessNodes.size() - 1; i >= 0; i--) {
- PlanNode accessNode1 = (PlanNode)accessNodes.get(i);
+ PlanNode accessNode1 = accessNodes.get(i);
for (int k = accessNodes.size() - 1; k >= 0; k--) {
if (k == i) {
continue;
}
- PlanNode accessNode2 = (PlanNode)accessNodes.get(k);
+ PlanNode accessNode2 = accessNodes.get(k);
List<PlanNode> criteriaNodes = joinRegion.getCriteriaNodes();
@@ -230,7 +246,7 @@
Object modelId = RuleRaiseAccess.getModelIDFromAccess(accessNode1, metadata);
SupportedJoinCriteria sjc = CapabilitiesUtil.getSupportedJoinCriteria(modelId, metadata, capFinder);
for (PlanNode critNode : criteriaNodes) {
- Set sources = (Set)joinRegion.getCritieriaToSourceMap().get(critNode);
+ Set<PlanNode> sources = joinRegion.getCritieriaToSourceMap().get(critNode);
if (sources == null) {
continue;
@@ -260,9 +276,7 @@
continue;
}
- List toTest = new ArrayList(2);
- toTest.add(accessNode1);
- toTest.add(accessNode2);
+ List<PlanNode> toTest = Arrays.asList(accessNode1, accessNode2);
JoinType joinType = joinCriteria.isEmpty()?JoinType.JOIN_CROSS:JoinType.JOIN_INNER;
@@ -291,17 +305,14 @@
joinNode.setProperty(NodeConstants.Info.JOIN_CRITERIA, joinCriteria);
PlanNode newAccess = RuleRaiseAccess.raiseAccessOverJoin(joinNode, entry.getKey(), false);
- for (Iterator joinCriteriaIter = joinCriteriaNodes.iterator(); joinCriteriaIter.hasNext();) {
- PlanNode critNode = (PlanNode)joinCriteriaIter.next();
+ for (PlanNode critNode : joinCriteriaNodes) {
critNode.removeFromParent();
critNode.removeAllChildren();
}
//update with the new source
- for (Iterator sourceIter = joinRegion.getCritieriaToSourceMap().values().iterator(); sourceIter.hasNext();) {
- Set source = (Set)sourceIter.next();
-
+ for (Set<PlanNode> source : joinRegion.getCritieriaToSourceMap().values()) {
if (source.remove(accessNode1) || source.remove(accessNode2)) {
source.add(newAccess);
}
@@ -340,9 +351,7 @@
TeiidComponentException {
Map accessMap = new HashMap();
- for (Iterator joinSourceIter = joinRegion.getJoinSourceNodes().values().iterator(); joinSourceIter.hasNext();) {
- PlanNode node = (PlanNode)joinSourceIter.next();
-
+ for (PlanNode node : joinRegion.getJoinSourceNodes().values()) {
/* check to see if we are directly over an access node. in the event that the join source root
* looks like select->access, we still won't consider this node for pushing
*/
@@ -376,15 +385,13 @@
throw new QueryPlannerException(QueryExecPlugin.Util.getString("RulePlanJoins.cantSatisfy", joinRegion.getUnsatisfiedAccessPatterns())); //$NON-NLS-1$
}
- HashSet currentGroups = new HashSet();
+ HashSet<GroupSymbol> currentGroups = new HashSet<GroupSymbol>();
- for (Iterator joinSources = joinRegion.getJoinSourceNodes().keySet().iterator(); joinSources.hasNext();) {
- PlanNode joinSource = (PlanNode)joinSources.next();
-
+ for (PlanNode joinSource : joinRegion.getJoinSourceNodes().keySet()) {
currentGroups.addAll(joinSource.getGroups());
}
- HashMap dependentNodes = new HashMap(joinRegion.getDependentJoinSourceNodes());
+ HashMap<PlanNode, PlanNode> dependentNodes = new HashMap<PlanNode, PlanNode>(joinRegion.getDependentJoinSourceNodes());
boolean satisfiedAP = true;
@@ -392,23 +399,21 @@
satisfiedAP = false;
- for (Iterator joinSources = dependentNodes.entrySet().iterator(); joinSources.hasNext();) {
- Map.Entry entry = (Map.Entry)joinSources.next();
- PlanNode joinSource = (PlanNode)entry.getKey();
+ for (Iterator<Map.Entry<PlanNode, PlanNode>> joinSources = dependentNodes.entrySet().iterator(); joinSources.hasNext();) {
+ Map.Entry<PlanNode, PlanNode> entry = joinSources.next();
+ PlanNode joinSource = entry.getKey();
Collection accessPatterns = (Collection)joinSource.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
for (Iterator i = accessPatterns.iterator(); i.hasNext();) {
AccessPattern ap = (AccessPattern)i.next();
boolean foundGroups = true;
- HashSet allRequiredGroups = new HashSet();
- for (Iterator j = ap.getUnsatisfied().iterator(); j.hasNext();) {
- ElementSymbol symbol = (ElementSymbol)j.next();
- Collection requiredGroupsSet = (Collection)joinRegion.getDependentCriteriaElements().get(symbol);
+ HashSet<GroupSymbol> allRequiredGroups = new HashSet<GroupSymbol>();
+ for (ElementSymbol symbol : ap.getUnsatisfied()) {
+ Set<Collection<GroupSymbol>> requiredGroupsSet = joinRegion.getDependentCriteriaElements().get(symbol);
boolean elementSatisfied = false;
if (requiredGroupsSet != null) {
- for (Iterator k = requiredGroupsSet.iterator(); k.hasNext();) {
- Collection requiredGroups = (Collection)k.next();
+ for (Collection<GroupSymbol> requiredGroups : requiredGroupsSet) {
if (currentGroups.containsAll(requiredGroups)) {
elementSatisfied = true;
allRequiredGroups.addAll(requiredGroups);
@@ -523,7 +528,7 @@
Object[] findBestJoinOrder(JoinRegion region, QueryMetadataInterface metadata) {
int regionCount = region.getJoinSourceNodes().size();
- List orderList = new ArrayList(regionCount);
+ List<Integer> orderList = new ArrayList<Integer>(regionCount);
for(int i=0; i<regionCount; i++) {
orderList.add(new Integer(i));
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -163,7 +163,8 @@
parentBlocking = true;
break;
case NodeConstants.Types.JOIN:
- if (node.getProperty(NodeConstants.Info.JOIN_STRATEGY) == JoinStrategyType.NESTED_LOOP) {
+ if (node.getProperty(NodeConstants.Info.JOIN_STRATEGY) == JoinStrategyType.NESTED_LOOP
+ || node.getProperty(NodeConstants.Info.JOIN_STRATEGY) == JoinStrategyType.NESTED_TABLE) {
break;
}
/*
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -42,6 +42,7 @@
import org.teiid.query.optimizer.relational.plantree.NodeEditor;
import org.teiid.query.optimizer.relational.plantree.NodeFactory;
import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.JoinType;
@@ -177,6 +178,11 @@
return null;
}
+ Command command = (Command)parentNode.getProperty(NodeConstants.Info.NESTED_COMMAND);
+ if (command != null && command.getCorrelatedReferences() != null) {
+ return null;
+ }
+
//raise only if there is no intervening project into
PlanNode parentProject = NodeEditor.findParent(parentNode, NodeConstants.Types.PROJECT);
GroupSymbol intoGroup = (GroupSymbol)parentProject.getProperty(NodeConstants.Info.INTO_GROUP);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -34,7 +34,6 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleBatch;
import org.teiid.common.buffer.TupleBuffer;
-import org.teiid.common.buffer.BufferManager.BufferReserveMode;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.query.processor.ProcessorDataManager;
@@ -56,16 +55,13 @@
public enum JoinStrategyType {
MERGE,
PARTITIONED_SORT,
- NESTED_LOOP
+ NESTED_LOOP,
+ NESTED_TABLE
}
private enum State { LOAD_LEFT, LOAD_RIGHT, EXECUTE }
private State state = State.LOAD_LEFT;
- private boolean leftOpened;
- private boolean rightOpened;
- private int reserved;
-
private JoinStrategy joinStrategy;
private JoinType joinType;
private String dependentValueSource;
@@ -120,17 +116,7 @@
this.joinCriteria = joinCriteria;
}
- /**
- * @see org.teiid.query.processor.relational.RelationalNode#reset()
- */
@Override
- public void reset() {
- super.reset();
- this.leftOpened = false;
- this.rightOpened = false;
- }
-
- @Override
public void initialize(CommandContext context, BufferManager bufferManager,
ProcessorDataManager dataMgr) {
super.initialize(context, bufferManager, dataMgr);
@@ -146,33 +132,18 @@
public void open()
throws TeiidComponentException, TeiidProcessingException {
+ // Set Up Join Strategy
+ this.joinStrategy.initialize(this);
- // Open left child always
- if (!this.leftOpened) {
- getChildren()[0].open();
- this.leftOpened = true;
- }
+ joinStrategy.openLeft();
if(!isDependent()) {
- openRight();
+ joinStrategy.openRight();
}
this.state = State.LOAD_LEFT;
- // Set Up Join Strategy
- this.joinStrategy.initialize(this);
}
- private void openRight() throws TeiidComponentException,
- TeiidProcessingException {
- if (!this.rightOpened) {
- if (reserved == 0) {
- reserved = getBufferManager().reserveBuffers(getBufferManager().getSchemaSize(getOutputElements()), BufferReserveMode.FORCE);
- }
- getChildren()[1].open();
- this.rightOpened = true;
- }
- }
-
/**
* @see org.teiid.query.processor.relational.RelationalNode#clone()
* @since 4.2
@@ -182,7 +153,7 @@
super.copy(this, clonedNode);
clonedNode.joinType = this.joinType;
- clonedNode.joinStrategy = (JoinStrategy) this.joinStrategy.clone();
+ clonedNode.joinStrategy = this.joinStrategy.clone();
clonedNode.joinCriteria = this.joinCriteria;
@@ -216,7 +187,7 @@
state = State.LOAD_RIGHT;
}
if (state == State.LOAD_RIGHT) {
- this.openRight();
+ this.joinStrategy.openRight();
this.joinStrategy.loadRight();
this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, null);
state = State.EXECUTE;
@@ -301,8 +272,6 @@
}
public void closeDirect() {
- getBufferManager().releaseBuffers(reserved);
- reserved = 0;
super.closeDirect();
joinStrategy.close();
this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource, null);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinStrategy.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinStrategy.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -26,6 +26,7 @@
import java.util.List;
import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.common.buffer.BufferManager.BufferReserveMode;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
@@ -35,8 +36,11 @@
protected JoinNode joinNode;
protected SourceState leftSource;
protected SourceState rightSource;
-
+ private int reserved;
+
public void close() {
+ joinNode.getBufferManager().releaseBuffers(reserved);
+ reserved = 0;
try {
if (leftSource != null) {
leftSource.close();
@@ -82,6 +86,23 @@
protected abstract void process() throws TeiidComponentException, CriteriaEvaluationException, TeiidProcessingException;
- public abstract Object clone();
+ public abstract JoinStrategy clone();
+
+ protected void openLeft() throws TeiidComponentException, TeiidProcessingException {
+ if (!this.leftSource.open) {
+ leftSource.getSource().open();
+ this.leftSource.open = true;
+ }
+ }
+
+ protected void openRight() throws TeiidComponentException, TeiidProcessingException {
+ if (!this.rightSource.open) {
+ if (reserved == 0) {
+ reserved = joinNode.getBufferManager().reserveBuffers(joinNode.getBufferManager().getSchemaSize(joinNode.getOutputElements()), BufferReserveMode.FORCE);
+ }
+ rightSource.getSource().open();
+ this.rightSource.open = true;
+ }
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -103,7 +103,7 @@
* @see org.teiid.query.processor.relational.JoinStrategy#clone()
*/
@Override
- public Object clone() {
+ public MergeJoinStrategy clone() {
return new MergeJoinStrategy(sortLeft, sortRight, grouping);
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedLoopJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedLoopJoinStrategy.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedLoopJoinStrategy.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -45,7 +45,7 @@
* @see org.teiid.query.processor.relational.MergeJoinStrategy#clone()
*/
@Override
- public Object clone() {
+ public NestedLoopJoinStrategy clone() {
return new NestedLoopJoinStrategy();
}
Added: trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -0,0 +1,179 @@
+/*
+ * 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.query.processor.relational;
+
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.common.buffer.IndexedTupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.processor.relational.SourceState.ImplicitBuffer;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+
+/**
+ * Variation of a nested loop join that handles nested tables
+ */
+public class NestedTableJoinStrategy extends JoinStrategy {
+
+ private SymbolMap leftMap;
+ private SymbolMap rightMap;
+ private Evaluator eval;
+ private boolean outerMatched;
+
+ @Override
+ public NestedTableJoinStrategy clone() {
+ NestedTableJoinStrategy clone = new NestedTableJoinStrategy();
+ clone.leftMap = leftMap;
+ clone.rightMap = rightMap;
+ return clone;
+ }
+
+ @Override
+ public void initialize(JoinNode joinNode) {
+ super.initialize(joinNode);
+ this.eval = new Evaluator(null, joinNode.getDataManager(), joinNode.getContext());
+ }
+
+ public void setLeftMap(SymbolMap leftMap) {
+ this.leftMap = leftMap;
+ }
+
+ public void setRightMap(SymbolMap rightMap) {
+ this.rightMap = rightMap;
+ }
+
+ @Override
+ protected void openLeft() throws TeiidComponentException,
+ TeiidProcessingException {
+ if (leftMap == null) {
+ super.openLeft();
+ }
+ }
+
+ @Override
+ protected void openRight() throws TeiidComponentException,
+ TeiidProcessingException {
+ if (rightMap == null) {
+ super.openRight();
+ this.rightSource.setImplicitBuffer(ImplicitBuffer.FULL);
+ }
+ }
+
+ @Override
+ protected void process() throws TeiidComponentException,
+ CriteriaEvaluationException, TeiidProcessingException {
+
+ if (leftMap != null && !leftSource.open) {
+ for (Map.Entry<ElementSymbol, Expression> entry : leftMap.asMap().entrySet()) {
+ joinNode.getContext().getVariableContext().setValue(entry.getKey(), eval.evaluate(entry.getValue(), null));
+ }
+ leftSource.getSource().reset();
+ super.openLeft();
+ }
+
+ IndexedTupleSource its = leftSource.getIterator();
+
+ while (its.hasNext() || leftSource.getCurrentTuple() != null) {
+
+ List<?> leftTuple = leftSource.getCurrentTuple();
+ if (leftTuple == null) {
+ leftTuple = leftSource.saveNext();
+ }
+ updateContext(leftTuple, leftSource.getSource().getElements());
+
+ if (rightMap != null && !rightSource.open) {
+ for (Map.Entry<ElementSymbol, Expression> entry : rightMap.asMap().entrySet()) {
+ joinNode.getContext().getVariableContext().setValue(entry.getKey(), eval.evaluate(entry.getValue(), null));
+ }
+ rightSource.getSource().reset();
+ super.openRight();
+ }
+
+ IndexedTupleSource right = rightSource.getIterator();
+
+ while (right.hasNext() || rightSource.getCurrentTuple() != null) {
+
+ List<?> rightTuple = rightSource.getCurrentTuple();
+ if (rightTuple == null) {
+ rightTuple = rightSource.saveNext();
+ }
+
+ List<?> outputTuple = outputTuple(this.leftSource.getCurrentTuple(), this.rightSource.getCurrentTuple());
+
+ if (this.joinNode.matchesCriteria(outputTuple)) {
+ joinNode.addBatchRow(outputTuple);
+ outerMatched = true;
+ }
+
+ rightSource.saveNext();
+ }
+
+ if (!outerMatched && this.joinNode.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
+ joinNode.addBatchRow(outputTuple(this.leftSource.getCurrentTuple(), this.rightSource.getOuterVals()));
+ }
+
+ outerMatched = false;
+
+ if (rightMap == null) {
+ rightSource.getIterator().setPosition(1);
+ } else {
+ rightSource.close();
+ for (Map.Entry<ElementSymbol, Expression> entry : rightMap.asMap().entrySet()) {
+ joinNode.getContext().getVariableContext().setValue(entry.getKey(), null);
+ }
+ }
+
+ leftSource.saveNext();
+ updateContext(null, leftSource.getSource().getElements());
+ }
+
+ if (leftMap != null) {
+ leftSource.close();
+ for (Map.Entry<ElementSymbol, Expression> entry : leftMap.asMap().entrySet()) {
+ joinNode.getContext().getVariableContext().setValue(entry.getKey(), null);
+ }
+ }
+ }
+
+ private void updateContext(List<?> tuple,
+ List<SingleElementSymbol> elements) {
+ for (int i = 0; i < elements.size(); i++) {
+ SingleElementSymbol element = elements.get(i);
+ if (element instanceof ElementSymbol) {
+ joinNode.getContext().getVariableContext().setValue((ElementSymbol)element, tuple==null?null:tuple.get(i));
+ }
+ }
+ }
+
+ public String toString() {
+ return "NESTED TABLE JOIN"; //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/PartitionedSortJoin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/PartitionedSortJoin.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/PartitionedSortJoin.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -304,7 +304,7 @@
}
@Override
- public Object clone() {
+ public PartitionedSortJoin clone() {
return new PartitionedSortJoin(this.sortLeft, this.sortRight);
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -55,6 +55,7 @@
private int maxProbeMatch = 1;
private boolean distinct;
private ImplicitBuffer implicitBuffer = ImplicitBuffer.FULL;
+ boolean open;
private SortUtility sortUtility;
@@ -110,6 +111,8 @@
this.iterator.closeSource();
this.iterator = null;
}
+ this.currentTuple = null;
+ this.open = false;
}
public int getRowCount() throws TeiidComponentException, TeiidProcessingException {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -1,3 +1,25 @@
+/*
+ * 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.query.processor.relational;
import java.util.Map;
@@ -4,7 +26,6 @@
import org.teiid.query.eval.Evaluator;
-
public abstract class SubqueryAwareRelationalNode extends RelationalNode {
private SubqueryAwareEvaluator evaluator;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -38,6 +38,7 @@
import org.teiid.api.exception.query.UnresolvedSymbolDescription;
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.query.QueryPlugin;
import org.teiid.query.analysis.AnalysisRecord;
@@ -54,8 +55,10 @@
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.ExistsCriteria;
import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.FromClause;
import org.teiid.query.sql.lang.Into;
import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.Select;
@@ -145,9 +148,11 @@
private LinkedHashSet<GroupSymbol> currentGroups = new LinkedHashSet<GroupSymbol>();
private List<GroupSymbol> discoveredGroups = new LinkedList<GroupSymbol>();
+ private List<GroupSymbol> implicitGroups = new LinkedList<GroupSymbol>();
private TempMetadataAdapter metadata;
private Query query;
private AnalysisRecord analysis;
+ private boolean allowImplicit = true;
public QueryResolverVisitor(Query query, TempMetadataAdapter metadata, AnalysisRecord record) {
super(new ResolverVisitor(metadata, null, query.getExternalGroupContexts()));
@@ -163,10 +168,8 @@
ResolverVisitor visitor = (ResolverVisitor)getVisitor();
try {
visitor.throwException(false);
- } catch (QueryResolverException e) {
+ } catch (TeiidException e) {
throw new TeiidRuntimeException(e);
- } catch (TeiidComponentException e) {
- throw new TeiidRuntimeException(e);
}
}
@@ -185,25 +188,21 @@
public void visit(GroupSymbol obj) {
try {
ResolverUtil.resolveGroup(obj, metadata);
- } catch (QueryResolverException err) {
+ } catch (TeiidException err) {
throw new TeiidRuntimeException(err);
- } catch (TeiidComponentException err) {
- throw new TeiidRuntimeException(err);
}
}
- private void resolveSubQuery(SubqueryContainer obj) {
+ private void resolveSubQuery(SubqueryContainer obj, Collection<GroupSymbol> externalGroups) {
Command command = obj.getCommand();
QueryResolver.setChildMetadata(command, query);
- command.pushNewResolvingContext(this.currentGroups);
+ command.pushNewResolvingContext(externalGroups);
try {
QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata.getMetadata(), analysis, false);
- } catch (QueryResolverException err) {
+ } catch (TeiidException err) {
throw new TeiidRuntimeException(err);
- } catch (TeiidComponentException err) {
- throw new TeiidRuntimeException(err);
}
}
@@ -244,15 +243,13 @@
List<ElementSymbol> elements = resolveSelectableElements(group);
obj.setElementSymbols(elements);
- } catch (QueryResolverException err) {
+ } catch (TeiidException err) {
throw new TeiidRuntimeException(err);
- } catch (TeiidComponentException err) {
- throw new TeiidRuntimeException(err);
}
}
public void visit(ScalarSubquery obj) {
- resolveSubQuery(obj);
+ resolveSubQuery(obj, this.currentGroups);
Collection<SingleElementSymbol> projSymbols = obj.getCommand().getProjectedSymbols();
@@ -265,24 +262,29 @@
}
public void visit(ExistsCriteria obj) {
- resolveSubQuery(obj);
+ resolveSubQuery(obj, this.currentGroups);
}
public void visit(SubqueryCompareCriteria obj) {
visitNode(obj.getLeftExpression());
- resolveSubQuery(obj);
+ resolveSubQuery(obj, this.currentGroups);
postVisitVisitor(obj);
}
public void visit(SubquerySetCriteria obj) {
visitNode(obj.getExpression());
- resolveSubQuery(obj);
+ resolveSubQuery(obj, this.currentGroups);
postVisitVisitor(obj);
}
public void visit(SubqueryFromClause obj) {
- resolveSubQuery(obj);
- this.discoveredGroups.add(obj.getGroupSymbol());
+ Collection<GroupSymbol> externalGroups = this.currentGroups;
+ if (obj.isTable() && allowImplicit) {
+ externalGroups = new ArrayList<GroupSymbol>(externalGroups);
+ externalGroups.addAll(this.implicitGroups);
+ }
+ resolveSubQuery(obj, externalGroups);
+ discoveredGroup(obj.getGroupSymbol());
try {
ResolverUtil.addTempGroup(metadata, obj.getGroupSymbol(), obj.getCommand().getProjectedSymbols(), false);
} catch (QueryResolverException err) {
@@ -298,16 +300,21 @@
if (!group.isProcedure() && metadata.isXMLGroup(group.getMetadataID())) {
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0003, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0003));
}
- this.discoveredGroups.add(group);
+ discoveredGroup(group);
if (group.isProcedure()) {
createProcRelational(obj);
}
- } catch(QueryResolverException e) {
- throw new TeiidRuntimeException(e);
- } catch(TeiidComponentException e) {
+ } catch(TeiidException e) {
throw new TeiidRuntimeException(e);
}
}
+
+ private void discoveredGroup(GroupSymbol group) {
+ discoveredGroups.add(group);
+ if (allowImplicit) {
+ implicitGroups.add(group);
+ }
+ }
private void createProcRelational(UnaryFromClause obj)
throws TeiidComponentException, QueryMetadataException,
@@ -405,14 +412,19 @@
}
public void visit(JoinPredicate obj) {
- List<GroupSymbol> pendingDiscoveredGroups = new ArrayList<GroupSymbol>(discoveredGroups);
+ assert currentGroups.isEmpty();
+ List<GroupSymbol> tempImplicitGroups = new ArrayList<GroupSymbol>(discoveredGroups);
discoveredGroups.clear();
visitNode(obj.getLeftClause());
+ List<GroupSymbol> leftGroups = new ArrayList<GroupSymbol>(discoveredGroups);
+ discoveredGroups.clear();
visitNode(obj.getRightClause());
-
+ discoveredGroups.addAll(leftGroups);
addDiscoveredGroups();
- discoveredGroups = pendingDiscoveredGroups;
visitNodes(obj.getJoinCriteria());
+ discoveredGroups.addAll(currentGroups);
+ currentGroups.clear();
+ discoveredGroups.addAll(tempImplicitGroups);
}
private void addDiscoveredGroups() {
@@ -429,8 +441,25 @@
public void visit(From obj) {
assert currentGroups.isEmpty();
+ for (FromClause clause : (List<FromClause>)obj.getClauses()) {
+ checkImplicit(clause);
+ }
super.visit(obj);
addDiscoveredGroups();
}
+
+ private void checkImplicit(FromClause clause) {
+ if (clause instanceof JoinPredicate) {
+ JoinPredicate jp = (JoinPredicate)clause;
+ if (jp.getJoinType() == JoinType.JOIN_FULL_OUTER || jp.getJoinType() == JoinType.JOIN_RIGHT_OUTER) {
+ allowImplicit = false;
+ return;
+ }
+ checkImplicit(jp.getLeftClause());
+ if (allowImplicit) {
+ checkImplicit(jp.getRightClause());
+ }
+ }
+ }
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -56,7 +56,6 @@
import org.teiid.query.sql.lang.SubqueryCompareCriteria;
import org.teiid.query.sql.lang.SubquerySetCriteria;
import org.teiid.query.sql.navigator.PostOrderNavigator;
-import org.teiid.query.sql.symbol.AggregateSymbol;
import org.teiid.query.sql.symbol.CaseExpression;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryFromClause.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryFromClause.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryFromClause.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -37,6 +37,7 @@
private GroupSymbol symbol;
private Command command;
+ private boolean table;
/**
* Construct default object
@@ -59,6 +60,14 @@
this.symbol = symbol;
this.command = command;
}
+
+ public boolean isTable() {
+ return table;
+ }
+
+ public void setTable(boolean table) {
+ this.table = table;
+ }
/**
* Reset the alias for this subquery from clause and it's pseudo-GroupSymbol.
@@ -135,7 +144,8 @@
SubqueryFromClause sfc = (SubqueryFromClause) obj;
return this.getName().equalsIgnoreCase(sfc.getName()) &&
- sfc.isOptional() == this.isOptional() && this.command.equals(sfc.command);
+ sfc.isOptional() == this.isOptional() && this.command.equals(sfc.command)
+ && this.table == sfc.table;
}
/**
@@ -160,7 +170,7 @@
clause.setOptional(this.isOptional());
clause.setMakeDep(this.isMakeDep());
clause.setMakeNotDep(this.isMakeNotDep());
-
+ clause.setTable(this.isTable());
return clause;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -36,6 +36,7 @@
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.AtomicCriteria;
import org.teiid.query.sql.lang.BetweenCriteria;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.CompareCriteria;
@@ -532,7 +533,7 @@
Iterator critIter = joinCriteria.iterator();
while(critIter.hasNext()) {
Criteria crit = (Criteria) critIter.next();
- if(crit instanceof PredicateCriteria) {
+ if(crit instanceof PredicateCriteria || crit instanceof AtomicCriteria) {
parts.add(registerNode(crit));
} else {
parts.add("("); //$NON-NLS-1$
@@ -1025,6 +1026,9 @@
public void visit(SubqueryFromClause obj) {
addOptionComment(obj);
+ if (obj.isTable()) {
+ parts.add(SQLReservedWords.TABLE);
+ }
parts.add("(");//$NON-NLS-1$
parts.add(registerNode(obj.getCommand()));
parts.add(")");//$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -32,6 +32,7 @@
import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.Streamable;
import org.teiid.core.util.ArgCheck;
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.SecurityFunctionEvaluator;
@@ -79,7 +80,7 @@
/** Indicate whether statistics should be collected for relational node processing*/
private boolean collectNodeStatistics;
- private int streamingBatchSize;
+ private int streamingBatchSize = Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
private Random random = null;
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-05-25 14:46:43 UTC (rev 2152)
@@ -1908,10 +1908,13 @@
{
String aliasID = null;
Command command = null;
- SubqueryFromClause clause = null;
Token lparen = null;
+ boolean table = false;
}
{
+ [
+ <TABLE> { table = true; }
+ ]
lparen = <LPAREN>
( command = queryExpression(info) |
command = storedProcedure(info) )
@@ -1920,8 +1923,9 @@
aliasID = id()
{
- clause = new SubqueryFromClause(validateAlias(aliasID), command);
+ SubqueryFromClause clause = new SubqueryFromClause(validateAlias(aliasID), command);
setFromClauseOptions(lparen, clause);
+ clause.setTable(table);
return clause;
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -64,6 +64,7 @@
import org.teiid.query.processor.relational.JoinStrategy;
import org.teiid.query.processor.relational.MergeJoinStrategy;
import org.teiid.query.processor.relational.NestedLoopJoinStrategy;
+import org.teiid.query.processor.relational.NestedTableJoinStrategy;
import org.teiid.query.processor.relational.NullNode;
import org.teiid.query.processor.relational.PartitionedSortJoin;
import org.teiid.query.processor.relational.PlanExecutionNode;
@@ -91,7 +92,7 @@
import org.teiid.query.validator.ValidatorReport;
import org.teiid.translator.SourceSystemFunctions;
-
+@SuppressWarnings("nls")
public class TestOptimizer {
public interface DependentJoin {}
@@ -408,7 +409,9 @@
if (strategy instanceof PartitionedSortJoin) {
updateCounts(PartitionedSortJoin.class, counts, types);
}
- }
+ } else if (strategy instanceof NestedTableJoinStrategy) {
+ updateCounts(NestedTableJoinStrategy.class, counts, types);
+ }
if (((JoinNode)relationalNode).isDependent()) {
updateCounts(DependentJoin.class, counts, types);
}
@@ -6776,6 +6779,16 @@
new String[] {"SELECT CONVERT(CONVERT(e2, long), biginteger) FROM pm1.g1 AS A"}, //$NON-NLS-1$
SHOULD_SUCCEED );
}
+
+ @Test public void testNestedTable() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan("select pm2.g1.e1, x.e1 from pm2.g1, table(select * from pm2.g2 where pm2.g1.e1=pm2.g2.e1) x where pm2.g1.e2 IN (1, 2)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm2.g2 AS g_0 WHERE g_0.e1 = pm2.g1.e1", "SELECT g_0.e1 FROM pm2.g1 AS g_0 WHERE g_0.e2 IN (1, 2)" }, capFinder, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {1}, new Class[] {NestedTableJoinStrategy.class});
+ }
public static final boolean DEBUG = false;
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -6742,5 +6742,17 @@
query.setSelect(new Select(Arrays.asList(as)));
helpTest(sql, "SELECT XMLAGG(1 ORDER BY e2)", query);
}
+
+ @Test public void testNestedTable() throws Exception {
+ String sql = "SELECT * from TABLE(exec foo()) as x"; //$NON-NLS-1$
+ Query query = new Query();
+ query.setSelect(new Select(Arrays.asList(new AllSymbol())));
+ StoredProcedure sp = new StoredProcedure();
+ sp.setProcedureName("foo");
+ SubqueryFromClause sfc = new SubqueryFromClause("x", sp);
+ sfc.setTable(true);
+ query.setFrom(new From(Arrays.asList(sfc)));
+ helpTest(sql, "SELECT * FROM TABLE(EXEC foo()) AS x", query);
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -298,10 +298,11 @@
Properties props = new Properties();
props.setProperty("soap_host", "my.host.com"); //$NON-NLS-1$ //$NON-NLS-2$
props.setProperty("soap_port", "12345"); //$NON-NLS-1$ //$NON-NLS-2$
- CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", 1, props, DEBUG, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", 1, props, DEBUG, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
context.setProcessorBatchSize(2000);
context.setConnectorBatchSize(2000);
context.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
+ context.setProcessDebug(DEBUG);
return context;
}
@@ -7485,6 +7486,106 @@
helpProcess(plan, dataManager, expected);
}
+
+ @Test public void testCorrelatedNestedTable() {
+ String sql = "select y.e2, x.e1, x.e2 from (select * from pm1.g1) y, table (select * from pm1.g3 where e2 = y.e2) x"; //$NON-NLS-1$
+ List[] expected = new List[] {
+ Arrays.asList(0, "a", 0),
+ Arrays.asList(0, "a", 0),
+ Arrays.asList(1, null, 1),
+ Arrays.asList(1, "c", 1),
+ Arrays.asList(3, "a", 3),
+ Arrays.asList(1, null, 1),
+ Arrays.asList(1, "c", 1),
+ Arrays.asList(2, "b", 2),
+ Arrays.asList(0, "a", 0),
+ Arrays.asList(0, "a", 0),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedNestedTable1() {
+ String sql = "select y.e2, z.e2, x.e1, x.e2 from (select * from pm1.g1 order by e2 desc limit 2) y inner join pm1.g2 z on y.e1 = z.e1, table (select * from pm1.g3 where e2 = y.e2 + z.e2) x"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(3, 0, "a", 3),
+ Arrays.asList(3, 0, "a", 3),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedNestedTable2() {
+ String sql = "select y.e1, x.e1 from (select distinct e1 from pm1.g1 where e1 is not null) y, table (call pm1.sq3b(\"in\" = e1, in3 = 'something')) x"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("a", "a"),
+ Arrays.asList("a", "a"),
+ Arrays.asList("a", "a"),
+ Arrays.asList("b", "b"),
+ Arrays.asList("c", "c"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedNestedTable3() {
+ String sql = "select y.e1, x.e1 from (select * from pm1.g1) y left outer join table (call pm1.sq3b(\"in\" = e2, in3 = 'something')) x on (1=1)"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("a", null),
+ Arrays.asList(null, null),
+ Arrays.asList("a", null),
+ Arrays.asList("c", null),
+ Arrays.asList("b", null),
+ Arrays.asList("a", null),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedNestedTable4() {
+ String sql = "select y.e1, y.e2, z.e2 from (select * from pm1.g1) y inner join table (select * from pm1.g3 where e2 = y.e2) x left outer join (select null as e1, e2 from pm1.g2) z on (x.e1 = z.e1) on (x.e1 = y.e1)"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("a", 0, null),
+ Arrays.asList("a", 0, null),
+ Arrays.asList("a", 3, null),
+ Arrays.asList("c", 1, null),
+ Arrays.asList("b", 2, null),
+ Arrays.asList("a", 0, null),
+ Arrays.asList("a", 0, null),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
private static final boolean DEBUG = false;
}
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -2749,6 +2749,10 @@
helpResolve("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 CROSS JOIN pm1.g2 LEFT OUTER JOIN pm2.g1 on pm1.g1.e1 = pm2.g1.e1"); //$NON-NLS-1$
}
+ @Test public void testInvalidColumnReferenceWithNestedJoin() {
+ helpResolveException("SELECT a.* FROM (pm1.g2 a left outer join pm1.g2 b on a.e1= b.e1) LEFT OUTER JOIN (select a.e1) c on (a.e1 = c.e1)"); //$NON-NLS-1$
+ }
+
/**
* should be the same as exec with too many params
*/
@@ -2932,4 +2936,9 @@
helpResolveException("select pm1.g1.e1 from pm1.g1 order by 2"); //$NON-NLS-1$
}
+ @Test public void testCorrelatedNestedTableReference() {
+ helpResolve("select pm1.g1.e1 from pm1.g1, table (exec pm1.sq2(pm1.g1.e2)) x"); //$NON-NLS-1$
+ helpResolveException("select pm1.g1.e1 from pm1.g1, (exec pm1.sq2(pm1.g1.e2)) x"); //$NON-NLS-1$
+ }
+
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2010-05-24 22:13:05 UTC (rev 2151)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2010-05-25 14:46:43 UTC (rev 2152)
@@ -204,7 +204,7 @@
new ElementSymbol("m.g.c1"), //$NON-NLS-1$
CompareCriteria.EQ,
new Constant("abc") ); //$NON-NLS-1$
- List crits = new ArrayList();
+ List<Criteria> crits = new ArrayList<Criteria>();
crits.add(cc);
CompoundCriteria comp = new CompoundCriteria(CompoundCriteria.AND, crits);
@@ -220,7 +220,7 @@
new ElementSymbol("m.g.c2"), //$NON-NLS-1$
CompareCriteria.EQ,
new Constant("abc") ); //$NON-NLS-1$
- List crits = new ArrayList();
+ List<Criteria> crits = new ArrayList<Criteria>();
crits.add(cc1);
crits.add(cc2);
CompoundCriteria comp = new CompoundCriteria(CompoundCriteria.AND, crits);
@@ -241,7 +241,7 @@
new ElementSymbol("m.g.c3"), //$NON-NLS-1$
CompareCriteria.EQ,
new Constant("abc") ); //$NON-NLS-1$
- List crits = new ArrayList();
+ List<Criteria> crits = new ArrayList<Criteria>();
crits.add(cc1);
crits.add(cc2);
crits.add(cc3);
@@ -255,7 +255,7 @@
new ElementSymbol("m.g.c1"), //$NON-NLS-1$
CompareCriteria.EQ,
new Constant("abc") ); //$NON-NLS-1$
- List crits = new ArrayList();
+ List<Criteria> crits = new ArrayList<Criteria>();
crits.add(cc1);
crits.add(null);
CompoundCriteria comp = new CompoundCriteria(CompoundCriteria.OR, crits);
@@ -268,7 +268,7 @@
new ElementSymbol("m.g.c1"), //$NON-NLS-1$
CompareCriteria.EQ,
new Constant("abc") ); //$NON-NLS-1$
- List crits = new ArrayList();
+ List<Criteria> crits = new ArrayList<Criteria>();
crits.add(null);
crits.add(cc1);
CompoundCriteria comp = new CompoundCriteria(CompoundCriteria.OR, crits);
@@ -281,7 +281,7 @@
new ElementSymbol("m.g.c1"), //$NON-NLS-1$
CompareCriteria.EQ,
new Constant("abc") ); //$NON-NLS-1$
- List crits = new ArrayList();
+ List<Criteria> crits = new ArrayList<Criteria>();
crits.add(cc1);
crits.add(null);
CompoundCriteria comp = new CompoundCriteria(CompoundCriteria.OR, crits);
@@ -404,7 +404,7 @@
}
public void testJoinPredicate2() {
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(new CompareCriteria(new ElementSymbol("m.g2.e1"), CompareCriteria.EQ, new ElementSymbol("m.g3.e1"))); //$NON-NLS-1$ //$NON-NLS-2$
JoinPredicate jp = new JoinPredicate(
new UnaryFromClause(new GroupSymbol("m.g2")), //$NON-NLS-1$
@@ -416,7 +416,7 @@
}
public void testJoinPredicate3() {
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(new CompareCriteria(new ElementSymbol("m.g2.e1"), CompareCriteria.EQ, new ElementSymbol("m.g3.e1"))); //$NON-NLS-1$ //$NON-NLS-2$
crits.add(new CompareCriteria(new ElementSymbol("m.g2.e2"), CompareCriteria.EQ, new ElementSymbol("m.g3.e2"))); //$NON-NLS-1$ //$NON-NLS-2$
JoinPredicate jp = new JoinPredicate(
@@ -429,7 +429,7 @@
}
public void testJoinPredicate4() {
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(new CompareCriteria(new ElementSymbol("m.g2.e1"), CompareCriteria.EQ, new ElementSymbol("m.g3.e1"))); //$NON-NLS-1$ //$NON-NLS-2$
JoinPredicate jp = new JoinPredicate(
new UnaryFromClause(new GroupSymbol("m.g2")), //$NON-NLS-1$
@@ -446,7 +446,7 @@
}
public void testJoinPredicate5() {
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(new NotCriteria(new CompareCriteria(new ElementSymbol("m.g2.e1"), CompareCriteria.EQ, new ElementSymbol("m.g3.e1")))); //$NON-NLS-1$ //$NON-NLS-2$
JoinPredicate jp = new JoinPredicate(
new UnaryFromClause(new GroupSymbol("m.g2")), //$NON-NLS-1$
@@ -454,7 +454,7 @@
JoinType.JOIN_INNER,
crits );
- helpTest(jp, "m.g2 INNER JOIN m.g3 ON (NOT (m.g2.e1 = m.g3.e1))"); //$NON-NLS-1$
+ helpTest(jp, "m.g2 INNER JOIN m.g3 ON NOT (m.g2.e1 = m.g3.e1)"); //$NON-NLS-1$
}
public void testJoinType1() {
14 years, 7 months
teiid SVN: r2151 - trunk/build/assembly/jboss-container.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-05-24 18:13:05 -0400 (Mon, 24 May 2010)
New Revision: 2151
Modified:
trunk/build/assembly/jboss-container/dist.xml
Log:
TEIID-1075: rolling back translator xml change
Modified: trunk/build/assembly/jboss-container/dist.xml
===================================================================
--- trunk/build/assembly/jboss-container/dist.xml 2010-05-24 16:41:41 UTC (rev 2150)
+++ trunk/build/assembly/jboss-container/dist.xml 2010-05-24 22:13:05 UTC (rev 2151)
@@ -79,7 +79,6 @@
<include>org.jboss.teiid.connectors:translator-salesforce</include>
<include>org.jboss.teiid.connectors:connector-salesforce:rar</include>
<include>org.jboss.teiid.connectors:connector-ws:rar</include>
- <include>org.jboss.teiid.connectors:translator-xml</include>
<!--
<include>org.jboss.teiid.connectors:connector-xml-http:rar</include>
14 years, 7 months
teiid SVN: r2150 - in trunk: client/src/main/java/org/teiid/adminapi/impl and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-05-24 12:41:41 -0400 (Mon, 24 May 2010)
New Revision: 2150
Modified:
trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
Log:
TEIID-1098: adding the "queryThreshold" property to the engine to define the long running query time in seconds. Also added a method "getLongRunningRequests" that will return any requests that took more time than the defined threshold property. The default query threshold is 600 secs.
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-05-22 21:57:32 UTC (rev 2149)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-05-24 16:41:41 UTC (rev 2150)
@@ -94,7 +94,9 @@
<!-- Enable Resultset Caching -->
<property name="resultSetCacheEnabled">true</property>
<!-- Turn on checking the entitlements on resources based on the roles defined in VDB -->
- <property name="useEntitlements" class="java.lang.Boolean">false</property>
+ <property name="useEntitlements" class="java.lang.Boolean">false</property>
+ <!-- Long running query threshold, after which a alert can be generated by tooling if configured-->
+ <property name="queryThresholdInSecs">600</property>
</bean>
<!-- JDBC Socket connection properties (SSL see below) -->
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-05-22 21:57:32 UTC (rev 2149)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-05-24 16:41:41 UTC (rev 2150)
@@ -40,4 +40,5 @@
Collection<org.teiid.adminapi.Transaction> getTransactions();
void terminateTransaction(String xid) throws AdminException ;
void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException;
+ List<RequestMetadata> getLongRunningRequests();
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-05-22 21:57:32 UTC (rev 2149)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-05-24 16:41:41 UTC (rev 2150)
@@ -34,6 +34,7 @@
static final int DEFAULT_FETCH_SIZE = RequestMessage.DEFAULT_FETCH_SIZE * 10;
static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
static final int DEFAULT_MAX_RESULTSET_CACHE_ENTRIES = 1024;
+ static final int DEFAULT_QUERY_THRESHOLD = 600;
static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
public static final int DEFAULT_MAX_PROCESS_WORKERS = 16;
@@ -50,6 +51,7 @@
private boolean resultSetCacheEnabled = true;
private int maxResultSetCacheEntries = DQPConfiguration.DEFAULT_MAX_RESULTSET_CACHE_ENTRIES;
private boolean useEntitlements = false;
+ private int queryThresholdInSecs = DEFAULT_QUERY_THRESHOLD;
@ManagementProperty(description="Process pool maximum thread count. (default 16) Increase this value if your load includes a large number of XQueries or if the system's available processors is larger than 8")
public int getMaxThreads() {
@@ -161,5 +163,14 @@
public void setUseEntitlements(Boolean useEntitlements) {
this.useEntitlements = useEntitlements.booleanValue();
+ }
+
+ @ManagementProperty(description="Long running query threshold, after which a alert can be generated by tooling if configured")
+ public int getQueryThresholdInSecs() {
+ return queryThresholdInSecs;
+ }
+
+ public void setQueryThresholdInSecs(int queryThresholdInSecs) {
+ this.queryThresholdInSecs = queryThresholdInSecs;
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-05-22 21:57:32 UTC (rev 2149)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-05-24 16:41:41 UTC (rev 2150)
@@ -173,6 +173,7 @@
private int maxCodeRecords = DQPConfiguration.DEFAULT_MAX_CODE_RECORDS;
private int maxFetchSize = DQPConfiguration.DEFAULT_FETCH_SIZE;
+ private int queryThreshold = DQPConfiguration.DEFAULT_QUERY_THRESHOLD;
// Resources
private BufferManager bufferManager;
@@ -214,7 +215,7 @@
if (state == null) {
return Collections.emptyList();
}
- return buildRequestInfos(state.getRequests());
+ return buildRequestInfos(state.getRequests(), -1);
}
public ClientState getClientState(String key, boolean create) {
@@ -232,10 +233,14 @@
* Return a list of all {@link RequestMetadata}
*/
public List<RequestMetadata> getRequests() {
- return buildRequestInfos(requests.keySet());
+ return buildRequestInfos(requests.keySet(), -1);
}
+
+ public List<RequestMetadata> getLongRunningRequests(){
+ return buildRequestInfos(requests.keySet(), this.queryThreshold);
+ }
- private List<RequestMetadata> buildRequestInfos(Collection<RequestID> ids) {
+ private List<RequestMetadata> buildRequestInfos(Collection<RequestID> ids, int longRunningQueryThreshold) {
List<RequestMetadata> results = new ArrayList<RequestMetadata>();
for (RequestID requestID : ids) {
@@ -291,7 +296,12 @@
info.setState(conInfo.isCanceled()?ProcessingState.CANCELED:conInfo.isDone()?ProcessingState.DONE:ProcessingState.PROCESSING);
results.add(info);
}
- results.add(req);
+
+ // check if only need long running queries.
+ long elapsedTime = System.currentTimeMillis() - req.getStartTime();
+ if (longRunningQueryThreshold == -1 || elapsedTime > longRunningQueryThreshold) {
+ results.add(req);
+ }
}
}
return results;
@@ -624,6 +634,7 @@
this.maxCodeTables = config.getCodeTablesMaxCount();
this.maxCodeRecords = config.getCodeTablesMaxRows();
this.useEntitlements = config.useEntitlements();
+ this.queryThreshold = config.getQueryThresholdInSecs();
this.chunkSize = config.getLobChunkSizeInKB() * 1024;
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-05-22 21:57:32 UTC (rev 2149)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-05-24 16:41:41 UTC (rev 2150)
@@ -247,6 +247,13 @@
}
@Override
+ @ManagementOperation(description="Long running requests", impact=Impact.ReadOnly)
+ public List<RequestMetadata> getLongRunningRequests() {
+ return this.dqpCore.getLongRunningRequests();
+ }
+
+
+ @Override
@ManagementOperation(description="Get Runtime workmanager statistics", impact=Impact.ReadOnly,params={@ManagementParameter(name="identifier",description="Use \"runtime\" for engine, or connector name for connector")})
public WorkerPoolStatisticsMetadata getWorkManagerStatistics(String identifier) {
if ("runtime".equalsIgnoreCase(identifier)) { //$NON-NLS-1$
14 years, 7 months
teiid SVN: r2149 - in trunk/connectors/translator-xml/src: main/java/org/teiid/translator/xml/streaming and 3 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-05-22 17:57:32 -0400 (Sat, 22 May 2010)
New Revision: 2149
Added:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/StremableDocument.java
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestHttpExecution.java
trunk/connectors/translator-xml/src/test/resources/xmltest.vdb
Removed:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/Document.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/DocumentImpl.java
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/BaseStreamingExecution.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/ElementProcessor.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/StreamingResultsProducer.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/StreamingRowCollector.java
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestElementCollector.java
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestSoapExecution.java
Log:
TEIID-1077: Fixed the feature to add request parameter to the resultset; added a test for the HTTP-relational model
Deleted: trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/Document.java
===================================================================
--- trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/Document.java 2010-05-21 20:33:45 UTC (rev 2148)
+++ trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/Document.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -1,12 +0,0 @@
-package org.teiid.translator.xml;
-
-import java.io.InputStream;
-import java.sql.SQLException;
-
-public interface Document {
-
- public InputStream getStream() throws SQLException;
-
- public String getCachekey();
-
-}
Modified: trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java
===================================================================
--- trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java 2010-05-21 20:33:45 UTC (rev 2148)
+++ trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -35,7 +35,6 @@
import org.teiid.translator.FileConnection;
import org.teiid.translator.ResultSetExecution;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.xml.streaming.DocumentImpl;
import org.teiid.translator.xml.streaming.InvalidPathException;
import org.teiid.translator.xml.streaming.StreamingResultsProducer;
import org.teiid.translator.xml.streaming.XPathSplitter;
@@ -47,7 +46,7 @@
private int docNumber = 0;
private File[] content;
private XMLExecutionFactory executionFactory;
- private List<Document> resultDocuments = null;
+ private List<StremableDocument> resultDocuments = null;
private StreamingResultsProducer streamProducer;
private List<Object[]> currentRowSet;
private int currentRow = 0;
@@ -87,7 +86,7 @@
@Override
public void execute() throws TranslatorException {
if (this.content != null) {
- this.resultDocuments = new ArrayList<Document>();
+ this.resultDocuments = new ArrayList<StremableDocument>();
int i = 0;
for(File f:this.content) {
this.resultDocuments.add(getDocumentStream(f, i++));
@@ -128,14 +127,14 @@
}
}
- private Document getDocumentStream(final File xmlFile, int fileNumber) {
+ private StremableDocument getDocumentStream(final File xmlFile, int fileNumber) {
InputStreamFactory isf = new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
return new BufferedInputStream(new FileInputStream(xmlFile));
}
};
- return new DocumentImpl(this.executionFactory.convertToXMLType(isf), xmlFile.getName()+fileNumber);
+ return new StremableDocument(this.executionFactory.convertToXMLType(isf), xmlFile.getName()+fileNumber);
}
@Override
Copied: trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/StremableDocument.java (from rev 2148, trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/Document.java)
===================================================================
--- trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/StremableDocument.java (rev 0)
+++ trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/StremableDocument.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -0,0 +1,25 @@
+package org.teiid.translator.xml;
+
+import java.io.InputStream;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+
+public class StremableDocument {
+
+ private SQLXML xml;
+ private String cacheKey;
+
+ public StremableDocument(SQLXML xml, String cacheKey) {
+ this.xml = xml;
+ this.cacheKey = cacheKey;
+ }
+
+ public InputStream getStream() throws SQLException{
+ return xml.getBinaryStream();
+ }
+
+ public String getCachekey() {
+ return cacheKey;
+ }
+
+}
Modified: trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/BaseStreamingExecution.java
===================================================================
--- trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/BaseStreamingExecution.java 2010-05-21 20:33:45 UTC (rev 2148)
+++ trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/BaseStreamingExecution.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -52,7 +52,7 @@
import org.teiid.translator.TranslatorException;
import org.teiid.translator.xml.Constants;
import org.teiid.translator.xml.CriteriaDesc;
-import org.teiid.translator.xml.Document;
+import org.teiid.translator.xml.StremableDocument;
import org.teiid.translator.xml.DocumentBuilder;
import org.teiid.translator.xml.ExecutionInfo;
import org.teiid.translator.xml.OutputXPathDesc;
@@ -81,7 +81,7 @@
Dispatch<Source> dispatch;
ExecutionInfo executionInfo;
Source soapPayload;
- Iterator<Document> resultsIterator;
+ Iterator<StremableDocument> resultsIterator;
public BaseStreamingExecution(List<CriteriaDesc> requestParams, ExecutionInfo executionInfo, ExecutionContext context, XMLExecutionFactory executionFactory, Dispatch<Source> dispatch) throws TranslatorException {
this.context = context;
@@ -202,9 +202,9 @@
private void fillInResults() throws TranslatorException {
List<Object[]> rows;
StreamingResultsProducer streamProducer = new StreamingResultsProducer(this.executionInfo, this.executionFactory.getSaxFilterProvider());
- Iterator<Document> streamIter = this.resultsIterator;
+ Iterator<StremableDocument> streamIter = this.resultsIterator;
while (streamIter.hasNext()) {
- Document xml = streamIter.next();
+ StremableDocument xml = streamIter.next();
// TODO: add stream filter class. --rareddy
rows = streamProducer.getResult(xml, getXPaths());
if (rows.isEmpty()) {
@@ -308,8 +308,8 @@
}
- private List<Document> getDocumentStream(ExecutionInfo executionInfo) {
- ArrayList<Document> docs = new ArrayList<Document>();
+ private List<StremableDocument> getDocumentStream(ExecutionInfo executionInfo) {
+ ArrayList<StremableDocument> docs = new ArrayList<StremableDocument>();
// Is this a request part joining across a document
CriteriaDesc criterion = executionInfo.getResponseIDCriterion();
@@ -318,7 +318,7 @@
List<SQLXML> xmls = this.executionFactory.getResponse(responseid);
for (SQLXML xml:xmls) {
Assertion.isNotNull(xml);
- docs.add(new DocumentImpl(xml, responseid));
+ docs.add(new StremableDocument(xml, responseid));
}
} else {
// Not a join, but might still be cached.
@@ -332,7 +332,7 @@
}
}
this.executionFactory.setResponse(this.context.getExecutionCountIdentifier(), responseBody);
- docs.add(new DocumentImpl(responseBody, this.context.getExecutionCountIdentifier()));
+ docs.add(new StremableDocument(responseBody, this.context.getExecutionCountIdentifier()));
}
return docs;
}
@@ -378,7 +378,7 @@
String inputParmsXPath = props.get(DocumentBuilder.PARM_INPUT_XPATH_TABLE_PROPERTY_NAME);
String namespacePrefixes = props.get(Constants.NAMESPACE_PREFIX_PROPERTY_NAME);
- if(inputParmsXPath.equals(SLASH)) {
+ if(inputParmsXPath == null || inputParmsXPath.equals(SLASH)) {
inputParmsXPath = "SLASH"; //$NON-NLS-1$
}
Deleted: trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/DocumentImpl.java
===================================================================
--- trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/DocumentImpl.java 2010-05-21 20:33:45 UTC (rev 2148)
+++ trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/DocumentImpl.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -1,27 +0,0 @@
-package org.teiid.translator.xml.streaming;
-
-import java.io.InputStream;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-
-public class DocumentImpl implements org.teiid.translator.xml.Document {
-
- private SQLXML xml;
- private String cacheKey;
-
- public DocumentImpl(SQLXML xml, String cacheKey) {
- this.xml = xml;
- this.cacheKey = cacheKey;
- }
-
- @Override
- public InputStream getStream() throws SQLException{
- return xml.getBinaryStream();
- }
-
- @Override
- public String getCachekey() {
- return cacheKey;
- }
-
-}
Modified: trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/ElementProcessor.java
===================================================================
--- trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/ElementProcessor.java 2010-05-21 20:33:45 UTC (rev 2148)
+++ trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/ElementProcessor.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -1,7 +1,6 @@
package org.teiid.translator.xml.streaming;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -14,9 +13,9 @@
import org.teiid.translator.TranslatorException;
import org.teiid.translator.xml.CriteriaDesc;
-import org.teiid.translator.xml.Document;
import org.teiid.translator.xml.ExecutionInfo;
import org.teiid.translator.xml.OutputXPathDesc;
+import org.teiid.translator.xml.StremableDocument;
import org.teiid.translator.xml.XMLPlugin;
@@ -31,10 +30,11 @@
*/
public class ElementProcessor {
+ private static final String CRITERIA_PREFIX = "_criteria_"; //$NON-NLS-1$
private ExecutionInfo info;
private Object[] row;
private Map<String, OutputXPathDesc> resultPaths;
- private OutputXPathDesc cacheKeyColumn;
+ private OutputXPathDesc responseId;
private Map<String, String> namespacesToPrefixMap;
private boolean rowExcluded = false;
@@ -52,7 +52,7 @@
public Object[] process(Node element) {
setRowExcluded(false);
row = new Object[resultPaths.size()];
- listChildren(element, "");
+ listChildren(element, ""); //$NON-NLS-1$
return row;
}
@@ -61,26 +61,37 @@
* @param xml the XML Document
* @param result the result batch for the query
*/
- public void insertResponseId(Document xml, List<Object[]> result) {
- if (null != cacheKeyColumn) {
- Object[] aRow;
+ public void insertProjectedParameters(StremableDocument xml, List<Object[]> result) {
+ if (responseId != null) {
if (!result.isEmpty()) {
- for (Iterator<Object[]> iter = result.iterator(); iter.hasNext();) {
- aRow = iter.next();
- aRow[cacheKeyColumn.getColumnNumber()] = xml.getCachekey();
+ for (Object[] aRow:result) {
+ aRow[responseId.getColumnNumber()] = xml.getCachekey();
}
} else {
- aRow = new Object[resultPaths.size()];
- aRow[cacheKeyColumn.getColumnNumber()] = xml.getCachekey();
+ Object[] aRow = new Object[resultPaths.size()];
+ aRow[responseId.getColumnNumber()] = xml.getCachekey();
result.add(aRow);
}
}
+
+ for (String column:resultPaths.keySet()) {
+ if (column != null && column.startsWith(CRITERIA_PREFIX)) {
+ OutputXPathDesc oxd = this.resultPaths.get(column);
+
+ if (!result.isEmpty()) {
+ for (Object[] aRow:result) {
+ aRow[oxd.getColumnNumber()] = oxd.getCurrentValue();
+ }
+ }
+ else {
+ Object[] aRow = new Object[resultPaths.size()];
+ aRow[oxd.getColumnNumber()] = oxd.getCurrentValue();
+ result.add(aRow);
+ }
+ }
+ }
}
- private void insertProjectedParameters() {
- //TODO insertProjectedParameters
- }
-
/**
* Match the current path against the Map of requested paths and add
* the matches to the result row.
@@ -97,7 +108,12 @@
Element temp = (Element) current;
for (int i = 0; i < temp.getAttributeCount(); i++) {
Attribute attribute = temp.getAttribute(i);
- String attrPath = path + "/@" + getLocalQName(attribute);
+
+ String attrPath = "@" + getLocalQName(attribute); //$NON-NLS-1$
+ if (path != null && path.length()> 0) {
+ attrPath = path + "/@" + getLocalQName(attribute); //$NON-NLS-1$
+ }
+
if(resultPaths.containsKey(attrPath)) {
handleNode(attribute, attrPath);
if(isRowExcluded()) {
@@ -115,7 +131,7 @@
path = path + '/' + temp.getRootElementName();
}
else if (current instanceof Text) {
- String textPath = path + "/text()";
+ String textPath = path + "/text()"; //$NON-NLS-1$
if(resultPaths.containsKey(textPath)) {
handleNode(current, textPath);
if(isRowExcluded()) {
@@ -161,7 +177,7 @@
localName = attribute.getLocalName();
}
if(null == namespaceURI) {
- throw new Error("namespce URI not found in model namespaces");
+ throw new Error("namespce URI not found in model namespaces"); //$NON-NLS-1$
}
String prefix = namespacesToPrefixMap.get(namespaceURI);
String result;
@@ -180,10 +196,9 @@
if(!passesCriteriaCheck(info.getCriteria(), node.getValue(), columnNum)) {
setRowExcluded(true);
return;
- } else {
- //TODO: type conversion
- row[columnNum] = node.getValue();
- }
+ }
+ //TODO: type conversion
+ row[columnNum] = node.getValue();
}
/**
@@ -229,8 +244,11 @@
if (xpathString != null) {
xpathString = relativizeAbsoluteXpath(xpathString);
}
+ else if (xPathDesc.getCurrentValue() != null) {
+ xpathString = CRITERIA_PREFIX+xPathDesc.getColumnName();
+ }
} else {
- cacheKeyColumn = xPathDesc;
+ responseId = xPathDesc;
}
xpaths.put(xpathString, xPathDesc);
}
Modified: trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/StreamingResultsProducer.java
===================================================================
--- trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/StreamingResultsProducer.java 2010-05-21 20:33:45 UTC (rev 2148)
+++ trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/StreamingResultsProducer.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -26,7 +26,7 @@
import java.util.Map;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.xml.Document;
+import org.teiid.translator.xml.StremableDocument;
import org.teiid.translator.xml.ExecutionInfo;
import org.teiid.translator.xml.SAXFilterProvider;
import org.xml.sax.SAXException;
@@ -63,7 +63,7 @@
* @return result set rows
* @throws TranslatorException
*/
- public List<Object[]> getResult(Document xml, List<String> xpaths) throws TranslatorException {
+ public List<Object[]> getResult(StremableDocument xml, List<String> xpaths) throws TranslatorException {
List<Object[]> rows;
try {
Modified: trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/StreamingRowCollector.java
===================================================================
--- trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/StreamingRowCollector.java 2010-05-21 20:33:45 UTC (rev 2148)
+++ trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/StreamingRowCollector.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -11,7 +11,7 @@
import nux.xom.xquery.StreamingTransform;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.xml.Document;
+import org.teiid.translator.xml.StremableDocument;
import org.xml.sax.XMLReader;
@@ -42,7 +42,7 @@
* @throws TranslatorException
* @throws InvalidPathException
*/
- public List<Object[]> getElements(Document xml, List<String> xPaths)
+ public List<Object[]> getElements(StremableDocument xml, List<String> xPaths)
throws TranslatorException, InvalidPathException {
result.clear();
StreamingTransform myTransform = new StreamingTransform() {
@@ -61,7 +61,7 @@
} catch (Exception e) {
throw new TranslatorException(e);
}
- elemProcessor.insertResponseId(xml, result);
+ elemProcessor.insertProjectedParameters(xml, result);
return result;
}
Modified: trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestElementCollector.java
===================================================================
--- trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestElementCollector.java 2010-05-21 20:33:45 UTC (rev 2148)
+++ trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestElementCollector.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -14,8 +14,6 @@
import org.teiid.core.types.InputStreamFactory;
import org.teiid.core.types.SQLXMLImpl;
import org.teiid.language.Select;
-import org.teiid.translator.xml.Document;
-import org.teiid.translator.xml.streaming.DocumentImpl;
import org.teiid.translator.xml.streaming.ElementProcessor;
import org.teiid.translator.xml.streaming.ReaderFactory;
import org.teiid.translator.xml.streaming.StreamingRowCollector;
@@ -52,7 +50,7 @@
String path = "/po:purchaseOrders/order/items/item";
int itemCount = 5968;
try {
- Document doc = new DocumentImpl(getSQLXML(new FileInputStream(filename)), "foo");
+ StremableDocument doc = new StremableDocument(getSQLXML(new FileInputStream(filename)), "foo");
List result = builder.getElements(doc, Arrays.asList(path));
assertEquals(itemCount, result.size());
} catch (Exception e) {
@@ -64,7 +62,7 @@
String path = "/";
int itemCount = 1;
try {
- Document doc = new DocumentImpl(getSQLXML(new FileInputStream(filename)), "foo");
+ StremableDocument doc = new StremableDocument(getSQLXML(new FileInputStream(filename)), "foo");
List result = builder.getElements(doc, Arrays.asList(path));
assertEquals(itemCount, result.size());
} catch (Exception e) {
Added: trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestHttpExecution.java
===================================================================
--- trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestHttpExecution.java (rev 0)
+++ trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestHttpExecution.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -0,0 +1,181 @@
+/*
+ * 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.translator.xml.streaming;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.resource.ResourceException;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.handler.MessageContext;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.resource.spi.BasicConnection;
+import org.teiid.resource.spi.BasicConnectionFactory;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.xml.XMLExecutionFactory;
+import org.teiid.translator.xml.streaming.TestSoapExecution.MyDispatch;
+
+import com.metamatrix.cdk.api.ConnectorHost;
+
+@SuppressWarnings("nls")
+public class TestHttpExecution {
+
+
+ public static BasicConnectionFactory getCF() {
+ BasicConnectionFactory cf = new BasicConnectionFactory() {
+ @Override
+ public BasicConnection getConnection() throws ResourceException {
+ String usResult = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<ns2:purchaseOrderList xmlns:ns2=\"http://www.example.com/PO1\" xmlns:ns3=\"http://www.example.org/PO1\">\n" +
+ " <ns3:purchaseOrders orderDate=\"2010-05-22-04:00\">\n" +
+ " <shipTo country=\"Ship_Country_6\">\n" +
+ " <name>Ship_Name_6</name>\n" +
+ " <street>Ship_Street_6</street>\n" +
+ " <city>Ship_City_6</city>\n" +
+ " <state>Ship_State_6</state>\n" +
+ " <zip>6</zip>\n" +
+ " </shipTo>\n" +
+ " <billTo country=\"Bill_Country_6\">\n" +
+ " <name>Bill_Name_6</name>\n" +
+ " <street>Bill_Street_6</street>\n" +
+ " <city>Bill_City_6</city>\n" +
+ " <state>Bill_State_6</state>\n" +
+ " <zip>6</zip>\n" +
+ " </billTo>\n" +
+ " <items>\n" +
+ " <item partNum=\"0\">\n" +
+ " <productName>Product0</productName>\n" +
+ " <quantity>0</quantity>\n" +
+ " <USPrice>0</USPrice>\n" +
+ " <ns2:comment>Comment 0</ns2:comment>\n" +
+ " <shipDate>2010-05-22-04:00</shipDate>\n" +
+ " </item>\n" +
+ " <item partNum=\"1\">\n" +
+ " <productName>Product1</productName>\n" +
+ " <quantity>1</quantity>\n" +
+ " <USPrice>1</USPrice>\n" +
+ " <ns2:comment>Comment 1</ns2:comment>\n" +
+ " <shipDate>2010-05-22-04:00</shipDate>\n" +
+ " </item>\n" +
+ " <item partNum=\"2\">\n" +
+ " <productName>Product2</productName>\n" +
+ " <quantity>2</quantity>\n" +
+ " <USPrice>2</USPrice>\n" +
+ " <ns2:comment>Comment 2</ns2:comment>\n" +
+ " <shipDate>2010-05-22-04:00</shipDate>\n" +
+ " </item>\n" +
+ " </items>\n" +
+ " </ns3:purchaseOrders>\n" +
+ " <ns3:purchaseOrders orderDate=\"2010-05-22-04:00\">\n" +
+ " <shipTo country=\"Ship_Country_7\">\n" +
+ " <name>Ship_Name_7</name>\n" +
+ " <street>Ship_Street_7</street>\n" +
+ " <city>Ship_City_7</city>\n" +
+ " <state>Ship_State_7</state>\n" +
+ " <zip>7</zip>\n" +
+ " </shipTo>\n" +
+ " <billTo country=\"Bill_Country_7\">\n" +
+ " <name>Bill_Name_7</name>\n" +
+ " <street>Bill_Street_7</street>\n" +
+ " <city>Bill_City_7</city>\n" +
+ " <state>Bill_State_7</state>\n" +
+ " <zip>7</zip>\n" +
+ " </billTo>\n" +
+ " <items>\n" +
+ " <item partNum=\"0\">\n" +
+ " <productName>Product0</productName>\n" +
+ " <quantity>0</quantity>\n" +
+ " <USPrice>0</USPrice>\n" +
+ " <ns2:comment>Comment 0</ns2:comment>\n" +
+ " <shipDate>2010-05-22-04:00</shipDate>\n" +
+ " </item>\n" +
+ " <item partNum=\"1\">\n" +
+ " <productName>Product1</productName>\n" +
+ " <quantity>1</quantity>\n" +
+ " <USPrice>1</USPrice>\n" +
+ " <ns2:comment>Comment 1</ns2:comment>\n" +
+ " <shipDate>2010-05-22-04:00</shipDate>\n" +
+ " </item>\n" +
+ " <item partNum=\"2\">\n" +
+ " <productName>Product2</productName>\n" +
+ " <quantity>2</quantity>\n" +
+ " <USPrice>2</USPrice>\n" +
+ " <ns2:comment>Comment 2</ns2:comment>\n" +
+ " <shipDate>2010-05-22-04:00</shipDate>\n" +
+ " </item>\n" +
+ " </items>\n" +
+ " </ns3:purchaseOrders>\n" +
+ "</ns2:purchaseOrderList>";
+
+
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put("result", usResult);
+ return new HttpDispatch(map);
+ }
+
+ };
+ return cf;
+ }
+
+ static class HttpDispatch extends MyDispatch{
+
+ public HttpDispatch(Map<String, String> result) {
+ super(result);
+ }
+
+ @Override
+ public Source invoke(Source msg) {
+ String qt = (String)this.getRequestContext().get(MessageContext.QUERY_STRING);
+ assertEquals("orderCount=2&itemCount=3&", qt);
+ return new StreamSource(new StringReader(result.get("result"))); //$NON-NLS-1$
+ }
+ }
+
+ @Test
+ public void testHttpExecution() throws Exception{
+ XMLExecutionFactory factory = new XMLExecutionFactory();
+
+ String vdbPath = UnitTestUtil.getTestDataPath()+"/xmltest.vdb";
+ ConnectorHost host = new ConnectorHost(factory, getCF(), vdbPath);
+ ExecutionContext context = Mockito.mock(ExecutionContext.class);
+ Mockito.stub(context.getExecutionCountIdentifier()).toReturn("1.1");
+ host.setExecutionContext(context);
+
+ List result = host.executeCommand("SELECT queryParams.REQUEST.ResponseOut, queryParams.REQUEST.itemcount, queryParams.REQUEST.ordercount FROM queryParams.REQUEST WHERE (queryParams.REQUEST.itemcount = '3') AND (queryParams.REQUEST.ordercount = '2')", false);
+ assertEquals(1, result.size());
+ assertEquals(Arrays.asList(new Object[] {"1.1", "3", "2"}), result.get(0));
+
+ result = host.executeCommand("SELECT queryParams.item.partNum, queryParams.item.productName, queryParams.item.quantity, queryParams.item.USPrice, queryParams.item.comment, queryParams.item.shipDate FROM queryParams.item WHERE queryParams.item.ResponseIn = '1.1'");
+
+ assertEquals(6, result.size());
+ assertEquals(Arrays.asList(new Object[] {"1", "Product1","1","1","Comment 1","2010-05-22-04:00"}), result.get(1));
+ }
+}
Modified: trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestSoapExecution.java
===================================================================
--- trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestSoapExecution.java 2010-05-21 20:33:45 UTC (rev 2148)
+++ trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestSoapExecution.java 2010-05-22 21:57:32 UTC (rev 2149)
@@ -166,7 +166,7 @@
static class MyDispatch extends BasicConnection implements Dispatch<Source>{
private Map<String, Object> requestContext = new HashMap<String, Object>();
- private Map<String, String> result;
+ Map<String, String> result;
public MyDispatch(Map<String, String> result) {
this.result = result;
Added: trunk/connectors/translator-xml/src/test/resources/xmltest.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/connectors/translator-xml/src/test/resources/xmltest.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 7 months
teiid SVN: r2148 - in trunk/build/kits/jboss-container: teiid-examples/portfolio and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-05-21 16:33:45 -0400 (Fri, 21 May 2010)
New Revision: 2148
Modified:
trunk/build/kits/jboss-container/deploy/teiid/connectors/jdbc-translator.xml
trunk/build/kits/jboss-container/teiid-examples/portfolio/marketdata-text-translator.xml
Log:
TEIID-1077 fixing the previous fixes
Modified: trunk/build/kits/jboss-container/deploy/teiid/connectors/jdbc-translator.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/connectors/jdbc-translator.xml 2010-05-20 21:51:04 UTC (rev 2147)
+++ trunk/build/kits/jboss-container/deploy/teiid/connectors/jdbc-translator.xml 2010-05-21 20:33:45 UTC (rev 2148)
@@ -79,7 +79,7 @@
<translator>
<name>jdbc-simple</name>
- <execution-factory-class>org.teiid.translator.jdbc.SimpleExecutionFactory</execution-factory-class>
+ <execution-factory-class>org.teiid.translator.jdbc.SimpleJDBCExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
<template-name>translator-jdbc-${project.version}</template-name>
</translator>
Modified: trunk/build/kits/jboss-container/teiid-examples/portfolio/marketdata-text-translator.xml
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/portfolio/marketdata-text-translator.xml 2010-05-20 21:51:04 UTC (rev 2147)
+++ trunk/build/kits/jboss-container/teiid-examples/portfolio/marketdata-text-translator.xml 2010-05-21 20:33:45 UTC (rev 2148)
@@ -4,6 +4,6 @@
<name>text</name>
<execution-factory-class>org.teiid.translator.text.TextExecutionFactory</execution-factory-class>
<template-name>translator-text-${project.version}</template-name>
- <translator-property name="ParentDirectory" value="file://${jboss.server.home.dir}/teiid-examples/portfolio/marketdata-def.txt"/>
+ <translator-property name="DescriptorFile" value="file://${jboss.server.home.dir}/teiid-examples/portfolio/marketdata-def.txt"/>
</translator>
</translator-factory>
\ No newline at end of file
14 years, 7 months
teiid SVN: r2146 - trunk/engine/src/main/java/org/teiid/query/processor/program.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-05-19 21:13:35 -0400 (Wed, 19 May 2010)
New Revision: 2146
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/program/Program.java
Log:
fix for refactoring error in the tostring method
Modified: trunk/engine/src/main/java/org/teiid/query/processor/program/Program.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/program/Program.java 2010-05-19 23:20:03 UTC (rev 2145)
+++ trunk/engine/src/main/java/org/teiid/query/processor/program/Program.java 2010-05-20 01:13:35 UTC (rev 2146)
@@ -182,29 +182,24 @@
* The sub program(s) from those kinds of instructions are passed, recursively, into this
* method.
*/
- private final int programToString(StringBuilder str) {
+ private final void programToString(StringBuilder str) {
int instructionIndex = 0;
ProgramInstruction inst = getInstructionAt(instructionIndex);
while(inst != null) {
- printLine(counter++, inst.toString(), str);
+ printLine(instructionIndex++, inst.toString(), str);
- if(counter > 1000) {
- printLine(counter, "[OUTPUT TRUNCATED...]", str); //$NON-NLS-1$
+ if(instructionIndex > 1000) {
+ printLine(instructionIndex, "[OUTPUT TRUNCATED...]", str); //$NON-NLS-1$
break;
}
- instructionIndex++;
inst = getInstructionAt(instructionIndex);
-
}
-
- return counter;
}
-
private static final void printLine(int counter, String line, StringBuilder buffer) {
// Pad counter with spaces
String counterStr = "" + counter + ": "; //$NON-NLS-1$ //$NON-NLS-2$
14 years, 7 months
teiid SVN: r2145 - in trunk/console: src/main/java/org/teiid/rhq/plugin and 5 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-05-19 19:20:03 -0400 (Wed, 19 May 2010)
New Revision: 2145
Added:
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertyListAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertyMapAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertySimpleAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/MeasurementAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/MeasurementAdapterFactory.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapterFactory.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/AbstractPropertyMapToCompositeValueAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToArrayValueAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToCollectionValueAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToMapCompositeValueSupportAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToPropertiesValueAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertySimpleToEnumValueAdapter.java
trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertySimpleToSimpleValueAdapter.java
Removed:
trunk/console/src/main/java/org/teiid/rhq/plugin/QueriesComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/SessionComponent.java
Modified:
trunk/console/pom.xml
trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
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/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
trunk/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-807: Added Translator creation logic
Modified: trunk/console/pom.xml
===================================================================
--- trunk/console/pom.xml 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/pom.xml 2010-05-19 23:20:03 UTC (rev 2145)
@@ -159,6 +159,28 @@
</dependency> -->
</dependencies>
+
+ <build>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
</project>
\ No newline at end of file
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -29,13 +29,22 @@
import java.util.Map;
import java.util.Set;
+import javax.naming.NamingException;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.transfer.DeployPackageStep;
@@ -45,13 +54,13 @@
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.content.version.PackageVersions;
import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.content.ContentFacet;
import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.content.version.PackageVersions;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
@@ -104,22 +113,23 @@
* C:/opt/jboss-5.0.0.GA/server/default/deploy/foo.vdb).
*/
protected String deploymentName;
-
+
private PackageVersions versions = null;
-
- /**
- * Name of the backing package type that will be used when discovering packages. This corresponds to the name of the
- * package type defined in the plugin descriptor. For simplicity, the package type for VDBs is called "vdb". This is
- * still unique within the context of the parent resource type and lets this class use the same package type name in
- * both cases.
- */
- private static final String PKG_TYPE_VDB = "vdb";
- /**
- * Architecture string used in describing discovered packages.
- */
- private static final String ARCHITECTURE = "noarch";
+ /**
+ * Name of the backing package type that will be used when discovering
+ * packages. This corresponds to the name of the package type defined in the
+ * plugin descriptor. For simplicity, the package type for VDBs is called
+ * "vdb". This is still unique within the context of the parent resource
+ * type and lets this class use the same package type name in both cases.
+ */
+ private static final String PKG_TYPE_VDB = "vdb";
+ /**
+ * Architecture string used in describing discovered packages.
+ */
+ private static final String ARCHITECTURE = "noarch";
+
abstract String getComponentType();
/**
@@ -299,7 +309,6 @@
// this simulates the plugin taking the new configuration and
// reconfiguring the managed resource
resourceConfiguration = report.getConfiguration().deepCopy();
-
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
}
@@ -346,7 +355,7 @@
File deploymentFile = null;
if (this.deploymentName != null) {
- deploymentFile = new File(deploymentName.substring(7));
+ deploymentFile = new File(deploymentName.substring(7));
}
if (!deploymentFile.exists())
@@ -374,7 +383,7 @@
if (!deploymentFile.isDirectory())
packageDetails.setFileSize(deploymentFile.length());
packageDetails.setFileCreatedDate(null); // TODO: get created date via
- // SIGAR
+ // SIGAR
Set<ResourcePackageDetails> packages = new HashSet<ResourcePackageDetails>();
packages.add(packageDetails);
@@ -398,9 +407,107 @@
return null;
}
+
+ protected static Configuration getDefaultPluginConfiguration(
+ ResourceType resourceType) {
+ ConfigurationTemplate pluginConfigDefaultTemplate = resourceType
+ .getPluginConfigurationDefinition().getDefaultTemplate();
+ return (pluginConfigDefaultTemplate != null) ? pluginConfigDefaultTemplate
+ .createConfiguration()
+ : new Configuration();
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.rhq.core.pluginapi.inventory.CreateChildResourceFacet#createResource(org.rhq.core.pluginapi.inventory.CreateResourceReport)
+ */
@Override
- public CreateResourceReport createResource(
+ public CreateResourceReport createResource(CreateResourceReport report) {
+ ResourceType resourceType = report.getResourceType();
+ if (resourceType.getName().equals("Translators")){
+ createConfigurationBasedResource(report);
+ }else{
+ createContentBasedResource(report);
+ }
+
+ return report;
+ }
+
+ private CreateResourceReport createConfigurationBasedResource(
CreateResourceReport createResourceReport) {
+ ResourceType resourceType = createResourceReport.getResourceType();
+ Configuration defaultPluginConfig =
+ getDefaultPluginConfiguration(resourceType);
+ Configuration resourceConfig = createResourceReport
+ .getResourceConfiguration();
+ String resourceName = getResourceName(defaultPluginConfig,
+ resourceConfig);
+ ComponentType componentType = ProfileServiceUtil
+ .getComponentType(resourceType);
+ ManagementView managementView = null;;
+ try {
+ managementView = ProfileServiceUtil.getManagementView(
+ ProfileServiceUtil.getProfileService(), true);
+ } catch (NamingException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ if (ProfileServiceUtil.isManagedComponent(managementView,
+ resourceName, componentType)) {
+ createResourceReport.setStatus(CreateResourceStatus.FAILURE);
+ createResourceReport.setErrorMessage("A " + resourceType.getName()
+ + " named '" + resourceName + "' already exists.");
+ return createResourceReport;
+ }
+
+ createResourceReport.setResourceName(resourceName);
+ String resourceKey = getResourceKey(resourceType, resourceName);
+ createResourceReport.setResourceKey(resourceKey);
+
+ PropertySimple templateNameProperty = resourceConfig
+ .getSimple(TranslatorComponent.Config.TEMPLATE_NAME);
+ String templateName = templateNameProperty.getStringValue();
+
+ DeploymentTemplateInfo template;
+ Set templateNamesSet = managementView.getTemplateNames();
+ try {
+ template = managementView.getTemplate(templateName);
+ Map<String, ManagedProperty> managedProperties = template
+ .getProperties();
+
+ ProfileServiceUtil.convertConfigurationToManagedProperties(
+ managedProperties, resourceConfig, resourceType);
+
+ LOG.debug("Applying template [" + templateName
+ + "] to create ManagedComponent of type [" + componentType
+ + "]...");
+ try {
+ managementView.applyTemplate(resourceName, template);
+ managementView.process();
+ createResourceReport.setStatus(CreateResourceStatus.SUCCESS);
+ } catch (Exception e) {
+ LOG.error("Unable to apply template [" + templateName
+ + "] to create ManagedComponent of type "
+ + componentType + ".", e);
+ createResourceReport.setStatus(CreateResourceStatus.FAILURE);
+ createResourceReport.setException(e);
+ }
+ } catch (NoSuchDeploymentException e) {
+ LOG.error("Unable to find template [" + templateName + "].", e);
+ createResourceReport.setStatus(CreateResourceStatus.FAILURE);
+ createResourceReport.setException(e);
+ } catch (Exception e) {
+ LOG.error("Unable to process create request", e);
+ createResourceReport.setStatus(CreateResourceStatus.FAILURE);
+ createResourceReport.setException(e);
+ }
+ return createResourceReport;
+ }
+
+ protected void createContentBasedResource(
+ CreateResourceReport createResourceReport) {
+
ResourcePackageDetails details = createResourceReport
.getPackageDetails();
PackageDetailsKey key = details.getKey();
@@ -417,7 +524,7 @@
createResourceReport
.setErrorMessage("Incorrect extension specified on filename ["
+ archivePath + "]");
- return createResourceReport;
+
}
DeploymentManager deploymentManager = ProfileServiceUtil
@@ -437,9 +544,29 @@
createResourceReport.setException(t);
}
- return createResourceReport;
-
}
+
+ private static String getResourceName(Configuration pluginConfig, Configuration resourceConfig)
+ {
+ PropertySimple resourceNameProp = pluginConfig.getSimple(TranslatorComponent.Config.RESOURCE_NAME);
+ if (resourceNameProp == null || resourceNameProp.getStringValue() == null)
+ throw new IllegalStateException("Property [" + TranslatorComponent.Config.RESOURCE_NAME
+ + "] is not defined in the default plugin configuration.");
+ String resourceNamePropName = resourceNameProp.getStringValue();
+ PropertySimple propToUseAsResourceName = resourceConfig.getSimple(resourceNamePropName);
+ if (propToUseAsResourceName == null)
+ throw new IllegalStateException("Property [" + resourceNamePropName
+ + "] is not defined in initial Resource configuration.");
+ return propToUseAsResourceName.getStringValue();
+ }
+
+ private String getResourceKey(ResourceType resourceType, String resourceName)
+ {
+ ComponentType componentType = ProfileServiceUtil.getComponentType(resourceType);
+ if (componentType == null)
+ throw new IllegalStateException("Unable to map " + resourceType + " to a ComponentType.");
+ return componentType.getType() + ":" + componentType.getSubtype() + ":" + resourceName;
+ }
/**
* Returns an instantiated and loaded versions store access point.
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -35,6 +35,7 @@
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -174,6 +175,7 @@
}
}
+
@Override
public void stop() {
@@ -181,4 +183,6 @@
super.stop();
}
+
+
}
\ No newline at end of file
Deleted: trunk/console/src/main/java/org/teiid/rhq/plugin/QueriesComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/QueriesComponent.java 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/QueriesComponent.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -1,130 +0,0 @@
-/*
- * 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.rhq.plugin;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.Query;
-import org.teiid.rhq.plugin.objects.ExecutedResourceConfigurationResultImpl;
-
-
-/**
- * MetaMatrix Connector component class
- *
- */
-public class QueriesComponent extends Facet {
-
- private final Log LOG = LogFactory.getLog(QueriesComponent.class);
-
-
- private ExecutedResourceConfigurationResultImpl getQueries = null;
-
- /**
- * @see org.teiid.rhq.plugin.Facet#getComponentType()
- * @since 1.0
- */
- @Override
- String getComponentType() {
- return Queries.TYPE;
- }
-
- public void start(ResourceContext context) {
- super.start(context);
-
- Map defns = context.getResourceType().getResourceConfigurationDefinition().getPropertyDefinitions();
-
- getQueries = new ExecutedResourceConfigurationResultImpl(
- this.getComponentType(),
- Query.GET_QUERIES,
- defns);
- }
-
- protected void setOperationArguments(String name, Configuration configuration,
- Map argumentMap) {
-
-
- }
-
- @Override
- public AvailabilityType getAvailability() {
- return AvailabilityType.UP;
-
- }
-
- @Override
- public void getValues(MeasurementReport arg0,
- Set<MeasurementScheduleRequest> arg1) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
-
- /**
- * The plugin container will call this method and it needs to obtain the
- * current configuration of the managed resource. Your plugin will obtain
- * the managed resource's configuration in your own custom way and populate
- * the returned Configuration object with the managed resource's
- * configuration property values.
- *
- * @see ConfigurationFacet#loadResourceConfiguration()
- *
- */
- @Override
- public Configuration loadResourceConfiguration() {
- // here we simulate the loading of the managed resource's configuration
- Configuration config = this.getResourceConfiguration() ;
- if (config == null) {
- // for this example, we will create a simple dummy configuration to
- // start with.
- // note that it is empty, so we're assuming there are no required
- // configs in the plugin descriptor.
- config = new Configuration();
-
-
- }
-
- getQueries.reset();
-
- execute(getQueries, new HashMap());
-
-
- config.put( (PropertyList) getQueries.getResult());
-
-
- this.setResourceConfiguration(config);
- return this.getResourceConfiguration();
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/console/src/main/java/org/teiid/rhq/plugin/SessionComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/SessionComponent.java 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/SessionComponent.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -1,154 +0,0 @@
-/*
- * 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.rhq.plugin;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.Query;
-import org.teiid.rhq.plugin.objects.ExecutedResourceConfigurationResultImpl;
-
-
-/**
- * MetaMatrix Connector component class
- *
- */
-public class SessionComponent extends Facet {
-
- private final Log LOG = LogFactory.getLog(SessionComponent.class);
-
-
- private ExecutedResourceConfigurationResultImpl getSessions = null;
-
- /**
- * @see org.teiid.rhq.plugin.Facet#getComponentType()
- * @since 1.0
- */
- @Override
- String getComponentType() {
- return Session.TYPE;
- }
-
- public void start(ResourceContext context) {
- super.start(context);
-
- Map defns = context.getResourceType().getResourceConfigurationDefinition().getPropertyDefinitions();
-
- getSessions = new ExecutedResourceConfigurationResultImpl(
- this.getComponentType(),
- Query.GET_SESSIONS,
- defns);
- }
-
- protected void setOperationArguments(String name, Configuration configuration,
- Map argumentMap) {
-
-
- }
-
- @Override
- public AvailabilityType getAvailability() {
- return AvailabilityType.UP;
-
- }
-
- @Override
- public void getValues(MeasurementReport arg0,
- Set<MeasurementScheduleRequest> arg1) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
-
- /**
- * The plugin container will call this method and it needs to obtain the
- * current configuration of the managed resource. Your plugin will obtain
- * the managed resource's configuration in your own custom way and populate
- * the returned Configuration object with the managed resource's
- * configuration property values.
- *
- * @see ConfigurationFacet#loadResourceConfiguration()
- *
- */
- @Override
- public Configuration loadResourceConfiguration() {
- // here we simulate the loading of the managed resource's configuration
- Configuration config = this.getResourceConfiguration() ;
- if (config == null) {
- // for this example, we will create a simple dummy configuration to
- // start with.
- // note that it is empty, so we're assuming there are no required
- // configs in the plugin descriptor.
- config = new Configuration();
-
-
- }
-
- getSessions.reset();
-
- execute(getSessions, new HashMap());
-
-
- config.put( (PropertyList) getSessions.getResult());
-
-
- this.setResourceConfiguration(config);
- return this.getResourceConfiguration();
- }
-
-
-// class SessionComparable implements Comparator {
-//
-// public int compare(Object arg0, Object arg1) {
-// // TODO Auto-generated method stub
-// Component a = (Component) arg0;
-// Component b = (Component) arg1;
-//
-// if ( a == null && b == null ) {
-// return 0;
-// }
-// if ( a != null && b == null ) {
-// return 1;
-// }
-// if ( a == null && b != null ) {
-// return -1;
-// }
-// int result = a.get.compareTo(b.getDisplayName());
-// return result;
-// }
-
-
-
- // }
-
-}
\ No newline at end of file
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -21,42 +21,56 @@
*/
package org.teiid.rhq.plugin;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
+import javax.naming.NamingException;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
-
/**
* Component class for the MetaMatrix Host Controller process.
*
*/
public class TranslatorComponent extends Facet {
- private final Log LOG = LogFactory
- .getLog(TranslatorComponent.class);
+ private final Log LOG = LogFactory.getLog(TranslatorComponent.class);
+ public static interface Config {
+ String COMPONENT_TYPE = "componentType";
+ String COMPONENT_SUBTYPE = "componentSubtype";
+ String COMPONENT_NAME = "componentName";
+ String TEMPLATE_NAME = "template-name";
+ String RESOURCE_NAME = "resourceName";
+ }
- /**
- * @see org.teiid.rhq.plugin.Facet#getComponentType()
- * @since 1.0
- */
- @Override
- String getComponentType() {
- return ConnectionConstants.ComponentType.Resource.Model.TYPE;
- }
-
- /**
+ /**
+ * @see org.teiid.rhq.plugin.Facet#getComponentType()
+ * @since 1.0
+ */
+ @Override
+ String getComponentType() {
+ return ConnectionConstants.ComponentType.Resource.Model.TYPE;
+ }
+
+ /**
* The plugin container will call this method when your resource component
* has been scheduled to collect some measurements now. It is within this
* method that you actually talk to the managed resource and collect the
@@ -75,8 +89,8 @@
// actually need to collect
try {
Number value = new Integer(1); // dummy measurement value -
- // this should come from the
- // managed resource
+ // this should come from the
+ // managed resource
report.addData(new MeasurementDataNumeric(request, value
.doubleValue()));
} catch (Exception e) {
@@ -88,14 +102,17 @@
return;
}
- protected void setOperationArguments(String name, Configuration configuration,
- Map argumentMap) {
+ protected void setOperationArguments(String name,
+ Configuration configuration, Map argumentMap) {
- if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES)){
+ if (name
+ .equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES)) {
String key = ConnectionConstants.IDENTIFIER;
argumentMap.put(key, getComponentIdentifier());
}
-
- }
+
+ }
+
+
}
\ No newline at end of file
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -31,7 +31,6 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.CollectionValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
import org.rhq.core.domain.configuration.Configuration;
@@ -42,7 +41,6 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.teiid.adminapi.impl.PropertyMetadata;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -66,8 +64,6 @@
for (ManagedComponent translator : translators) {
- Map<String, ManagedProperty> managedPropertyMap = translator
- .getProperties();
String translatorKey = translator.getName();
String translatorName = ProfileServiceUtil.getSimpleValue(
translator, "name", String.class);
@@ -82,8 +78,7 @@
translatorName, // Resource Name
null, // Version
PluginConstants.ComponentType.Translator.DESCRIPTION, // Description
- discoveryContext.getDefaultPluginConfiguration(), // Plugin
- // Config
+ discoveryContext.getDefaultPluginConfiguration(), // Plugin config
null // Process info from a process scan
);
@@ -92,25 +87,34 @@
PropertyMap propMap = null;
c.put(list);
- for (ManagedProperty prop : managedPropertyMap.values()) {
- propMap = new PropertyMap("translatorMap");
- String name = prop.getName();
- if (name.equals("translator-property")) {
- getTranslatorValues(prop.getValue(), propMap, list);
- } else {
- propMap.put(new PropertySimple("name", name));
- propMap.put(new PropertySimple("value", ProfileServiceUtil
- .stringValue(prop.getValue())));
- propMap.put(new PropertySimple("description", prop
- .getDescription()));
- list.add(propMap);
- }
- }
+ // First get translator specific properties
+ ManagedProperty translatorProps = translator
+ .getProperty("translator-property");
+ getTranslatorValues(translatorProps.getValue(), propMap, list);
+ // Now get common properties
+ c.put(new PropertySimple("name", translatorName));
+ c.put(new PropertySimple("execution-factory-class",
+ ProfileServiceUtil.getSimpleValue(translator,
+ "execution-factory-class", String.class)));
+ c.put(new PropertySimple("immutable", ProfileServiceUtil
+ .getSimpleValue(translator, "immutable", Boolean.class)));
+ c.put(new PropertySimple("xa-capable", ProfileServiceUtil
+ .getSimpleValue(translator, "xa-capable", Boolean.class)));
+ c.put(new PropertySimple("exception-on-max-rows",
+ ProfileServiceUtil.getSimpleValue(translator,
+ "exception-on-max-rows", Boolean.class)));
+ c.put(new PropertySimple("max-result-rows", ProfileServiceUtil
+ .getSimpleValue(translator, "max-result-rows",
+ Integer.class)));
+ c.put(new PropertySimple("template-name", ProfileServiceUtil
+ .getSimpleValue(translator, "template-name",
+ String.class)));
+
detail.setPluginConfiguration(c);
// Add to return values
discoveredResources.add(detail);
- log.info("Discovered Teiid Translator: " + translatorName);
+ log.debug("Discovered Teiid Translator: " + translatorName);
}
return discoveredResources;
@@ -119,29 +123,22 @@
public static <T> void getTranslatorValues(MetaValue pValue,
PropertyMap map, PropertyList list) {
MetaType metaType = pValue.getMetaType();
- PropertyMetadata unwrappedvalue = null;
- if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue)
- .getElements()) {
- if (value.getMetaType().isComposite()) {
- map = new PropertyMap("translatorMap");
- unwrappedvalue = (PropertyMetadata) MetaValueFactory
- .getInstance().unwrap(value);
- map
- .put(new PropertySimple("name", unwrappedvalue
- .getName()));
- map.put(new PropertySimple("value", unwrappedvalue
- .getValue()));
- map
- .put(new PropertySimple("description",
- "Custom property"));
- list.add(map);
- } else {
- throw new IllegalStateException(pValue
- + " is not a Composite type");
- }
+ Map<String, T> unwrappedvalue = null;
+ if (metaType.isComposite()) {
+ unwrappedvalue = (Map<String, T>) MetaValueFactory
+ .getInstance().unwrap(pValue);
+
+ for (String key : unwrappedvalue.keySet()) {
+ map = new PropertyMap("translator-properties");
+ map.put(new PropertySimple("name", key));
+ map.put(new PropertySimple("value", unwrappedvalue.get(key)));
+ map.put(new PropertySimple("description", "Custom property"));
+ list.add(map);
}
+ } else {
+ throw new IllegalStateException(pValue + " is not a Composite type");
}
+
}
}
\ No newline at end of file
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -43,6 +43,7 @@
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -51,6 +52,10 @@
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.comm.ConnectionConstants;
@@ -218,6 +223,21 @@
return PluginConstants.ComponentType.VDB.NAME;
}
+ /**
+ * The plugin container will call this method when it has a new
+ * configuration for your managed resource. Your plugin will re-configure
+ * the managed resource in your own custom way, setting its configuration
+ * based on the new values of the given configuration.
+ *
+ * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
+ */
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ // this simulates the plugin taking the new configuration and
+ // reconfiguring the managed resource
+ resourceConfiguration = report.getConfiguration().deepCopy();
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ }
+
@Override
public Configuration loadResourceConfiguration() {
@@ -251,7 +271,15 @@
return configuration;
}
+
+ @Override
+ public CreateResourceReport createResource(
+ CreateResourceReport createResourceReport) {
+ createContentBasedResource(createResourceReport);
+ return createResourceReport;
+ }
+
/**
* @param mcVdb
* @param configuration
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -239,7 +239,7 @@
list.add(map);
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue)
+ for (MetaValue value : ((CollectionValueSupport) pValue)
.getElements()) {
GenericValueSupport genValue = ((GenericValueSupport) value);
ManagedObject mo = (ManagedObject) genValue.getValue();
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertyListAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertyListAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertyListAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,42 @@
+/*
+ * 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.rhq.plugin.adapter.api;
+
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A base class for PropertyList <-> ???MetaValue adapters.
+ *
+ */
+public abstract class AbstractPropertyListAdapter implements PropertyAdapter<PropertyList, PropertyDefinitionList>
+{
+ public PropertyList convertToProperty(MetaValue metaValue, PropertyDefinitionList propDefList)
+ {
+ PropertyList propList = new PropertyList(propDefList.getName());
+ populatePropertyFromMetaValue(propList, metaValue, propDefList);
+ return propList;
+ }
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertyMapAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertyMapAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertyMapAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.rhq.plugin.adapter.api;
+
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A base class for PropertyMap <-> ???MetaValue adapters.
+ *
+ */
+public abstract class AbstractPropertyMapAdapter implements PropertyAdapter<PropertyMap, PropertyDefinitionMap>
+{
+ public PropertyMap convertToProperty(MetaValue metaValue, PropertyDefinitionMap propDefMap)
+ {
+ PropertyMap propMap = new PropertyMap(propDefMap.getName());
+ populatePropertyFromMetaValue(propMap, metaValue, propDefMap);
+ return propMap;
+ }
+}
\ No newline at end of file
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertySimpleAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertySimpleAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/AbstractPropertySimpleAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.rhq.plugin.adapter.api;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A base class for {@link PropertySimple} <-> ???MetaValue adapters.
+ *
+ */
+public abstract class AbstractPropertySimpleAdapter implements PropertyAdapter<PropertySimple, PropertyDefinitionSimple>
+{
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public PropertySimple convertToProperty(MetaValue metaValue, PropertyDefinitionSimple propDefSimple)
+ {
+ PropertySimple propSimple = new PropertySimple(propDefSimple.getName(), null);
+ populatePropertyFromMetaValue(propSimple, metaValue, propDefSimple);
+ return propSimple;
+ }
+
+ public void populateMetaValueFromProperty(PropertySimple propSimple, MetaValue metaValue,
+ PropertyDefinitionSimple propDefSimple)
+ {
+ if (metaValue == null)
+ throw new IllegalArgumentException("MetaValue to be populated is null.");
+ String value;
+ if (propSimple == null || propSimple.getStringValue() == null)
+ {
+ // Value is null (i.e. prop is unset) - figure out what to use as a default value.
+ String defaultValue = propDefSimple.getDefaultValue();
+ if (defaultValue != null)
+ {
+ log.debug("Simple property '" + propDefSimple.getName()
+ + "' has a null value - setting inner value of corresponding ManagedProperty's MetaValue to plugin-specified default ('"
+ + defaultValue + "')...");
+ value = defaultValue;
+ }
+ else
+ {
+ if (metaValue.getMetaType().isPrimitive())
+ // If it's a primitive, don't mess with the MetaValue - just let it keep whatever inner value it
+ // currently has.
+ return;
+ // It's a non-primitive - set its value to null. In most cases, this should tell the managed resource
+ // to use its internal default.
+ log.debug("Simple property '" + propDefSimple.getName()
+ + "' has a null value - setting inner value of corresponding ManagedProperty's MetaValue to null...");
+ value = null;
+ }
+ }
+ else
+ {
+ value = propSimple.getStringValue();
+ }
+ setInnerValue(value, metaValue, propDefSimple);
+ }
+
+ protected abstract void setInnerValue(String propSimpleValue, MetaValue metaValue, PropertyDefinitionSimple propDefSimple);
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/MeasurementAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/MeasurementAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/MeasurementAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,34 @@
+/*
+ * 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.rhq.plugin.adapter.api;
+
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+
+import org.jboss.metatype.api.values.MetaValue;
+
+public interface MeasurementAdapter {
+ public void setMeasurementData(MeasurementReport report, MetaValue metaValue, MeasurementScheduleRequest request,
+ MeasurementDefinition measurementDefinition);
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/MeasurementAdapterFactory.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/MeasurementAdapterFactory.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/MeasurementAdapterFactory.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,99 @@
+/*
+ * 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.rhq.plugin.adapter.api;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.metatype.api.types.MetaType;
+
+public class MeasurementAdapterFactory
+{
+
+ private static final Log LOG = LogFactory.getLog(MeasurementAdapterFactory.class);
+
+ private static Map<String, String> customAdapters = new HashMap<String, String>();
+
+ {
+ // Add customAdapters to the map
+ customAdapters.put("NoClasses", "NoClasses");
+ }
+
+ public static MeasurementAdapter getMeasurementPropertyAdapter(MetaType metaType)
+ {
+ MeasurementAdapter measurementAdapter = null;
+ if (metaType.isSimple())
+ {
+ // measurementAdapter = new SimpleMetaValueMeasurementAdapter();
+ }
+ else if (metaType.isGeneric())
+ {
+ measurementAdapter = null;
+ }
+ else if (metaType.isComposite())
+ {
+ measurementAdapter = null;
+ }
+ else if (metaType.isTable())
+ {
+ measurementAdapter = null;
+ }
+ else if (metaType.isCollection())
+ {
+ measurementAdapter = null;
+ }
+ else if (metaType.isArray())
+ {
+ measurementAdapter = null;
+ }
+
+ return measurementAdapter;
+ }
+
+ public static MeasurementAdapter getCustomMeasurementPropertyAdapter(String measurementName)
+ {
+ MeasurementAdapter measurementAdapter = null;
+ String adapterClassName = customAdapters.get(measurementName);
+ if (adapterClassName != null && !adapterClassName.equals(""))
+ {
+ try
+ {
+ measurementAdapter = (MeasurementAdapter)Class.forName(adapterClassName).newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ LOG.error("Cannot instantiate adapter class called " + adapterClassName, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ LOG.error("Cannot access adapter class called " + adapterClassName, e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ LOG.error("Cannot find adapter class called " + adapterClassName, e);
+ }
+ }
+ return measurementAdapter;
+ }
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,87 @@
+/*
+ * 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.rhq.plugin.adapter.api;
+
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * An adapter that can convert back and forth between a specific type of {@link MetaValue} and a specific type of {@link
+ * Property}.
+ *
+ * @author Mark Spritzler
+ * @author Ian Springer
+ */
+public interface PropertyAdapter<P extends Property, D extends PropertyDefinition>
+{
+ /**
+ * Given a {@link Property} and its {@link PropertyDefinition}, as well as a {@link MetaValue}, populate that
+ * MetaValue so it corresponds to the Property. If the Property is a list or a map, all descendant Property's should
+ * be added as descendants of the MetaValue.
+ *
+ * @param property the property to be copied
+ * @param metaValue the MetaValue to be populated; should not be null
+ * @param propertyDefinition the property's definition
+ */
+ public void populateMetaValueFromProperty(P property, MetaValue metaValue, D propertyDefinition);
+
+ /**
+ * Given a {@link Property} and its {@link PropertyDefinition}, create and return a corresponding {@link MetaValue}
+ * with the specified {@link MetaType}. If the Property is a list or a map, all descendant Property's should be
+ * represented as descendants of the returned MetaValue. Generally this method can simply create an empty MetaValue
+ * object and then delegate the population of the guts of the object to {@link #populateMetaValueFromProperty(Property,
+ * MetaValue, PropertyDefinition)}.
+ *
+ * @param property the property to be converted
+ * @param propertyDefinition the property's definition
+ * @param metaType the type of MetaValue that should be created and returned
+ * @return the MetaValue representation of the given Property
+ */
+ public MetaValue convertToMetaValue(P property, D propertyDefinition, MetaType metaType);
+
+ /**
+ * Given a {@link Property} and its {@link PropertyDefinition}, as well as a {@link MetaValue}, populate the
+ * Property so it corresponds to the MetaValue. If the MetaValue is a from of list or map, all descendant
+ * MetaValue's should be added as descendants of the Property.
+ *
+ * @param property the property to be populated; should not be null
+ * @param metaValue the MetaValue to be copied
+ * @param propertyDefinition the property's definition
+ */
+ public void populatePropertyFromMetaValue(P property, MetaValue metaValue, D propertyDefinition);
+
+ /**
+ * Given a {@link MetaValue}, create and return a corresponding {@link Property} with the specified {@link
+ * PropertyDefinition}. If the MetaValue is a form of list or map, all descendant MetaValue's should be represented
+ * as descendants of the returned Property. Generally this method can simply create an empty Property object and
+ * then delegate the population of the guts of the object to {@link #populatePropertyFromMetaValue(Property,
+ * MetaValue, PropertyDefinition)}.
+ *
+ * @param metaValue the metaValue to be converted
+ * @param propertyDefinition the definition of the property to be created and returned
+ * @return the Property representation of the given MetaValue
+ */
+ public P convertToProperty(MetaValue metaValue, D propertyDefinition);
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapterFactory.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapterFactory.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapterFactory.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,124 @@
+/*
+ * 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.rhq.plugin.adapter.api;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.PropertiesMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.teiid.rhq.plugin.adapter.impl.PropertyListToArrayValueAdapter;
+import org.teiid.rhq.plugin.adapter.impl.PropertyListToCollectionValueAdapter;
+import org.teiid.rhq.plugin.adapter.impl.PropertyMapToCompositeValueSupportAdapter;
+import org.teiid.rhq.plugin.adapter.impl.PropertyMapToGenericValueAdapter;
+import org.teiid.rhq.plugin.adapter.impl.PropertyMapToMapCompositeValueSupportAdapter;
+import org.teiid.rhq.plugin.adapter.impl.PropertyMapToPropertiesValueAdapter;
+import org.teiid.rhq.plugin.adapter.impl.PropertyMapToTableValueAdapter;
+import org.teiid.rhq.plugin.adapter.impl.PropertySimpleToEnumValueAdapter;
+import org.teiid.rhq.plugin.adapter.impl.PropertySimpleToSimpleValueAdapter;
+
+import com.sun.istack.Nullable;
+
+/**
+ * @author Mark Spritzler
+ */
+public class PropertyAdapterFactory
+{
+ private static final Log LOG = LogFactory.getLog(PropertyAdapterFactory.class);
+
+ public static PropertyAdapter getPropertyAdapter(MetaValue metaValue)
+ {
+ if (metaValue == null)
+ {
+ LOG.debug("The MetaValue passed in is null.");
+ return null;
+ }
+ MetaType metaType = metaValue.getMetaType();
+ return getPropertyAdapter(metaType);
+ }
+
+ public static PropertyAdapter getPropertyAdapter(MetaType metaType)
+ {
+ PropertyAdapter propertyAdapter = null;
+ if (metaType.isSimple())
+ {
+ propertyAdapter = new PropertySimpleToSimpleValueAdapter();
+ }
+ else if (metaType.isGeneric())
+ {
+ propertyAdapter = new PropertyMapToGenericValueAdapter();
+ }
+ else if (metaType.isComposite())
+ {
+ if (metaType instanceof MapCompositeMetaType)
+ propertyAdapter = new PropertyMapToMapCompositeValueSupportAdapter();
+ else
+ propertyAdapter = new PropertyMapToCompositeValueSupportAdapter();
+ }
+ else if (metaType.isTable())
+ {
+ propertyAdapter = new PropertyMapToTableValueAdapter();
+ }
+ else if (metaType.isCollection())
+ {
+ propertyAdapter = new PropertyListToCollectionValueAdapter();
+ }
+ else if (metaType.isArray())
+ {
+ propertyAdapter = new PropertyListToArrayValueAdapter();
+ }
+ else if (metaType.isEnum())
+ {
+ propertyAdapter = new PropertySimpleToEnumValueAdapter();
+ }
+ else if (metaType instanceof PropertiesMetaType)
+ {
+ propertyAdapter = new PropertyMapToPropertiesValueAdapter();
+ }
+ else
+ {
+ LOG.warn("Unsupported MetaType: " + metaType);
+ }
+ return propertyAdapter;
+ }
+
+ @Nullable
+ public static PropertyAdapter getCustomPropertyAdapter(PropertySimple customProp)
+ {
+ if (customProp == null)
+ return null;
+ String adapterClassName = customProp.getStringValue();
+ PropertyAdapter propertyAdapter = null;
+ try
+ {
+ Class adapterClass = Class.forName(adapterClassName);
+ propertyAdapter = (PropertyAdapter)adapterClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ LOG.error("Unable to create custom adapter class for " + customProp + ".", e);
+ }
+ return propertyAdapter;
+ }
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/AbstractPropertyMapToCompositeValueAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/AbstractPropertyMapToCompositeValueAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/AbstractPropertyMapToCompositeValueAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,119 @@
+/*
+ * 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.rhq.plugin.adapter.impl;
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.teiid.rhq.plugin.adapter.api.AbstractPropertyMapAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * This class provides code that maps back and forth between a {@link PropertyMap} and a {@link CompositeValue}.
+ * Subclasses exist for the two different implementations of <code>CompositeValue</code>.
+ *
+ */
+public abstract class AbstractPropertyMapToCompositeValueAdapter extends AbstractPropertyMapAdapter
+ implements PropertyAdapter<PropertyMap, PropertyDefinitionMap>
+{
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public void populateMetaValueFromProperty(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
+ {
+ CompositeValue compositeValue = (CompositeValue)metaValue;
+ for (String mapMemberPropName : propMap.getMap().keySet())
+ {
+ Property mapMemberProp = propMap.get(mapMemberPropName);
+ PropertyDefinition mapMemberPropDef = propDefMap.get(mapMemberPropName);
+ MetaType mapMemberMetaType = compositeValue.getMetaType().getType(mapMemberPropName);
+ if (mapMemberMetaType == null)
+ {
+ // this will occur when new map properties are added since they are not present
+ // in the original metaValue which we are using
+ mapMemberMetaType = SimpleMetaType.STRING;
+ }
+ PropertyAdapter adapter = PropertyAdapterFactory.getPropertyAdapter(mapMemberMetaType);
+ MetaValue mapMemberMetaValue = adapter.convertToMetaValue(mapMemberProp, mapMemberPropDef, mapMemberMetaType);
+ putValue(compositeValue, mapMemberPropName, mapMemberMetaValue);
+ }
+ }
+
+ public MetaValue convertToMetaValue(PropertyMap propMap, PropertyDefinitionMap propDefMap, MetaType metaType)
+ {
+ CompositeValue compositeValue = createCompositeValue(propDefMap, metaType);
+ populateMetaValueFromProperty(propMap, compositeValue, propDefMap);
+ return compositeValue;
+ }
+
+ public void populatePropertyFromMetaValue(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
+ {
+ if (metaValue == null)
+ return;
+ CompositeValue compositeValue = (CompositeValue)metaValue;
+ Set<String> mapMemberPropNames = compositeValue.getMetaType().keySet();
+ // There won't be any keys when loading a Configuration for the first time.
+ for (String mapMemberPropName : mapMemberPropNames)
+ {
+ Property mapMemberProp = propMap.get(mapMemberPropName);
+ MetaValue mapMemberMetaValue = compositeValue.get(mapMemberPropName);
+ MetaType mapMemberMetaType = compositeValue.getMetaType().getType(mapMemberPropName);
+ PropertyAdapter propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(mapMemberMetaType);
+ PropertyDefinition mapMemberPropDef = propDefMap.get(mapMemberPropName);
+ if (mapMemberProp == null)
+ {
+ if (mapMemberPropDef != null)
+ mapMemberProp = propertyAdapter.convertToProperty(mapMemberMetaValue, mapMemberPropDef);
+ else
+ {
+ // If the member prop has no associated prop def, this is an "open map".
+ if (!mapMemberMetaType.isSimple() && !mapMemberMetaType.isEnum())
+ {
+ log.debug("Map member prop [" + mapMemberMetaType + "] is not a simple type - skipping...");
+ continue;
+ }
+ // Create a PropertySimple and populate it.
+ mapMemberProp = new PropertySimple(mapMemberPropName, null);
+ // NOTE: It's ok that the propDef is null - PropertySimple*Adapter.populatePropertyFromMetaValue()
+ // doesn't use it for anything.
+ propertyAdapter.populatePropertyFromMetaValue(mapMemberProp, mapMemberMetaValue, mapMemberPropDef);
+ }
+ propMap.put(mapMemberProp);
+ }
+ }
+ }
+
+ protected abstract void putValue(CompositeValue compositeValue, String key, MetaValue value);
+
+ protected abstract CompositeValue createCompositeValue(PropertyDefinitionMap propDefMap, MetaType metaType);
+}
\ No newline at end of file
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToArrayValueAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToArrayValueAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToArrayValueAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,93 @@
+/*
+ * 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.rhq.plugin.adapter.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.teiid.rhq.plugin.adapter.api.AbstractPropertyListAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.ArrayValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+
+/**
+ *
+ */
+public class PropertyListToArrayValueAdapter extends AbstractPropertyListAdapter implements PropertyAdapter<PropertyList, PropertyDefinitionList>
+{
+ //@todo need to implement this like the other List to Collection, but not until there is an actual property that needs this
+ public void populateMetaValueFromProperty(PropertyList property, MetaValue metaValue, PropertyDefinitionList propertyDefinition)
+ {
+ PropertyDefinition memberDefinition = propertyDefinition.getMemberDefinition();
+ List<Property> properties = property.getList();
+ if (metaValue != null)
+ {
+ ArrayValueSupport valueSupport = (ArrayValueSupport)metaValue;
+ MetaType listMetaType = valueSupport.getMetaType().getElementType();
+ List<MetaValue> values = new ArrayList<MetaValue>(properties.size());
+ for (Property propertyWithinList : properties)
+ {
+ MetaValue value = MetaValueFactory.getInstance().create(null);
+ PropertyAdapter<Property, PropertyDefinition> propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(listMetaType);
+ propertyAdapter.populateMetaValueFromProperty(propertyWithinList, value, memberDefinition);
+ values.add(value);
+ }
+ valueSupport.setValue(values.toArray());
+ }
+ }
+
+ //@todo need to implement this like the other List to Collection, but not until there is an actual property that needs this
+ public MetaValue convertToMetaValue(PropertyList property, PropertyDefinitionList propertyDefinition, MetaType type)
+ {
+ return null;
+ }
+
+ public void populatePropertyFromMetaValue(PropertyList property, MetaValue metaValue, PropertyDefinitionList propertyDefinition)
+ {
+ PropertyDefinition memberDefinition = propertyDefinition.getMemberDefinition();
+ List<Property> properties = property.getList();
+
+ // Since we want to load the PropertyList with fresh values, we want it cleared out
+ properties.clear();
+
+ if (metaValue != null)
+ {
+ ArrayValueSupport valueSupport = (ArrayValueSupport)metaValue;
+ MetaType listMetaType = valueSupport.getMetaType().getElementType();
+ MetaValue[] metaValues = (MetaValue[])valueSupport.getValue();
+ PropertyAdapter propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(listMetaType);
+ for (MetaValue value : metaValues)
+ {
+ Property propertyToAddToList = propertyAdapter.convertToProperty(value, memberDefinition);
+ properties.add(propertyToAddToList);
+ }
+ }
+ }
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToCollectionValueAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToCollectionValueAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToCollectionValueAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,98 @@
+/*
+ * 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.rhq.plugin.adapter.impl;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.teiid.rhq.plugin.adapter.api.AbstractPropertyListAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
+
+/**
+ *
+ */
+public class PropertyListToCollectionValueAdapter extends AbstractPropertyListAdapter implements PropertyAdapter<PropertyList, PropertyDefinitionList>
+{
+ private static final Log LOG = LogFactory.getLog(PropertyListToCollectionValueAdapter.class);
+
+ public void populateMetaValueFromProperty(PropertyList property, MetaValue metaValue, PropertyDefinitionList propertyDefinition)
+ {
+ PropertyDefinition listMemberPropDef = propertyDefinition.getMemberDefinition();
+ List<Property> listMemberProps = property.getList();
+ CollectionValueSupport collectionValue = (CollectionValueSupport)metaValue;
+ MetaType listMemberMetaType = collectionValue.getMetaType().getElementType();
+ MetaValue[] listMemberValues = new MetaValue[listMemberProps.size()];
+ PropertyAdapter propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(listMemberMetaType);
+ int memberIndex = 0;
+ for (Property listMemberProp : listMemberProps)
+ {
+ MetaValue listMemberValue = propertyAdapter.convertToMetaValue(listMemberProp, listMemberPropDef, listMemberMetaType);
+ listMemberValues[memberIndex++] = listMemberValue;
+ }
+ // Replace the existing elements with the new ones.
+ collectionValue.setElements(listMemberValues);
+ }
+
+ public MetaValue convertToMetaValue(PropertyList propertyList, PropertyDefinitionList propertyListDefinition, MetaType metaType)
+ {
+ LOG.debug("GetMetaValue for property: " + propertyList.getName() + " values: " + propertyList.getList().toString());
+ CollectionMetaType collectionMetaType = (CollectionMetaType)metaType;
+ MetaType memberMetaType = collectionMetaType.getElementType();
+ CollectionMetaType collectionType = new CollectionMetaType(propertyListDefinition.getName(), memberMetaType);
+ CollectionValue collectionValue = new CollectionValueSupport(collectionType);
+ populateMetaValueFromProperty(propertyList, collectionValue, propertyListDefinition);
+ return collectionValue;
+ }
+
+ public void populatePropertyFromMetaValue(PropertyList propList, MetaValue metaValue, PropertyDefinitionList propDefList)
+ {
+ PropertyDefinition memberPropDef = propDefList.getMemberDefinition();
+ if (propList != null)
+ {
+ // Since we want to load the PropertyList with fresh values, we want it cleared out.
+ propList.getList().clear();
+ if (metaValue != null)
+ {
+ CollectionValue collectionValue = (CollectionValue)metaValue;
+ MetaType listMemberMetaType = collectionValue.getMetaType().getElementType();
+ MetaValue[] listMemberValues = collectionValue.getElements();
+ PropertyAdapter propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(listMemberMetaType);
+ for (MetaValue listMemberValue : listMemberValues)
+ {
+ Property listMemberProp = propertyAdapter.convertToProperty(listMemberValue, memberPropDef);
+ propList.add(listMemberProp);
+ }
+ }
+ }
+ }
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.rhq.plugin.adapter.impl;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
+
+/**
+ * This class provides code that maps back and forth between a {@link PropertyMap} and a {@link CompositeValueSupport}.
+ * A <code>CompositeValueSupport</code> is a {@link CompositeValue} implementation that contains items that may be of
+ * different types.
+ *
+ */
+public class PropertyMapToCompositeValueSupportAdapter extends AbstractPropertyMapToCompositeValueAdapter
+ implements PropertyAdapter<PropertyMap, PropertyDefinitionMap>
+{
+ protected void putValue(CompositeValue compositeValue, String key, MetaValue value)
+ {
+ CompositeValueSupport compositeValueSupport = (CompositeValueSupport)compositeValue;
+ compositeValueSupport.set(key, value);
+ }
+
+ protected CompositeValue createCompositeValue(PropertyDefinitionMap propDefMap, MetaType metaType)
+ {
+ MutableCompositeMetaType compositeMetaType;
+ if (metaType != null)
+ compositeMetaType = (MutableCompositeMetaType)metaType;
+ else
+ {
+ // TODO: See if this else block is actually necessary (I think it is needed for creates).
+ String name = (propDefMap != null) ?
+ propDefMap.getName() : "CompositeMetaType";
+ String desc = (propDefMap != null && propDefMap.getDescription() != null) ?
+ propDefMap.getDescription() : "none";
+ compositeMetaType = new MutableCompositeMetaType(name, desc);
+ if (propDefMap != null)
+ {
+ for (PropertyDefinition mapMemberPropDef : propDefMap.getPropertyDefinitions().values())
+ {
+ String mapMemberDesc = (propDefMap.getDescription() != null) ? propDefMap.getDescription() : "none";
+ MetaType mapMemberMetaType = ProfileServiceUtil.convertPropertyDefinitionToMetaType(mapMemberPropDef);
+ compositeMetaType.addItem(mapMemberPropDef.getName(), mapMemberDesc, mapMemberMetaType);
+ }
+ }
+ }
+ return new CompositeValueSupport(compositeMetaType);
+ }
+}
\ No newline at end of file
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.rhq.plugin.adapter.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.teiid.rhq.plugin.adapter.api.AbstractPropertyMapAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
+
+/**
+ * This class provides code that maps back and forth between a {@link PropertyMap} and a {@link GenericValue}. The
+ * GenericValue's value is assumed to be a {@link ManagedObject}.
+ *
+ */
+public class PropertyMapToGenericValueAdapter extends AbstractPropertyMapAdapter
+ implements PropertyAdapter<PropertyMap, PropertyDefinitionMap>
+{
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public void populateMetaValueFromProperty(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
+ {
+ GenericValue genericValue = (GenericValue)metaValue;
+ if (!(genericValue.getValue() instanceof ManagedObject))
+ {
+ log.error("GenericValue's value [" + genericValue.getValue() + "] is not a ManagedObject - not supported!");
+ return;
+ }
+ ManagedObject managedObject = (ManagedObject)genericValue.getValue();
+ for (String propName : propMap.getMap().keySet())
+ {
+ Property mapMemberProp = propMap.get(propName);
+ ManagedProperty managedProp = managedObject.getProperty(propName);
+ MetaType metaType = managedProp.getMetaType();
+ PropertyAdapter propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(metaType);
+ PropertyDefinition mapMemberPropDef = propDefMap.get(propName);
+ if (managedProp.getValue() == null)
+ {
+ MetaValue managedPropMetaValue = propertyAdapter.convertToMetaValue(mapMemberProp, mapMemberPropDef, metaType);
+ managedProp.setValue(managedPropMetaValue);
+ }
+ else
+ {
+ MetaValue managedPropMetaValue = (MetaValue)managedProp.getValue();
+ propertyAdapter.populateMetaValueFromProperty(mapMemberProp, managedPropMetaValue, mapMemberPropDef);
+ }
+ }
+ }
+
+ public MetaValue convertToMetaValue(PropertyMap propMap, PropertyDefinitionMap propDefMap, MetaType metaType)
+ {
+ //GenericMetaType genericMetaType = (GenericMetaType)metaType;
+ ManagedObjectImpl managedObject = new ManagedObjectImpl(propDefMap.getName());
+ for (PropertyDefinition mapMemberPropDef : propDefMap.getPropertyDefinitions().values())
+ {
+ ManagedPropertyImpl managedProp = new ManagedPropertyImpl(mapMemberPropDef.getName());
+ MetaType managedPropMetaType = ProfileServiceUtil.convertPropertyDefinitionToMetaType(mapMemberPropDef);
+ managedProp.setMetaType(managedPropMetaType);
+ managedProp.setManagedObject(managedObject);
+ managedObject.getProperties().put(managedProp.getName(), managedProp);
+ }
+ GenericValue genericValue = new GenericValueSupport(new GenericMetaType(propDefMap.getName(),
+ propDefMap.getDescription()), managedObject);
+ populateMetaValueFromProperty(propMap, genericValue, propDefMap);
+ return genericValue;
+ }
+
+ public void populatePropertyFromMetaValue(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
+ {
+ GenericValue genericValue = (GenericValue)metaValue;
+ ManagedObject managedObject = (ManagedObject)genericValue.getValue();
+ for (String propName : propDefMap.getPropertyDefinitions().keySet())
+ {
+ ManagedProperty managedProp = managedObject.getProperty(propName);
+ if (managedProp != null)
+ {
+ MetaType metaType = managedProp.getMetaType();
+ Object value;
+ if (metaType.isSimple())
+ {
+ SimpleValue simpleValue = (SimpleValue)managedProp.getValue();
+ value = simpleValue.getValue();
+ }
+ else if (metaType.isEnum())
+ {
+ EnumValue enumValue = (EnumValue)managedProp.getValue();
+ value = enumValue.getValue();
+ }
+ else
+ {
+ log.error("Nested ManagedProperty's value [" + managedProp.getValue()
+ + "] is not a SimpleValue or EnumValue - unsupported!");
+ continue;
+ }
+ propMap.put(new PropertySimple(propName, value));
+ }
+ }
+ }
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToMapCompositeValueSupportAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToMapCompositeValueSupportAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToMapCompositeValueSupportAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,68 @@
+/*
+ * 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.rhq.plugin.adapter.impl;
+
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * This class provides code that maps back and forth between a {@link PropertyMap} and a {@link
+ * MapCompositeValueSupport}. A <code>MapCompositeValueSupport</code> is a {@link CompositeValue} implementation that
+ * contains items that are all of the same type; there is no predefined list of valid keys, so it maps nicely to an
+ * "open" PropertyMap.
+ *
+ */
+public class PropertyMapToMapCompositeValueSupportAdapter extends AbstractPropertyMapToCompositeValueAdapter implements PropertyAdapter<PropertyMap, PropertyDefinitionMap>
+{
+ @Override
+ public void populateMetaValueFromProperty(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
+ {
+ MapCompositeValueSupport mapCompositeValueSupport = (MapCompositeValueSupport)metaValue;
+ // First clear out all existing values from the MapCompositeValue.
+ for (String key : mapCompositeValueSupport.getMetaType().keySet())
+ {
+ mapCompositeValueSupport.remove(key);
+ }
+ // Now re-populate it with the values from the PropertyMap.
+ super.populateMetaValueFromProperty(propMap, metaValue, propDefMap);
+ }
+
+ protected void putValue(CompositeValue compositeValue, String key, MetaValue value)
+ {
+ MapCompositeValueSupport mapCompositeValueSupport = (MapCompositeValueSupport)compositeValue;
+ mapCompositeValueSupport.put(key, value);
+ }
+
+ protected CompositeValue createCompositeValue(PropertyDefinitionMap propDefMap, MetaType metaType)
+ {
+ MapCompositeMetaType mapCompositeMetaType = (MapCompositeMetaType)metaType;
+ MetaType mapMemberMetaType = mapCompositeMetaType.getValueType();
+ return new MapCompositeValueSupport(mapMemberMetaType);
+ }
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToPropertiesValueAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToPropertiesValueAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToPropertiesValueAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.rhq.plugin.adapter.impl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.teiid.rhq.plugin.adapter.api.AbstractPropertyMapAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+
+/**
+ * This class provides code that maps back and forth between a {@link PropertyMap} and a {@link PropertiesMetaValue}. A
+ * <code>PropertiesMetaValue</code> extends java.util.Properties. Its associated PropertiesMetaType may or may not
+ * define member property names; since the RHQ Configuration system assumes a PropertyDefinitionMap either defines none
+ * of its member properties (i.e. an "open map") or defines all of them, we just ignore the PropertiesMetaType and
+ * always map to an open map.
+ *
+ */
+public class PropertyMapToPropertiesValueAdapter extends AbstractPropertyMapAdapter
+ implements PropertyAdapter<PropertyMap, PropertyDefinitionMap>
+{
+ public void populateMetaValueFromProperty(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
+ {
+ PropertiesMetaValue propertiesValue = (PropertiesMetaValue)metaValue;
+ for (String mapMemberPropName : propMap.getMap().keySet())
+ {
+ Property mapMemberProp = propMap.get(mapMemberPropName);
+ propertiesValue.setProperty(mapMemberProp.getName(), ((PropertySimple)mapMemberProp).getStringValue());
+ }
+ }
+
+ public MetaValue convertToMetaValue(PropertyMap propMap, PropertyDefinitionMap propDefMap, MetaType metaType)
+ {
+ PropertiesMetaValue propertiesValue = new PropertiesMetaValue();
+ populateMetaValueFromProperty(propMap, propertiesValue, propDefMap);
+ return propertiesValue;
+ }
+
+ public void populatePropertyFromMetaValue(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
+ {
+ if (metaValue == null)
+ return;
+ PropertiesMetaValue propertiesValue = (PropertiesMetaValue)metaValue;
+ Set<String> mapMemberPropNames = new HashSet();
+ for (Object key : propertiesValue.keySet())
+ mapMemberPropNames.add((String)key);
+ // There won't be any keys when loading a Configuration for the first time.
+ for (String mapMemberPropName : mapMemberPropNames)
+ {
+ // We assume the PropertyMap is an "open map", since that's what PropertiesMetaValue maps to.
+ PropertySimple mapMemberProp = propMap.getSimple(mapMemberPropName);
+ // Create a PropertySimple and populate it.
+ if (mapMemberProp == null)
+ {
+ mapMemberProp = new PropertySimple(mapMemberPropName, propertiesValue.getProperty(mapMemberPropName));
+ propMap.put(mapMemberProp);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,92 @@
+/*
+ * 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.rhq.plugin.adapter.impl;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.api.values.TableValueSupport;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.teiid.rhq.plugin.adapter.api.AbstractPropertyMapAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
+
+/**
+ *
+ */
+public class PropertyMapToTableValueAdapter extends AbstractPropertyMapAdapter implements PropertyAdapter<PropertyMap, PropertyDefinitionMap>
+{
+ public PropertyMap convertToProperty(MetaValue metaValue, PropertyDefinitionMap propertyDefinition)
+ {
+ PropertyMap property = new PropertyMap();
+ populatePropertyFromMetaValue(property, metaValue, propertyDefinition);
+ return property;
+ }
+
+ //@todo need to implement this like the other Map to Composite, but not until there is an actual property that needs this
+ public void populateMetaValueFromProperty(PropertyMap property, MetaValue metaValue, PropertyDefinitionMap propertyDefinition)
+ {
+ if (metaValue != null)
+ {
+ TableValueSupport tableValueSupport = (TableValueSupport)metaValue;
+ Map<String, PropertyDefinition> map = propertyDefinition.getPropertyDefinitions();
+ Map<String, Property> properties = property.getMap();
+ for (String key : map.keySet())
+ {
+ PropertyDefinition definition = map.get(key);
+ MetaValue[] getKey = new MetaValue[]{SimpleValueSupport.wrap(key)};
+ MetaValue value = tableValueSupport.get(getKey);
+ Property innerProperty = properties.get(key);
+ PropertyAdapter adapter = PropertyAdapterFactory.getPropertyAdapter(value);
+ adapter.populateMetaValueFromProperty(innerProperty, value, definition);
+ }
+ }
+ }
+
+ //@todo need to implement this like the other Map to Composite, but not until there is an actual property that needs this
+ public MetaValue convertToMetaValue(PropertyMap property, PropertyDefinitionMap propertyDefinition, MetaType type)
+ {
+ return null;
+ }
+
+ public void populatePropertyFromMetaValue(PropertyMap property, MetaValue metaValue, PropertyDefinitionMap propertyDefinition)
+ {
+ // Not important at this moment to implement as there sin't a need for this mapping yet.
+ if (metaValue != null)
+ {
+ TableValueSupport valueSupport = (TableValueSupport)metaValue;
+ Collection<CompositeValue> values = valueSupport.values();
+ for (CompositeValue value : values)
+ {
+ CompositeValueSupport support = (CompositeValueSupport)value;
+ }
+ }
+ }
+}
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertySimpleToEnumValueAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertySimpleToEnumValueAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertySimpleToEnumValueAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.rhq.plugin.adapter.impl;
+
+import org.jboss.metatype.api.types.EnumMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.EnumValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.teiid.rhq.plugin.adapter.api.AbstractPropertySimpleAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+
+/**
+ * This class provides code that maps back and forth between a {@link PropertySimple} and an {@link EnumValueSupport}.
+ *
+ */
+public class PropertySimpleToEnumValueAdapter extends AbstractPropertySimpleAdapter implements PropertyAdapter<PropertySimple, PropertyDefinitionSimple>
+{
+ public void populatePropertyFromMetaValue(PropertySimple propSimple, MetaValue metaValue, PropertyDefinitionSimple propDefSimple)
+ {
+ Object value = (metaValue != null) ? ((EnumValue)metaValue).getValue() : null;
+ propSimple.setValue(value);
+ }
+
+ public MetaValue convertToMetaValue(PropertySimple propSimple, PropertyDefinitionSimple propDefSimple, MetaType metaType)
+ {
+ EnumValue enumValue = new EnumValueSupport((EnumMetaType)metaType, propSimple.getStringValue());
+ populateMetaValueFromProperty(propSimple, enumValue, propDefSimple);
+ return enumValue;
+ }
+
+ protected void setInnerValue(String propSimpleValue, MetaValue metaValue, PropertyDefinitionSimple propDefSimple)
+ {
+ EnumValueSupport enumValueSupport = (EnumValueSupport)metaValue;
+ enumValueSupport.setValue(propSimpleValue);
+ }
+}
\ No newline at end of file
Added: trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertySimpleToSimpleValueAdapter.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertySimpleToSimpleValueAdapter.java (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertySimpleToSimpleValueAdapter.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -0,0 +1,94 @@
+/*
+ * 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.rhq.plugin.adapter.impl;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.teiid.rhq.plugin.adapter.api.AbstractPropertySimpleAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+
+/**
+ * This class provides code that maps back and forth between a {@link PropertySimple} and a {@link SimpleValueSupport}.
+ *
+ */
+public class PropertySimpleToSimpleValueAdapter extends AbstractPropertySimpleAdapter implements PropertyAdapter<PropertySimple, PropertyDefinitionSimple>
+{
+ public void populatePropertyFromMetaValue(PropertySimple propSimple, MetaValue metaValue, PropertyDefinitionSimple propDefSimple)
+ {
+ Object value = (metaValue != null) ? ((SimpleValue)metaValue).getValue() : null;
+ propSimple.setValue(value);
+ }
+
+ public MetaValue convertToMetaValue(PropertySimple propSimple, PropertyDefinitionSimple propDefSimple, MetaType metaType)
+ {
+ SimpleValue simpleValue = new SimpleValueSupport((SimpleMetaType)metaType, null);
+ populateMetaValueFromProperty(propSimple, simpleValue, propDefSimple);
+ return simpleValue;
+ }
+
+ protected void setInnerValue(String propSimpleValue, MetaValue metaValue, PropertyDefinitionSimple propDefSimple)
+ {
+ SimpleValueSupport simpleValueSupport = (SimpleValueSupport)metaValue;
+ if (propSimpleValue == null)
+ {
+ // A null value is the easiest case - just set the SimpleMetaValue's inner value to null.
+ simpleValueSupport.setValue(null);
+ return;
+ }
+ // String value is non-null, so we can massage it into the proper type for the SimpleMetaValue's inner value.
+ SimpleMetaType simpleMetaType = simpleValueSupport.getMetaType();
+ Serializable innerValue;
+ if (simpleMetaType.equals(SimpleMetaType.STRING) || simpleMetaType.equals(SimpleMetaType.NAMEDOBJECT))
+ innerValue = propSimpleValue;
+ else if (simpleMetaType.equals(SimpleMetaType.BOOLEAN) || simpleMetaType.equals(SimpleMetaType.BOOLEAN_PRIMITIVE))
+ innerValue = Boolean.valueOf(propSimpleValue);
+ else if (simpleMetaType.equals(SimpleMetaType.BYTE) || simpleMetaType.equals(SimpleMetaType.BYTE_PRIMITIVE))
+ innerValue = Byte.valueOf(propSimpleValue);
+ else if (simpleMetaType.equals(SimpleMetaType.CHARACTER) || simpleMetaType.equals(SimpleMetaType.CHARACTER_PRIMITIVE))
+ {
+ if (propSimpleValue.length() != 1)
+ throw new IllegalStateException("String value '" + propSimpleValue + " cannot be converted to a character.");
+ innerValue = propSimpleValue.charAt(0);
+ }
+ else if (simpleMetaType.equals(SimpleMetaType.DOUBLE) || simpleMetaType.equals(SimpleMetaType.DOUBLE_PRIMITIVE))
+ innerValue = Double.valueOf(propSimpleValue);
+ else if (simpleMetaType.equals(SimpleMetaType.FLOAT) || simpleMetaType.equals(SimpleMetaType.FLOAT_PRIMITIVE))
+ innerValue = Float.valueOf(propSimpleValue);
+ else if (simpleMetaType.equals(SimpleMetaType.INTEGER) || simpleMetaType.equals(SimpleMetaType.INTEGER_PRIMITIVE))
+ innerValue = Integer.valueOf(propSimpleValue);
+ else if (simpleMetaType.equals(SimpleMetaType.LONG) || simpleMetaType.equals(SimpleMetaType.LONG_PRIMITIVE))
+ innerValue = Long.valueOf(propSimpleValue);
+ else if (simpleMetaType.equals(SimpleMetaType.SHORT) || simpleMetaType.equals(SimpleMetaType.SHORT_PRIMITIVE))
+ innerValue = Short.valueOf(propSimpleValue);
+ else
+ throw new IllegalStateException("Unsupported MetaType: " + simpleMetaType);
+ simpleValueSupport.setValue(innerValue);
+ }
+}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-05-19 23:20:03 UTC (rev 2145)
@@ -1,8 +1,36 @@
+/*
+ * 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.rhq.plugin.util;
import java.io.File;
+import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Set;
import javax.naming.InitialContext;
@@ -17,21 +45,104 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.EnumValue;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.profileservice.spi.ProfileService;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.core.domain.resource.ResourceType;
+import org.teiid.rhq.plugin.TranslatorComponent;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
+import com.sun.istack.NotNull;
+import com.sun.istack.Nullable;
public class ProfileServiceUtil {
- protected final Log LOG = LogFactory.getLog(ProfileServiceUtil.class);
+ protected final static Log LOG = LogFactory
+ .getLog(ProfileServiceUtil.class);
private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp");
private static String DQPNAME = "org.teiid.jboss.deployers.RuntimeEngineDeployer";
+ private static final Map<String, ComponentType> COMPONENT_TYPE_CACHE = new HashMap<String, ComponentType>();
+ private static final Map<String, KnownDeploymentTypes> DEPLOYMENT_TYPE_CACHE = new HashMap<String, KnownDeploymentTypes>();
+ private static final Map<String, Configuration> DEFAULT_PLUGIN_CONFIG_CACHE = new HashMap<String, Configuration>();
+ protected static final String PLUGIN = "ProfileService";
+
+ public static ComponentType getComponentType(
+ @NotNull ResourceType resourceType) {
+ String resourceTypeName = resourceType.getName();
+ if (COMPONENT_TYPE_CACHE.containsKey(resourceTypeName))
+ return COMPONENT_TYPE_CACHE.get(resourceTypeName);
+ Configuration defaultPluginConfig = getDefaultPluginConfiguration(resourceType);
+ String type = defaultPluginConfig.getSimpleValue(
+ TranslatorComponent.Config.COMPONENT_TYPE, null);
+ if (type == null || type.equals(""))
+ throw new IllegalStateException(
+ "Required plugin configuration property '"
+ + TranslatorComponent.Config.COMPONENT_TYPE
+ + "' is not defined in default template.");
+ String subtype = defaultPluginConfig.getSimpleValue(
+ TranslatorComponent.Config.COMPONENT_SUBTYPE, null);
+ if (subtype == null || subtype.equals(""))
+ throw new IllegalStateException(
+ "Required plugin configuration property '"
+ + TranslatorComponent.Config.COMPONENT_SUBTYPE
+ + "' is not defined in default template.");
+ ComponentType componentType = new ComponentType(type, subtype);
+ COMPONENT_TYPE_CACHE.put(resourceTypeName, componentType);
+ return componentType;
+ }
+
+ private static Configuration getDefaultPluginConfiguration(
+ ResourceType resourceType) {
+ ConfigurationTemplate pluginConfigDefaultTemplate = resourceType
+ .getPluginConfigurationDefinition().getDefaultTemplate();
+ return (pluginConfigDefaultTemplate != null) ? pluginConfigDefaultTemplate
+ .createConfiguration()
+ : new Configuration();
+ }
+
/**
+ * @param name
+ * @param componentType
+ * @return
+ */
+ public static boolean isManagedComponent(ManagementView managementView,
+ String name, ComponentType componentType) {
+ boolean isDeployed = false;
+ if (name != null) {
+ try {
+ ManagedComponent component = getManagedComponent(componentType,
+ name);
+ if (component != null)
+ isDeployed = true;
+ } catch (Exception e) {
+ // Setting it to true to be safe than sorry, since there might
+ // be a component
+ // already deployed in the AS.
+ isDeployed = true;
+ }
+ }
+ return isDeployed;
+ }
+
+ /**
* Get the passed in {@link ManagedComponent}
*
* @return {@link ManagedComponent}
@@ -45,7 +156,7 @@
ManagementView mv = getManagementView(ps, true);
ManagedComponent mc = mv.getComponent(componentName, componentType);
-
+
return mc;
}
@@ -54,7 +165,8 @@
* type.
*
* @return Set of {@link ManagedComponent}s
- * @throws NamingException, Exception
+ * @throws NamingException
+ * , Exception
* @throws Exception
*/
public static Set<ManagedComponent> getManagedComponents(
@@ -71,7 +183,8 @@
* @param {@link ManagementView}
* @return
*/
- public static ManagementView getManagementView(ProfileService ps, boolean load) {
+ public static ManagementView getManagementView(ProfileService ps,
+ boolean load) {
ManagementView mv = ps.getViewManager();
if (load) {
mv.load();
@@ -96,7 +209,8 @@
/**
* @return {@link ProfileService}
- * @throws NamingException, Exception
+ * @throws NamingException
+ * , Exception
*/
public static ProfileService getProfileService() throws NamingException {
InitialContext ic = new InitialContext();
@@ -107,7 +221,8 @@
/**
* @return {@link File}
- * @throws NamingException, Exception
+ * @throws NamingException
+ * , Exception
*/
public static File getDeployDirectory() throws NamingException, Exception {
ProfileService ps = getProfileService();
@@ -141,51 +256,280 @@
File deployDir = warFile.getParentFile();
return deployDir;
}
-
- public static ManagedComponent getDQPManagementView() throws NamingException, Exception {
-
+
+ public static ManagedComponent getDQPManagementView()
+ throws NamingException, Exception {
+
return getManagedComponent(DQPTYPE, DQPNAME);
}
-
+
public static String stringValue(MetaValue v1) throws Exception {
if (v1 != null) {
MetaType type = v1.getMetaType();
if (type instanceof SimpleMetaType) {
- SimpleValue simple = (SimpleValue)v1;
+ SimpleValue simple = (SimpleValue) v1;
return simple.getValue().toString();
}
throw new Exception("Failed to convert value to string value");
}
return null;
- }
-
+ }
+
public static Boolean booleanValue(MetaValue v1) throws Exception {
if (v1 != null) {
MetaType type = v1.getMetaType();
if (type instanceof SimpleMetaType) {
- SimpleValue simple = (SimpleValue)v1;
+ SimpleValue simple = (SimpleValue) v1;
return Boolean.valueOf(simple.getValue().toString());
}
throw new Exception("Failed to convert value to boolean value");
}
return null;
- }
+ }
+
+ public static <T> T getSimpleValue(ManagedComponent mc, String prop,
+ Class<T> expectedType) {
+ ManagedProperty mp = mc.getProperty(prop);
+ if (mp != null) {
+ MetaType metaType = mp.getMetaType();
+ if (metaType.isSimple()) {
+ SimpleValue simpleValue = (SimpleValue) mp.getValue();
+ return expectedType.cast((simpleValue != null) ? simpleValue
+ .getValue() : null);
+ } else if (metaType.isEnum()) {
+ EnumValue enumValue = (EnumValue) mp.getValue();
+ return expectedType.cast((enumValue != null) ? enumValue
+ .getValue() : null);
+ }
+ throw new IllegalStateException(prop + " is not a simple type");
+ }
+ return null;
+ }
+
+ public static Map<String, PropertySimple> getCustomProperties(
+ Configuration pluginConfig) {
+ Map<String, PropertySimple> customProperties = new LinkedHashMap<String, PropertySimple>();
+ if (pluginConfig == null)
+ return customProperties;
+ PropertyMap customPropsMap = pluginConfig.getMap("custom-properties");
+ if (customPropsMap != null) {
+ Collection<Property> customProps = customPropsMap.getMap().values();
+ for (Property customProp : customProps) {
+ if (!(customProp instanceof PropertySimple)) {
+ LOG
+ .error("Custom property definitions in plugin configuration must be simple properties - property "
+ + customProp + " is not - ignoring...");
+ continue;
+ }
+ customProperties.put(customProp.getName(),
+ (PropertySimple) customProp);
+ }
+ }
+ return customProperties;
+ }
+
+ public static Configuration convertManagedObjectToConfiguration(
+ Map<String, ManagedProperty> managedProperties,
+ Map<String, PropertySimple> customProps, ResourceType resourceType) {
+ Configuration config = new Configuration();
+ ConfigurationDefinition configDef = resourceType
+ .getResourceConfigurationDefinition();
+ Map<String, PropertyDefinition> propDefs = configDef
+ .getPropertyDefinitions();
+ Set<String> propNames = managedProperties.keySet();
+ for (String propName : propNames) {
+ PropertyDefinition propertyDefinition = propDefs.get(propName);
+ ManagedProperty managedProperty = managedProperties.get(propName);
+ if (propertyDefinition == null) {
+ if (!managedProperty.hasViewUse(ViewUse.STATISTIC))
+ LOG
+ .debug(resourceType
+ + " does not define a property corresponding to ManagedProperty '"
+ + propName + "'.");
+ continue;
+ }
+ if (managedProperty == null) {
+ // This should never happen, but don't let it blow us up.
+ LOG.error("ManagedProperty '" + propName
+ + "' has a null value in the ManagedProperties Map.");
+ continue;
+ }
+ MetaValue metaValue = managedProperty.getValue();
+ if (managedProperty.isRemoved() || metaValue == null) {
+ // Don't even add a Property to the Configuration if the
+ // ManagedProperty is flagged as removed or has a
+ // null value.
+ continue;
+ }
+ PropertySimple customProp = customProps.get(propName);
+ PropertyAdapter<Property, PropertyDefinition> propertyAdapter = PropertyAdapterFactory
+ .getCustomPropertyAdapter(customProp);
+ if (propertyAdapter == null)
+ propertyAdapter = PropertyAdapterFactory
+ .getPropertyAdapter(metaValue);
+ if (propertyAdapter == null) {
+ LOG
+ .error("Unable to find a PropertyAdapter for ManagedProperty '"
+ + propName
+ + "' with MetaType ["
+ + metaValue.getMetaType()
+ + "] for ResourceType '"
+ + resourceType.getName() + "'.");
+ continue;
+ }
+ Property property = propertyAdapter.convertToProperty(metaValue,
+ propertyDefinition);
+ config.put(property);
+ }
+ return config;
+ }
+
+ public static void convertConfigurationToManagedProperties(
+ Map<String, ManagedProperty> managedProperties,
+ Configuration configuration, ResourceType resourceType) {
+ ConfigurationDefinition configDefinition = resourceType
+ .getResourceConfigurationDefinition();
+ for (ManagedProperty managedProperty : managedProperties.values()) {
+ String propertyName = managedProperty.getName();
+ PropertyDefinition propertyDefinition = configDefinition
+ .get(propertyName);
+ if (propertyDefinition==null){
+ //The managed property is not defined in the configuration
+ continue;
+ }
+ populateManagedPropertyFromProperty(managedProperty,
+ propertyDefinition, configuration);
+ }
+ return;
+ }
+
+ private static void populateManagedPropertyFromProperty(ManagedProperty managedProperty,
+ PropertyDefinition propertyDefinition, Configuration configuration) {
+ // If the ManagedProperty defines a default value, assume it's more
+ // definitive than any default value that may
+ // have been defined in the plugin descriptor, and update the
+ // PropertyDefinition to use that as its default
+ // value.
+ MetaValue defaultValue = managedProperty.getDefaultValue();
+ if (defaultValue != null)
+ updateDefaultValueOnPropertyDefinition(propertyDefinition,
+ defaultValue);
+ MetaValue metaValue = managedProperty.getValue();
+ PropertyAdapter propertyAdapter = null;
+ if (metaValue != null) {
+ LOG.trace("Populating existing MetaValue of type "
+ + metaValue.getMetaType() + " from RHQ property "
+ + propertyDefinition.getName() + " with definition " + propertyDefinition
+ + "...");
+ propertyAdapter = PropertyAdapterFactory
+ .getPropertyAdapter(metaValue);
+ propertyAdapter.populateMetaValueFromProperty(configuration.getSimple(propertyDefinition.getName()), metaValue,
+ propertyDefinition);
+ } else {
+ MetaType metaType = managedProperty.getMetaType();
+ if (propertyAdapter == null)
+ propertyAdapter = PropertyAdapterFactory
+ .getPropertyAdapter(metaType);
+ LOG.trace("Converting property " + propertyDefinition.getName() + " with definition "
+ + propertyDefinition + " to MetaValue of type " + metaType
+ + "...");
+ metaValue = propertyAdapter.convertToMetaValue(configuration.getSimple(propertyDefinition.getName()),
+ propertyDefinition, metaType);
+ managedProperty.setValue(metaValue);
+ }
+ }
+
+ private static void updateDefaultValueOnPropertyDefinition(
+ PropertyDefinition propertyDefinition,
+ @NotNull MetaValue defaultValue) {
+ if (!(propertyDefinition instanceof PropertyDefinitionSimple)) {
+ LOG
+ .debug("Cannot update default value on non-simple property definition "
+ + propertyDefinition
+ + "(default value is "
+ + defaultValue + ").");
+ return;
+ }
+ MetaType metaType = defaultValue.getMetaType();
+ if (!metaType.isSimple() && !metaType.isEnum()) {
+ LOG.debug("Cannot update default value on " + propertyDefinition
+ + ", because default value's type (" + metaType
+ + ") is not simple or enum.");
+ return;
+ }
+ PropertyDefinitionSimple propertyDefinitionSimple = (PropertyDefinitionSimple) propertyDefinition;
+ if (metaType.isSimple()) {
+ SimpleValue defaultSimpleValue = (SimpleValue) defaultValue;
+ Serializable value = defaultSimpleValue.getValue();
+ propertyDefinitionSimple.setDefaultValue((value != null) ? value
+ .toString() : null);
+ } else { // defaultValueMetaType.isEnum()
+ EnumValue defaultEnumValue = (EnumValue) defaultValue;
+ Serializable value = defaultEnumValue.getValue();
+ propertyDefinitionSimple.setDefaultValue((value != null) ? value
+ .toString() : null);
+ }
+ }
+
+ public static MetaType convertPropertyDefinitionToMetaType(
+ PropertyDefinition propDef) {
+ MetaType memberMetaType;
+ if (propDef instanceof PropertyDefinitionSimple) {
+ PropertySimpleType propSimpleType = ((PropertyDefinitionSimple) propDef)
+ .getType();
+ memberMetaType = convertPropertySimpleTypeToSimpleMetaType(propSimpleType);
+ } else if (propDef instanceof PropertyDefinitionList) {
+ // TODO (very low priority, since lists of lists are not going to be
+ // at all common)
+ memberMetaType = null;
+ } else if (propDef instanceof PropertyDefinitionMap) {
+ Map<String, PropertyDefinition> memberPropDefs = ((PropertyDefinitionMap) propDef)
+ .getPropertyDefinitions();
+ if (memberPropDefs.isEmpty())
+ throw new IllegalStateException(
+ "PropertyDefinitionMap doesn't contain any member PropertyDefinitions.");
+ // NOTE: We assume member prop defs are all of the same type, since
+ // for MapCompositeMetaTypes, they have to be.
+ PropertyDefinition mapMemberPropDef = memberPropDefs.values()
+ .iterator().next();
+ MetaType mapMemberMetaType = convertPropertyDefinitionToMetaType(mapMemberPropDef);
+ memberMetaType = new MapCompositeMetaType(mapMemberMetaType);
+ } else {
+ throw new IllegalStateException(
+ "List member PropertyDefinition has unknown type: "
+ + propDef.getClass().getName());
+ }
+ return memberMetaType;
+ }
- public static <T> T getSimpleValue(ManagedComponent mc, String prop, Class<T> expectedType) {
- ManagedProperty mp = mc.getProperty(prop);
- if (mp != null) {
- MetaType metaType = mp.getMetaType();
- if (metaType.isSimple()) {
- SimpleValue simpleValue = (SimpleValue)mp.getValue();
- return expectedType.cast((simpleValue != null) ? simpleValue.getValue() : null);
- }
- else if (metaType.isEnum()) {
- EnumValue enumValue = (EnumValue)mp.getValue();
- return expectedType.cast((enumValue != null) ? enumValue.getValue() : null);
- }
- throw new IllegalStateException(prop+ " is not a simple type");
- }
- return null;
- }
+ private static MetaType convertPropertySimpleTypeToSimpleMetaType(PropertySimpleType memberSimpleType)
+ {
+ MetaType memberMetaType;
+ Class memberClass;
+ switch (memberSimpleType)
+ {
+ case BOOLEAN:
+ memberClass = Boolean.class;
+ break;
+ case INTEGER:
+ memberClass = Integer.class;
+ break;
+ case LONG:
+ memberClass = Long.class;
+ break;
+ case FLOAT:
+ memberClass = Float.class;
+ break;
+ case DOUBLE:
+ memberClass = Double.class;
+ break;
+ default:
+ memberClass = String.class;
+ break;
+ }
+ memberMetaType = SimpleMetaType.resolve(memberClass.getName());
+ return memberMetaType;
+ }
+
}
Modified: trunk/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-05-19 21:07:59 UTC (rev 2144)
+++ trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-05-19 23:20:03 UTC (rev 2145)
@@ -25,6 +25,40 @@
'>
<!ENTITY translatorConfiguration '
+
+ <c:list-property name="translatorList" description="Properties for this translator"
+ readOnly="true">
+ <c:simple-property name="name" displayName="Name"
+ description="Name of the translator" />
+ <c:simple-property name="execution-factory-class" displayName="execution-factory-class"
+ description="Connector Class" />
+ <c:simple-property name="capabilities-class" displayName="capabilities-class"
+ description="The class to use to provide the Connector Capabilities" />
+ <c:simple-property name="override-capabilities-file" displayName="override-capabilities-file"
+ description="Property file that defines the override capability properties" />
+ <c:simple-property name="immutable" displayName="immutable"
+ description="Is Immutable, True if the source never changes." type="boolean" default="false" />
+ <c:simple-property name="exception-on-max-rows" displayName="exception-on-max-rows" type="boolean" default="false" />
+ description="Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned" default="false" />
+ <c:simple-property name="max-result-rows" displayName="max-result-rows"
+ description="Maximum Result Rows allowed" default="false" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions" type="boolean" default="false" />
+ <c:list-property name="translatorList" description="Properties for this translator"
+ readOnly="true">
+ <c:map-property name="translator-properties" >
+ <c:simple-property name="name" displayName="Name"
+ description="Name of this property" readOnly="true" />
+ <c:simple-property name="value" displayName="Value"
+ description="Value of this property" />
+ <c:simple-property name="description" displayName="Description"
+ description="Description of this property" />
+ </c:map-property>
+ </c:list-property>
+
+'>
+
+<!ENTITY accessTranslatorConfiguration '
<resource-configuration>
<c:list-property name="translatorList" description="Properties for this translator"
readOnly="true">
@@ -37,11 +71,9 @@
description="Description of this property" readOnly="true" />
</c:map-property>
</c:list-property>
- </resource-configuration>
+ </resource-configuration>
-
-'>
-
+'>
<!ENTITY datasourceAndConnectionFactoryOperations '
<operation name="flush" displayName="Flush"
@@ -1258,10 +1290,203 @@
</service>
<service name="Translators" description="Teiid Translators"
- class="TranslatorComponent" discovery="TranslatorDiscoveryComponent">
+ class="TranslatorComponent" discovery="TranslatorDiscoveryComponent"
+ createDeletePolicy="both" creationDataType="configuration">
- &translatorConfiguration;
+ <plugin-configuration>
+ <c:simple-property name="componentType" default="teiid"
+ readOnly="true" />
+ <c:simple-property name="componentSubtype"
+ default="translator" readOnly="true" />
+ <c:simple-property name="componentName" default="teiid"
+ readOnly="true" />
+ <c:simple-property name="template-name" default="translator"
+ readOnly="true" />
+ <c:simple-property name="resourceName" default="name">
+ <c:description>The name of the Resource configuration property
+ whose value should be used as the
+ Resource name when creating a new
+ Resource of this type.</c:description>
+ </c:simple-property>
+ </plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="name" displayName="Name"
+ description="Name of the translator" />
+ <c:simple-property name="execution-factory-class"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="immutable" displayName="immutable"
+ description="Is Immutable, True if the source never changes." type="boolean"
+ default="false" />
+ <c:simple-property name="exception-on-max-rows"
+ displayName="exception-on-max-rows"
+ description="Indicates if an Exception should be thrown if the
+ specified value for Maximum Result Rows is exceeded; else no
+ exception and no more than the maximum will be returned"
+ type="boolean" default="false" defaultValue="false" />
+ <c:simple-property name="max-result-rows"
+ displayName="max-result-rows" description="Maximum Result Rows allowed"
+ default="false" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="false" />
+ <c:list-property name="translatorList" readOnly="true" required="false"
+ displayName="Translator Specific Properties" description="List of translator specific properties">
+ <c:map-property name="translator-properties" >
+ <c:simple-property name="name" displayName="Name"
+ description="Name of this property" readOnly="true" />
+ <c:simple-property name="value" displayName="Value"
+ description="Value of this property" />
+ <c:simple-property name="description"
+ displayName="Description" description="Description of this property" />
+ </c:map-property>
+ </c:list-property>
+ <c:simple-property name="template-name" default="translator"
+ readOnly="true" />
+
+ <c:template name="Access" description="Translator for Access">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.access.AccessExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="DB2" description="Translator for DB2">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.db2.DB2ExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="Derby" description="Translator for Derby">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.derby.DerbyExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="H2" description="Translator for H2">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.h2.H2ExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="HSQL" description="Translator for HSQL">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.hsql.HsqlExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="MySQL" description="Translator for MySQL">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.mysql.MySQLExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="MySQL5" description="Translator for MySQL 5">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.mysql5.MySQL5ExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="Oracle" description="Translator for Oracle">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.oracle.OracleExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="SQLServer" description="Translator for SQLServer">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.oracle.SQLServerExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="Sybase" description="Translator for Sybase">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.jdbc.sybase.SybaseExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-jdbc-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="LDAP" description="Translator for LDAP">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.ldap.LDAPExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-ldap-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="SalesForce" description="Translator for SalesForce">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.salesforce.SalesForceExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-salesforce-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="XML" description="Translator for XML">
+ <c:simple-property name="execution-factory-class"
+ default="org.teiid.translator.xml.XMLExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-xml-${project.version}" readOnly="true" />
+ </c:template>
+ <c:template name="Loopback" description="Translator for Loopback">
+ <c:simple-property name="execution-factory-class"
+ default=">org.teiid.translator.loopback.LoopbackExecutionFactory"
+ displayName="execution-factory-class" description="Connector Class" />
+ <c:simple-property name="xa-capable" displayName="xa-capable"
+ description="True, if this connector supports XA Transactions"
+ type="boolean" default="true" />
+ <c:simple-property name="template-name"
+ default="translator-loopback-${project.version}" readOnly="true" />
+ </c:template>
+
+ </resource-configuration>
+
</service>
</server>
14 years, 7 months