teiid SVN: r4481 - in trunk: admin and 33 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-27 06:24:37 -0400 (Thu, 27 Sep 2012)
New Revision: 4481
Modified:
trunk/admin/pom.xml
trunk/adminshell/pom.xml
trunk/api/pom.xml
trunk/build/pom.xml
trunk/client-jdk15/pom.xml
trunk/client/pom.xml
trunk/common-core/pom.xml
trunk/connectors/connector-file/pom.xml
trunk/connectors/connector-ldap/pom.xml
trunk/connectors/connector-salesforce/pom.xml
trunk/connectors/connector-ws/pom.xml
trunk/connectors/pom.xml
trunk/connectors/salesforce-api/pom.xml
trunk/connectors/sandbox/pom.xml
trunk/connectors/sandbox/translator-yahoo/pom.xml
trunk/connectors/translator-file/pom.xml
trunk/connectors/translator-hive/pom.xml
trunk/connectors/translator-jdbc/pom.xml
trunk/connectors/translator-jpa/pom.xml
trunk/connectors/translator-ldap/pom.xml
trunk/connectors/translator-loopback/pom.xml
trunk/connectors/translator-object/pom.xml
trunk/connectors/translator-olap/pom.xml
trunk/connectors/translator-salesforce/pom.xml
trunk/connectors/translator-ws/pom.xml
trunk/engine/pom.xml
trunk/hibernate-dialect/pom.xml
trunk/jboss-integration/pom.xml
trunk/metadata/pom.xml
trunk/pom.xml
trunk/runtime/pom.xml
trunk/test-integration/common/pom.xml
trunk/test-integration/db/pom.xml
trunk/test-integration/perf/pom.xml
trunk/test-integration/pom.xml
Log:
[maven-release-plugin] prepare for next development iteration
Modified: trunk/admin/pom.xml
===================================================================
--- trunk/admin/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/admin/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-admin</artifactId>
Modified: trunk/adminshell/pom.xml
===================================================================
--- trunk/adminshell/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/adminshell/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-adminshell</artifactId>
Modified: trunk/api/pom.xml
===================================================================
--- trunk/api/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/api/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-api</artifactId>
Modified: trunk/build/pom.xml
===================================================================
--- trunk/build/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/build/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid</artifactId>
Modified: trunk/client/pom.xml
===================================================================
--- trunk/client/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/client/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-client</artifactId>
Modified: trunk/client-jdk15/pom.xml
===================================================================
--- trunk/client-jdk15/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/client-jdk15/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-client-jdk15</artifactId>
Modified: trunk/common-core/pom.xml
===================================================================
--- trunk/common-core/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/common-core/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-common-core</artifactId>
Modified: trunk/connectors/connector-file/pom.xml
===================================================================
--- trunk/connectors/connector-file/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/connector-file/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-file</artifactId>
Modified: trunk/connectors/connector-ldap/pom.xml
===================================================================
--- trunk/connectors/connector-ldap/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/connector-ldap/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ldap</artifactId>
Modified: trunk/connectors/connector-salesforce/pom.xml
===================================================================
--- trunk/connectors/connector-salesforce/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/connector-salesforce/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-salesforce</artifactId>
Modified: trunk/connectors/connector-ws/pom.xml
===================================================================
--- trunk/connectors/connector-ws/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/connector-ws/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ws</artifactId>
Modified: trunk/connectors/pom.xml
===================================================================
--- trunk/connectors/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/connectors/salesforce-api/pom.xml
===================================================================
--- trunk/connectors/salesforce-api/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/salesforce-api/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>salesforce-api</artifactId>
Modified: trunk/connectors/sandbox/pom.xml
===================================================================
--- trunk/connectors/sandbox/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/sandbox/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid.connectors</groupId>
Modified: trunk/connectors/sandbox/translator-yahoo/pom.xml
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/sandbox/translator-yahoo/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>sandbox</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-yahoo</artifactId>
Modified: trunk/connectors/translator-file/pom.xml
===================================================================
--- trunk/connectors/translator-file/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-file/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-file</artifactId>
Modified: trunk/connectors/translator-hive/pom.xml
===================================================================
--- trunk/connectors/translator-hive/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-hive/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-hive</artifactId>
Modified: trunk/connectors/translator-jdbc/pom.xml
===================================================================
--- trunk/connectors/translator-jdbc/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-jdbc/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-jdbc</artifactId>
Modified: trunk/connectors/translator-jpa/pom.xml
===================================================================
--- trunk/connectors/translator-jpa/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-jpa/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-jpa</artifactId>
Modified: trunk/connectors/translator-ldap/pom.xml
===================================================================
--- trunk/connectors/translator-ldap/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-ldap/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ldap</artifactId>
Modified: trunk/connectors/translator-loopback/pom.xml
===================================================================
--- trunk/connectors/translator-loopback/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-loopback/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-loopback</artifactId>
Modified: trunk/connectors/translator-object/pom.xml
===================================================================
--- trunk/connectors/translator-object/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-object/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-object</artifactId>
Modified: trunk/connectors/translator-olap/pom.xml
===================================================================
--- trunk/connectors/translator-olap/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-olap/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-olap</artifactId>
Modified: trunk/connectors/translator-salesforce/pom.xml
===================================================================
--- trunk/connectors/translator-salesforce/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-salesforce/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-salesforce</artifactId>
Modified: trunk/connectors/translator-ws/pom.xml
===================================================================
--- trunk/connectors/translator-ws/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/connectors/translator-ws/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ws</artifactId>
Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/engine/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-engine</artifactId>
Modified: trunk/hibernate-dialect/pom.xml
===================================================================
--- trunk/hibernate-dialect/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/hibernate-dialect/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-hibernate-dialect</artifactId>
Modified: trunk/jboss-integration/pom.xml
===================================================================
--- trunk/jboss-integration/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/jboss-integration/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-jboss-integration</artifactId>
Modified: trunk/metadata/pom.xml
===================================================================
--- trunk/metadata/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/metadata/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-metadata</artifactId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -10,7 +10,7 @@
<artifactId>teiid-parent</artifactId>
<packaging>pom</packaging>
<name>Teiid</name>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
<description>Federated SQL and XML query engine.</description>
<properties>
<ant.version>1.7.0</ant.version>
@@ -41,9 +41,9 @@
<version.junit>4.10</version.junit>
</properties>
<scm>
- <connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/tags/teiid-parent-8.2.0.Alpha2</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/teiid/tags/teiid-parent-8.2.0.Alpha2</developerConnection>
- <url>http://anonsvn.jboss.org/repos/teiid/tags/teiid-parent-8.2.0.Alpha2</url>
+ <connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/teiid/trunk</developerConnection>
+ <url>http://anonsvn.jboss.org/repos/teiid/trunk</url>
</scm>
<licenses>
<license>
Modified: trunk/runtime/pom.xml
===================================================================
--- trunk/runtime/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/runtime/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-runtime</artifactId>
Modified: trunk/test-integration/common/pom.xml
===================================================================
--- trunk/test-integration/common/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/test-integration/common/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration-common</artifactId>
Modified: trunk/test-integration/db/pom.xml
===================================================================
--- trunk/test-integration/db/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/test-integration/db/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -9,7 +9,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/test-integration/perf/pom.xml
===================================================================
--- trunk/test-integration/perf/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/test-integration/perf/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration-perf</artifactId>
Modified: trunk/test-integration/pom.xml
===================================================================
--- trunk/test-integration/pom.xml 2012-09-27 10:24:25 UTC (rev 4480)
+++ trunk/test-integration/pom.xml 2012-09-27 10:24:37 UTC (rev 4481)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2</version>
+ <version>8.2.0.Beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-test-integration</artifactId>
12 years, 3 months
teiid SVN: r4480 - tags.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-27 06:24:25 -0400 (Thu, 27 Sep 2012)
New Revision: 4480
Added:
tags/teiid-parent-8.2.0.Alpha2/
Log:
[maven-release-plugin] copy for tag teiid-parent-8.2.0.Alpha2
12 years, 3 months
teiid SVN: r4479 - in trunk: admin and 33 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-27 06:24:18 -0400 (Thu, 27 Sep 2012)
New Revision: 4479
Modified:
trunk/admin/pom.xml
trunk/adminshell/pom.xml
trunk/api/pom.xml
trunk/build/pom.xml
trunk/client-jdk15/pom.xml
trunk/client/pom.xml
trunk/common-core/pom.xml
trunk/connectors/connector-file/pom.xml
trunk/connectors/connector-ldap/pom.xml
trunk/connectors/connector-salesforce/pom.xml
trunk/connectors/connector-ws/pom.xml
trunk/connectors/pom.xml
trunk/connectors/salesforce-api/pom.xml
trunk/connectors/sandbox/pom.xml
trunk/connectors/sandbox/translator-yahoo/pom.xml
trunk/connectors/translator-file/pom.xml
trunk/connectors/translator-hive/pom.xml
trunk/connectors/translator-jdbc/pom.xml
trunk/connectors/translator-jpa/pom.xml
trunk/connectors/translator-ldap/pom.xml
trunk/connectors/translator-loopback/pom.xml
trunk/connectors/translator-object/pom.xml
trunk/connectors/translator-olap/pom.xml
trunk/connectors/translator-salesforce/pom.xml
trunk/connectors/translator-ws/pom.xml
trunk/engine/pom.xml
trunk/hibernate-dialect/pom.xml
trunk/jboss-integration/pom.xml
trunk/metadata/pom.xml
trunk/pom.xml
trunk/runtime/pom.xml
trunk/test-integration/common/pom.xml
trunk/test-integration/db/pom.xml
trunk/test-integration/perf/pom.xml
trunk/test-integration/pom.xml
Log:
[maven-release-plugin] prepare release teiid-parent-8.2.0.Alpha2
Modified: trunk/admin/pom.xml
===================================================================
--- trunk/admin/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/admin/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-admin</artifactId>
Modified: trunk/adminshell/pom.xml
===================================================================
--- trunk/adminshell/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/adminshell/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-adminshell</artifactId>
Modified: trunk/api/pom.xml
===================================================================
--- trunk/api/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/api/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-api</artifactId>
Modified: trunk/build/pom.xml
===================================================================
--- trunk/build/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/build/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid</artifactId>
Modified: trunk/client/pom.xml
===================================================================
--- trunk/client/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/client/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-client</artifactId>
Modified: trunk/client-jdk15/pom.xml
===================================================================
--- trunk/client-jdk15/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/client-jdk15/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-client-jdk15</artifactId>
Modified: trunk/common-core/pom.xml
===================================================================
--- trunk/common-core/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/common-core/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-common-core</artifactId>
Modified: trunk/connectors/connector-file/pom.xml
===================================================================
--- trunk/connectors/connector-file/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/connector-file/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-file</artifactId>
Modified: trunk/connectors/connector-ldap/pom.xml
===================================================================
--- trunk/connectors/connector-ldap/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/connector-ldap/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ldap</artifactId>
Modified: trunk/connectors/connector-salesforce/pom.xml
===================================================================
--- trunk/connectors/connector-salesforce/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/connector-salesforce/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-salesforce</artifactId>
Modified: trunk/connectors/connector-ws/pom.xml
===================================================================
--- trunk/connectors/connector-ws/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/connector-ws/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ws</artifactId>
Modified: trunk/connectors/pom.xml
===================================================================
--- trunk/connectors/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/connectors/salesforce-api/pom.xml
===================================================================
--- trunk/connectors/salesforce-api/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/salesforce-api/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>salesforce-api</artifactId>
Modified: trunk/connectors/sandbox/pom.xml
===================================================================
--- trunk/connectors/sandbox/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/sandbox/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid.connectors</groupId>
Modified: trunk/connectors/sandbox/translator-yahoo/pom.xml
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/sandbox/translator-yahoo/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>sandbox</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-yahoo</artifactId>
Modified: trunk/connectors/translator-file/pom.xml
===================================================================
--- trunk/connectors/translator-file/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-file/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-file</artifactId>
Modified: trunk/connectors/translator-hive/pom.xml
===================================================================
--- trunk/connectors/translator-hive/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-hive/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-hive</artifactId>
Modified: trunk/connectors/translator-jdbc/pom.xml
===================================================================
--- trunk/connectors/translator-jdbc/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-jdbc/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-jdbc</artifactId>
Modified: trunk/connectors/translator-jpa/pom.xml
===================================================================
--- trunk/connectors/translator-jpa/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-jpa/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-jpa</artifactId>
Modified: trunk/connectors/translator-ldap/pom.xml
===================================================================
--- trunk/connectors/translator-ldap/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-ldap/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ldap</artifactId>
Modified: trunk/connectors/translator-loopback/pom.xml
===================================================================
--- trunk/connectors/translator-loopback/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-loopback/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-loopback</artifactId>
Modified: trunk/connectors/translator-object/pom.xml
===================================================================
--- trunk/connectors/translator-object/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-object/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-object</artifactId>
Modified: trunk/connectors/translator-olap/pom.xml
===================================================================
--- trunk/connectors/translator-olap/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-olap/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-olap</artifactId>
Modified: trunk/connectors/translator-salesforce/pom.xml
===================================================================
--- trunk/connectors/translator-salesforce/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-salesforce/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-salesforce</artifactId>
Modified: trunk/connectors/translator-ws/pom.xml
===================================================================
--- trunk/connectors/translator-ws/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/connectors/translator-ws/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ws</artifactId>
Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/engine/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-engine</artifactId>
Modified: trunk/hibernate-dialect/pom.xml
===================================================================
--- trunk/hibernate-dialect/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/hibernate-dialect/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-hibernate-dialect</artifactId>
Modified: trunk/jboss-integration/pom.xml
===================================================================
--- trunk/jboss-integration/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/jboss-integration/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-jboss-integration</artifactId>
Modified: trunk/metadata/pom.xml
===================================================================
--- trunk/metadata/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/metadata/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-metadata</artifactId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -10,7 +10,7 @@
<artifactId>teiid-parent</artifactId>
<packaging>pom</packaging>
<name>Teiid</name>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
<description>Federated SQL and XML query engine.</description>
<properties>
<ant.version>1.7.0</ant.version>
@@ -41,9 +41,9 @@
<version.junit>4.10</version.junit>
</properties>
<scm>
- <connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/teiid/trunk</developerConnection>
- <url>http://anonsvn.jboss.org/repos/teiid/trunk</url>
+ <connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/tags/teiid-parent-8.2.0.Alpha2</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/teiid/tags/teiid-parent-8.2.0.Alpha2</developerConnection>
+ <url>http://anonsvn.jboss.org/repos/teiid/tags/teiid-parent-8.2.0.Alpha2</url>
</scm>
<licenses>
<license>
Modified: trunk/runtime/pom.xml
===================================================================
--- trunk/runtime/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/runtime/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-runtime</artifactId>
Modified: trunk/test-integration/common/pom.xml
===================================================================
--- trunk/test-integration/common/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/test-integration/common/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration-common</artifactId>
Modified: trunk/test-integration/db/pom.xml
===================================================================
--- trunk/test-integration/db/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/test-integration/db/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -9,7 +9,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/test-integration/perf/pom.xml
===================================================================
--- trunk/test-integration/perf/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/test-integration/perf/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration-perf</artifactId>
Modified: trunk/test-integration/pom.xml
===================================================================
--- trunk/test-integration/pom.xml 2012-09-27 10:05:05 UTC (rev 4478)
+++ trunk/test-integration/pom.xml 2012-09-27 10:24:18 UTC (rev 4479)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha2-SNAPSHOT</version>
+ <version>8.2.0.Alpha2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-test-integration</artifactId>
12 years, 3 months
teiid SVN: r4478 - in trunk/runtime/src: test/java/org/teiid/runtime and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-27 06:05:05 -0400 (Thu, 27 Sep 2012)
New Revision: 4478
Modified:
trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
Log:
TEIID-2230 accounting for empty vdbs
Modified: trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java 2012-09-27 10:04:26 UTC (rev 4477)
+++ trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java 2012-09-27 10:05:05 UTC (rev 4478)
@@ -44,8 +44,8 @@
import org.teiid.metadata.MetadataRepository;
import org.teiid.metadata.MetadataStore;
import org.teiid.query.metadata.DDLMetadataRepository;
+import org.teiid.query.metadata.DirectQueryMetadataRepository;
import org.teiid.query.metadata.NativeMetadataRepository;
-import org.teiid.query.metadata.DirectQueryMetadataRepository;
import org.teiid.translator.TranslatorException;
public abstract class AbstractVDBDeployer {
@@ -139,6 +139,10 @@
loadCount.incrementAndGet();
}
}
+ if (loadCount.get() == 0) {
+ getVDBRepository().finishDeployment(vdb.getName(), vdb.getVersion());
+ return;
+ }
for (ModelMetaData model: vdb.getModelMetaDatas().values()) {
MetadataRepository metadataRepository = model.getAttachment(MetadataRepository.class);
if (model.getModelType() == Model.Type.PHYSICAL || model.getModelType() == Model.Type.VIRTUAL) {
Modified: trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java 2012-09-27 10:04:26 UTC (rev 4477)
+++ trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java 2012-09-27 10:05:05 UTC (rev 4478)
@@ -275,6 +275,11 @@
s.execute("update \"my-view\" set \"my-column\" = 'a'");
assertEquals(2, s.getUpdateCount());
+
+ es.deployVDB("empty");
+ c = es.getDriver().connect("jdbc:teiid:empty", null);
+ s = c.createStatement();
+ s.execute("select * from tables");
}
@Test(expected=VirtualDatabaseException.class) public void testDeploymentError() throws Exception {
12 years, 3 months
teiid SVN: r4477 - trunk/engine/src/main/javacc/org/teiid/query/parser.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-27 06:04:26 -0400 (Thu, 27 Sep 2012)
New Revision: 4477
Modified:
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
Log:
TEIID-2226 correcting declare
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2012-09-27 10:04:04 UTC (rev 4476)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2012-09-27 10:04:26 UTC (rev 4477)
@@ -1170,7 +1170,7 @@
/*
name=declare statement
description=A procedure declaration statement that creates a variable and optionally assigns a value.
-example={code:sql}DECLARE STRING x := 'a'{code}
+example={code:sql}DECLARE STRING x = 'a'{code}
*/
DeclareStatement declareStatement(ParseInfo info) :
{
12 years, 3 months
teiid SVN: r4476 - in trunk/test-integration/common/src/test/java/org/teiid: transport and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-27 06:04:04 -0400 (Thu, 27 Sep 2012)
New Revision: 4476
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java
Log:
updating unit tests
Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java 2012-09-26 23:15:59 UTC (rev 4475)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java 2012-09-27 10:04:04 UTC (rev 4476)
@@ -128,7 +128,7 @@
@Test
public void testTraslators() throws Exception {
Collection<? extends Translator> translators = admin.getTranslators();
- assertEquals(30, translators.size());
+ assertEquals(33, translators.size());
JavaArchive jar = getLoopyArchive();
Modified: trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java 2012-09-26 23:15:59 UTC (rev 4475)
+++ trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java 2012-09-27 10:04:04 UTC (rev 4476)
@@ -186,8 +186,8 @@
Properties p = new Properties();
p.setProperty("user", "testuser");
p.setProperty("password", "testpassword");
- p.setProperty("org.teiid.sockets.soTimeout", "50");
- p.setProperty("org.teiid.sockets.SynchronousTtl", "50");
+ p.setProperty("org.teiid.sockets.soTimeout", "200");
+ p.setProperty("org.teiid.sockets.SynchronousTtl", "100");
ConnectorManagerRepository cmr = server.getConnectorManagerRepository();
AutoGenDataService agds = new AutoGenDataService() {
@Override
@@ -196,7 +196,7 @@
return null;
}
};
- agds.setSleep(100);
+ agds.setSleep(500); //wait longer than the synch ttl/soTimeout, we should still succeed
cmr.addConnectorManager("source", agds);
try {
conn = td.connect("jdbc:teiid:parts@mm://"+addr.getHostName()+":" +jdbcTransport.getPort(), p);
12 years, 3 months
teiid SVN: r4475 - in trunk: common-core/src/main/java/org/teiid/core/util and 24 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-26 19:15:59 -0400 (Wed, 26 Sep 2012)
New Revision: 4475
Modified:
trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java
trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ErrorInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/IfInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java
trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/CommandStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/processor/TestTriggerActions.java
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcErrors.java
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
trunk/engine/src/test/java/org/teiid/query/validator/TestAlterValidation.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java
Log:
TEIID-2226 TEIID-1386 replacing the path logic for result detection and refining exception support
Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-09-26 23:15:59 UTC (rev 4475)
@@ -57,7 +57,9 @@
<li>TEIID-2187 the CONSTRAINT keyword is not correctly used in table DDL. It should be replaced with a comma from scripts to be compatible with 8.2. If desired, 8.2 now supports the CONSTRAINT keyword to provide a name for each constraint.
<li>TEIID-2181 system tables no longer contain valid OIDs. That responsibility has moved to the pg_catalog.
<li>TEIID-1386 the SQLState and errorCode reported by a TeiidSQLException will typically be from the top level nested SQLException. If there is also a nested TeiidException, the TeiidSQLException.teiidCode will be set to the TeiidException.getCode value and the TeiidSQLException.errorCode will be set
- to the integer suffix of the teiidCode if possible.
+ to the integer suffix of the teiidCode if possible.
+ <li>TEIID-2226 All statements that return result sets that are executed as command statements in a procedure are validated against the expected resultset columns of the procedure.
+ If the statement is not intended to be returnable, WITHOUT RETURN can be added to the end of the statement.
</ul>
<h4>from 8.0</h4>
Modified: trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -74,18 +74,34 @@
*/
public static final String LINE_SEPARATOR = System.getProperty(LINE_SEPARATOR_PROPERTY_NAME, Constants.NEW_LINE);
- public static final Comparator CASE_INSENSITIVE_ORDER = String.CASE_INSENSITIVE_ORDER;
+ public static final Comparator<String> CASE_INSENSITIVE_ORDER = String.CASE_INSENSITIVE_ORDER;
+
+ public static final Comparator<String> NULL_SAFE_CASE_INSENSITIVE_ORDER = new Comparator<String>() {
+ @Override
+ public int compare(String o1, String o2) {
+ if (o1 == null) {
+ if (o2 == null) {
+ return 0;
+ }
+ return -1;
+ }
+ if (o2 == null) {
+ return 1;
+ }
+ return String.CASE_INSENSITIVE_ORDER.compare(o1, o2);
+ }
+ };
- public static final Comparator CASE_SENSITIVE_ORDER = new Comparator() {
+ public static final Comparator<String> CASE_SENSITIVE_ORDER = new Comparator<String>() {
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
* @since 4.2
*/
- public int compare(Object o1, Object o2) {
+ public int compare(String o1, String o2) {
if ( o1 == o2 ) {
return 0;
}
- return ((String)o1).compareTo((String)o2);
+ return o1.compareTo(o2);
}
};
Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -330,7 +330,6 @@
TEIID30364,
TEIID30365,
TEIID30366,
- TEIID30367,
TEIID30371,
TEIID30372,
TEIID30373,
@@ -535,6 +534,7 @@
TEIID31118,
TEIID31119,
TEIID31120,
- TEIID31121,
+ TEIID31121,
+ TEIID31122,
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -36,6 +36,7 @@
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.proc.*;
+import org.teiid.query.processor.proc.CreateCursorResultSetInstruction.Mode;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.DynamicCommand;
import org.teiid.query.sql.lang.SPParameter;
@@ -97,7 +98,7 @@
// create plan from program and initialized environment
ProcedurePlan plan = new ProcedurePlan(programBlock);
-
+ plan.setMetadata(metadata);
plan.setOutputElements(cupc.getProjectedSymbols());
if(debug) {
@@ -231,12 +232,9 @@
ProcessorPlan commandPlan = cmdStmt.getCommand().getProcessorPlan();
if (command.getType() == Command.TYPE_DYNAMIC){
- instruction = new ExecDynamicSqlInstruction(parentProcCommand,((DynamicCommand)command), metadata, idGenerator, capFinder );
+ instruction = new ExecDynamicSqlInstruction(parentProcCommand,((DynamicCommand)command), metadata, idGenerator, capFinder, cmdStmt.isReturnable() );
}else{
- instruction = new CreateCursorResultSetInstruction(CreateCursorResultSetInstruction.RS_NAME, commandPlan,
- command.getType() == Command.TYPE_INSERT
- || command.getType() == Command.TYPE_UPDATE
- || command.getType() == Command.TYPE_DELETE);
+ instruction = new CreateCursorResultSetInstruction(null, commandPlan, (!command.returnsResultSet()&&!(command instanceof StoredProcedure))?Mode.UPDATE:(cmdStmt.isReturnable()&&cmdStmt.getCommand().returnsResultSet())?Mode.HOLD:Mode.NOHOLD);
//handle stored procedure calls
if (command.getType() == Command.TYPE_STORED_PROCEDURE) {
StoredProcedure sp = (StoredProcedure)command;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -22,9 +22,6 @@
package org.teiid.query.optimizer;
-import java.util.LinkedList;
-import java.util.List;
-
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.api.exception.query.QueryResolverException;
@@ -40,21 +37,17 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempCapabilitiesFinder;
import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.relational.RelationalPlanner;
import org.teiid.query.optimizer.xml.XMLPlanner;
import org.teiid.query.processor.ProcessorPlan;
-import org.teiid.query.processor.proc.ProcedurePlan;
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.ProcedureContainer;
import org.teiid.query.sql.lang.Query;
-import org.teiid.query.sql.lang.SPParameter;
-import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.proc.CreateProcedureCommand;
-import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.util.CommandContext;
@@ -111,14 +104,16 @@
switch (command.getType()) {
case Command.TYPE_UPDATE_PROCEDURE:
CreateProcedureCommand cupc = (CreateProcedureCommand)command;
- if (cupc.getUserCommand() == null) {
+ if (cupc.getUpdateType() != Command.TYPE_UNKNOWN) {
//row update procedure
result = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, context);
} else {
- StoredProcedure c = (StoredProcedure)cupc.getUserCommand();
Object pid = cupc.getVirtualGroup().getMetadataID();
- if (c != null) {
- pid = c.getProcedureID();
+ if (pid instanceof TempMetadataID) {
+ TempMetadataID tid = (TempMetadataID)pid;
+ if (tid.getOriginalMetadataID() != null) {
+ pid = tid.getOriginalMetadataID();
+ }
}
String fullName = metadata.getFullName(pid);
fullName = "procedure cache:" + fullName; //$NON-NLS-1$
@@ -141,34 +136,6 @@
context.accessedPlanningObject(id);
}
}
- // propagate procedure parameters to the plan to allow runtime type checking
- ProcedureContainer container = (ProcedureContainer)cupc.getUserCommand();
- ProcedurePlan plan = (ProcedurePlan)result;
- if (container != null) {
- if (container instanceof StoredProcedure) {
- plan.setRequiresTransaction(container.getUpdateCount() > 0);
- StoredProcedure sp = (StoredProcedure)container;
- if (sp.returnParameters()) {
- List<ElementSymbol> outParams = new LinkedList<ElementSymbol>();
- for (SPParameter param : sp.getParameters()) {
- if (param.getParameterType() == SPParameter.RETURN_VALUE) {
- outParams.add(param.getParameterSymbol());
- }
- }
- for (SPParameter param : sp.getParameters()) {
- if (param.getParameterType() == SPParameter.INOUT ||
- param.getParameterType() == SPParameter.OUT) {
- outParams.add(param.getParameterSymbol());
- }
- }
- if (outParams.size() > 0) {
- plan.setOutParams(outParams);
- }
- }
- plan.setParams(sp.getProcedureParameters());
- }
- plan.setMetadata(metadata);
- }
break;
case Command.TYPE_BATCHED_UPDATE:
result = BATCHED_UPDATE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -99,7 +99,7 @@
result.setLookupMap(RelationalNode.createLookupMap(query.getProjectedSymbols()));
CreateProcedureCommand command = new CreateProcedureCommand(ta.getBlock());
command.setVirtualGroup(ta.getView());
- command.setUpdateType(userCommand.getClass().getSimpleName());
+ command.setUpdateType(userCommand.getType());
ProcedurePlan rowProcedure = (ProcedurePlan)QueryOptimizer.optimizePlan(command, metadata, idGenerator, capFinder, analysisRecord, context);
result.setRowProcedure(rowProcedure);
return result;
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 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -61,6 +61,7 @@
import org.teiid.query.optimizer.relational.rules.RulePlaceAccess;
import org.teiid.query.optimizer.relational.rules.RulePushAggregates;
import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.proc.ProcedurePlan;
import org.teiid.query.processor.relational.AccessNode;
import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
@@ -581,13 +582,18 @@
if (c == null) {
c = QueryResolver.expandCommand(container, metadata, analysisRecord);
if (c != null) {
+ if (c instanceof CreateProcedureCommand) {
+ //TODO: find a better way to do this
+ ((CreateProcedureCommand)c).setProjectedSymbols(container.getProjectedSymbols());
+ }
Request.validateWithVisitor(new ValidationVisitor(), metadata, c);
metadata.addToMetadataCache(metadataId, cacheString, c.clone());
}
} else {
c = (Command)c.clone();
if (c instanceof CreateProcedureCommand) {
- ((CreateProcedureCommand)c).setUserCommand(container);
+ //TODO: find a better way to do this
+ ((CreateProcedureCommand)c).setProjectedSymbols(container.getProjectedSymbols());
}
}
if (c != null) {
@@ -1007,6 +1013,30 @@
actualMetadata = ((TempMetadataAdapter)metadata).getMetadata();
}
ProcessorPlan plan = QueryOptimizer.optimizePlan(toPlan, actualMetadata, idGenerator, capFinder, analysisRecord, context);
+ //hack for the optimizer not knowing the containing command when forming the plan
+ if (nestedCommand instanceof StoredProcedure && plan instanceof ProcedurePlan) {
+ StoredProcedure container = (StoredProcedure)nestedCommand;
+ ProcedurePlan pp = (ProcedurePlan)plan;
+ pp.setRequiresTransaction(container.getUpdateCount() > 0);
+ if (container.returnParameters()) {
+ List<ElementSymbol> outParams = new LinkedList<ElementSymbol>();
+ for (SPParameter param : container.getParameters()) {
+ if (param.getParameterType() == SPParameter.RETURN_VALUE) {
+ outParams.add(param.getParameterSymbol());
+ }
+ }
+ for (SPParameter param : container.getParameters()) {
+ if (param.getParameterType() == SPParameter.INOUT ||
+ param.getParameterType() == SPParameter.OUT) {
+ outParams.add(param.getParameterSymbol());
+ }
+ }
+ if (outParams.size() > 0) {
+ pp.setOutParams(outParams);
+ }
+ }
+ pp.setParams(container.getProcedureParameters());
+ }
node.setProperty(NodeConstants.Info.PROCESSOR_PLAN, plan);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -40,17 +40,21 @@
*/
public class CreateCursorResultSetInstruction extends ProgramInstruction {
- public static final String RS_NAME = "EXECSQL_INSTRUCTION"; //$NON-NLS-1$
+ public enum Mode {
+ UPDATE,
+ HOLD,
+ NOHOLD
+ }
protected String rsName;
protected ProcessorPlan plan;
- private boolean update;
+ private Mode mode;
private Map<ElementSymbol, ElementSymbol> procAssignments;
- public CreateCursorResultSetInstruction(String rsName, ProcessorPlan plan, boolean update){
+ public CreateCursorResultSetInstruction(String rsName, ProcessorPlan plan, Mode mode){
this.rsName = rsName;
this.plan = plan;
- this.update = update;
+ this.mode = mode;
}
public void setProcAssignments(
@@ -60,22 +64,8 @@
public void process(ProcedurePlan procEnv)
throws BlockedException, TeiidComponentException, TeiidProcessingException {
-
- if(procEnv.resultSetExists(rsName)) {
- procEnv.removeResults(rsName);
- }
-
- procEnv.executePlan(plan, rsName, procAssignments, !update);
-
- if (update) {
- boolean hasNext = procEnv.iterateCursor(rsName);
- if (hasNext) {
- procEnv.getCurrentVariableContext().setValue(ProcedurePlan.ROWCOUNT, procEnv.getCurrentRow(rsName).get(0));
- } else {
- procEnv.getCurrentVariableContext().setValue(ProcedurePlan.ROWCOUNT, 0);
- }
- procEnv.removeResults(rsName);
- }
+
+ procEnv.executePlan(plan, rsName, procAssignments, mode);
}
/**
@@ -83,7 +73,7 @@
*/
public CreateCursorResultSetInstruction clone(){
ProcessorPlan clonedPlan = this.plan.clone();
- CreateCursorResultSetInstruction clone = new CreateCursorResultSetInstruction(this.rsName, clonedPlan, update);
+ CreateCursorResultSetInstruction clone = new CreateCursorResultSetInstruction(this.rsName, clonedPlan, mode);
clone.setProcAssignments(procAssignments);
return clone;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ErrorInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/ErrorInstruction.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ErrorInstruction.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -29,6 +29,7 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.jdbc.TeiidSQLException;
import org.teiid.logging.LogManager;
+import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.symbol.Expression;
@@ -85,7 +86,7 @@
return;
}
if (value == null) {
- throw new TeiidProcessingException();
+ throw new TeiidProcessingException(QueryPlugin.Event.TEIID31122, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31122));
}
throw TeiidSQLException.create((Exception)value);
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -52,6 +52,7 @@
import org.teiid.query.parser.QueryParser;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.RegisterRequestParameter;
+import org.teiid.query.processor.proc.CreateCursorResultSetInstruction.Mode;
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.ProcedureReservedWords;
@@ -92,6 +93,7 @@
// the metadata for this plan
private QueryMetadataInterface metadata;
+ private boolean returnable;
// The parent command
CreateProcedureCommand parentProcCommand;
@@ -101,12 +103,13 @@
public ExecDynamicSqlInstruction(
CreateProcedureCommand parentProcCommand,
DynamicCommand command, QueryMetadataInterface metadata,
- IDGenerator idGenerator, CapabilitiesFinder capFinder) {
+ IDGenerator idGenerator, CapabilitiesFinder capFinder, boolean returnable) {
this.parentProcCommand = parentProcCommand;
this.dynamicCommand = command;
this.metadata = metadata;
this.capFinder = capFinder;
this.idGenerator = idGenerator;
+ this.returnable = returnable;
}
/**
@@ -185,7 +188,7 @@
.createNonRecordingRecord(), procEnv
.getContext());
- CreateCursorResultSetInstruction inst = new CreateCursorResultSetInstruction(CreateCursorResultSetInstruction.RS_NAME, commandPlan, dynamicCommand.getIntoGroup() != null) {
+ CreateCursorResultSetInstruction inst = new CreateCursorResultSetInstruction(null, commandPlan, dynamicCommand.getIntoGroup() != null?Mode.UPDATE:returnable?Mode.HOLD:Mode.NOHOLD) {
@Override
public void process(ProcedurePlan procEnv)
throws BlockedException, TeiidComponentException,
@@ -316,8 +319,8 @@
// do a recursion check
// Add group to recursion stack
CommandContext context = procEnv.getContext();
- if (parentProcCommand.getUpdateType() != null) {
- context.pushCall(parentProcCommand.getUpdateType() + " " + parentProcCommand.getVirtualGroup()); //$NON-NLS-1$
+ if (parentProcCommand.getUpdateType() != Command.TYPE_UNKNOWN) {
+ context.pushCall(Command.getCommandToken(parentProcCommand.getUpdateType()) + " " + parentProcCommand.getVirtualGroup()); //$NON-NLS-1$
} else {
context.pushCall(parentProcCommand.getVirtualGroup().toString());
}
@@ -328,7 +331,7 @@
*/
public ExecDynamicSqlInstruction clone() {
ExecDynamicSqlInstruction clone = new ExecDynamicSqlInstruction(
- parentProcCommand, dynamicCommand, metadata, idGenerator, capFinder);
+ parentProcCommand, dynamicCommand, metadata, idGenerator, capFinder, returnable);
return clone;
}
@@ -341,5 +344,13 @@
props.addProperty(PROP_SQL, dynamicCommand.toString());
return props;
}
+
+ public boolean isReturnable() {
+ return returnable;
+ }
+
+ public void setReturnable(boolean returnable) {
+ this.returnable = returnable;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/IfInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/IfInstruction.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/IfInstruction.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -125,7 +125,14 @@
}
public String toString() {
- return "IF INSTRUCTION:"; //$NON-NLS-1$
+ StringBuffer sb = new StringBuffer("IF INSTRUCTION: "); //$NON-NLS-1$
+ sb.append(condition);
+ sb.append("\n").append(ifProgram); //$NON-NLS-1$
+ if (elseProgram!=null) {
+ sb.append("\nELSE\n"); //$NON-NLS-1$
+ sb.append(elseProgram);
+ }
+ return sb.toString();
}
public PlanNode getDescriptionProperties() {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -49,7 +49,7 @@
private String label;
public LoopInstruction(Program loopProgram, String rsName, ProcessorPlan plan, String label) {
- super(rsName, plan, false);
+ super(rsName, plan, Mode.NOHOLD);
this.loopProgram = loopProgram;
this.label = label;
}
@@ -105,7 +105,7 @@
public boolean testCondition(ProcedurePlan procEnv) throws TeiidComponentException, TeiidProcessingException {
if(!procEnv.resultSetExists(rsName)) {
- procEnv.executePlan(plan, rsName, null, false);
+ procEnv.executePlan(plan, rsName, null, Mode.NOHOLD);
}
return procEnv.iterateCursor(rsName);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -28,12 +28,12 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Stack;
+import java.util.TreeMap;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryValidatorException;
@@ -52,6 +52,7 @@
import org.teiid.core.types.ArrayImpl;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.Assertion;
+import org.teiid.core.util.StringUtil;
import org.teiid.dqp.internal.process.DataTierTupleSource;
import org.teiid.dqp.service.TransactionContext;
import org.teiid.dqp.service.TransactionService;
@@ -70,6 +71,7 @@
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.QueryProcessor;
import org.teiid.query.processor.RegisterRequestParameter;
+import org.teiid.query.processor.proc.CreateCursorResultSetInstruction.Mode;
import org.teiid.query.processor.relational.SubqueryAwareEvaluator;
import org.teiid.query.resolver.command.UpdateProcedureResolver;
import org.teiid.query.sql.ProcedureReservedWords;
@@ -93,6 +95,13 @@
TupleBuffer resultsBuffer;
}
+ static ElementSymbol ROWCOUNT =
+ new ElementSymbol(ProcedureReservedWords.VARIABLES+"."+ProcedureReservedWords.ROWCOUNT); //$NON-NLS-1$
+
+ static {
+ ROWCOUNT.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ }
+
private Program originalProgram;
// State initialized by processor
@@ -113,18 +122,11 @@
private List<ElementSymbol> outParams;
private QueryMetadataInterface metadata;
- private Map<String, CursorState> cursorStates = new HashMap<String, CursorState>();
+ private Map<String, CursorState> cursorStates = new TreeMap<String, CursorState>(StringUtil.NULL_SAFE_CASE_INSENSITIVE_ORDER);
- static ElementSymbol ROWCOUNT =
- new ElementSymbol(ProcedureReservedWords.VARIABLES+"."+ProcedureReservedWords.ROWCOUNT); //$NON-NLS-1$
-
- static {
- ROWCOUNT.setType(DataTypeManager.DefaultDataClasses.INTEGER);
- }
-
private VariableContext currentVarContext;
- private TupleSource lastTupleSource;
+ private CursorState last;
private List outputElements;
@@ -202,11 +204,10 @@
evaluatedParams = false;
cursorStates.clear();
createVariableContext();
- lastTupleSource = null;
+ last = null;
done = false;
currentState = null;
-
finalTupleSource = null;
beginBatch = 1;
batchRows = null;
@@ -377,20 +378,16 @@
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "Executing instruction", inst); //$NON-NLS-1$
inst.process(this);
}
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (TeiidComponentException e) {
+ throw e;
} catch (Exception e) {
- if (e instanceof BlockedException) {
- throw (BlockedException)e;
- }
+ //processing or teiidsqlexception
while (program.getExceptionGroup() == null) {
this.pop(false);
if (this.programs.empty()) {
//reached the top without a handler, so throw
- if (e instanceof RuntimeException) {
- throw (RuntimeException)e;
- }
- if (e instanceof TeiidComponentException) {
- throw (TeiidComponentException)e;
- }
if (e instanceof TeiidProcessingException) {
throw (TeiidProcessingException)e;
}
@@ -398,7 +395,6 @@
}
program = peek();
}
- //assign variables
if (program.getExceptionProgram() == null) {
this.pop(true);
continue;
@@ -419,10 +415,10 @@
program.incrementProgramCounter();
}
- if(lastTupleSource == null){
+ if(last == null){
return CollectionTupleSource.createNullTupleSource();
}
- return lastTupleSource;
+ return last.ts;
}
private ElementSymbol exceptionSymbol(GroupSymbol gs, int pos) {
@@ -543,11 +539,16 @@
return this.currentVarContext;
}
- public void executePlan(ProcessorPlan command, String rsName, Map<ElementSymbol, ElementSymbol> procAssignments, boolean keepRs)
+ public void executePlan(ProcessorPlan command, String rsName, Map<ElementSymbol, ElementSymbol> procAssignments, CreateCursorResultSetInstruction.Mode mode)
throws TeiidComponentException, TeiidProcessingException {
- CursorState state = this.cursorStates.get(rsName.toUpperCase());
+ CursorState state = this.cursorStates.get(rsName);
if (state == null) {
+ if (this.currentState != null && this.currentState.processor.getProcessorPlan() != command) {
+ //sanity check for non-deterministic paths
+ removeState(this.currentState);
+ this.currentState = null;
+ }
if (this.currentState == null) {
//this may not be the first time the plan is being run
command.reset();
@@ -557,16 +558,17 @@
state = new CursorState();
state.processor = new QueryProcessor(command, subContext, this.bufferMgr, this.dataMgr);
state.ts = new BatchIterator(state.processor);
- if (procAssignments != null && state.processor.getOutputElements().size() - procAssignments.size() > 0) {
+ if (mode == Mode.HOLD && procAssignments != null && state.processor.getOutputElements().size() - procAssignments.size() > 0) {
state.resultsBuffer = bufferMgr.createTupleBuffer(state.processor.getOutputElements().subList(0, state.processor.getOutputElements().size() - procAssignments.size()), getContext().getConnectionId(), TupleSourceType.PROCESSOR);
- } else if (this.blockContext != null) {
+ } else if ((this.blockContext != null || this.programs.peek().isTrappingExceptions()) && (mode == Mode.HOLD || rsName != null)) {
state.resultsBuffer = bufferMgr.createTupleBuffer(state.processor.getOutputElements(), getContext().getConnectionId(), TupleSourceType.PROCESSOR);
}
this.currentState = state;
}
- //force execution to the first batch
+ //force execution to the first batch to ensure that the plan is executed in the context of the procedure
this.currentState.ts.hasNext();
if (procAssignments != null) {
+ //proc assignments force us to scroll through the entire results and save as we go
while (this.currentState.ts.hasNext()) {
if (this.currentState.currentRow != null && this.currentState.resultsBuffer != null) {
this.currentState.resultsBuffer.addTuple(this.currentState.currentRow.subList(0, this.currentState.resultsBuffer.getSchema().size()));
@@ -583,28 +585,49 @@
int index = this.currentState.processor.getOutputElements().indexOf(entry.getKey());
getCurrentVariableContext().setValue(entry.getValue(), DataTypeManager.transformValue(this.currentState.currentRow.get(index), entry.getValue().getType()));
}
- //no resultset
- if (this.currentState.resultsBuffer == null) {
- this.currentState.processor.closeProcessing();
- this.currentState = null;
- return;
- }
- this.currentState.resultsBuffer.close();
- this.currentState.ts = this.currentState.resultsBuffer.createIndexedTupleSource();
- } else if (this.blockContext != null) {
- //process fully in a block transaction
+ } else if (this.currentState.resultsBuffer != null) {
+ //result should be saved, typically to respect txn semantics
while (this.currentState.ts.hasNext()) {
List<?> tuple = this.currentState.ts.nextTuple();
this.currentState.resultsBuffer.addTuple(tuple);
+ }
+ } else if (mode == Mode.UPDATE) {
+ List<?> t = this.currentState.ts.nextTuple();
+ if (this.currentState.ts.hasNext()) {
+ throw new AssertionError("Invalid update count result - more than 1 row returned"); //$NON-NLS-1$
+ }
+ removeState(this.currentState);
+ this.currentState = null;
+ int rowCount = 0;
+ if (t != null) {
+ rowCount = (Integer)t.get(0);
+ }
+ getCurrentVariableContext().setValue(ProcedurePlan.ROWCOUNT, rowCount);
+ return;
+ }
+ if (rsName == null && mode == Mode.NOHOLD) {
+ //unnamed without hold
+ //process fully, but don't save
+ //TODO: could set the rowcount in this case
+ while (this.currentState.ts.hasNext()) {
+ this.currentState.ts.nextTuple();
}
+ this.currentState = null;
+ return;
+ }
+ if (this.currentState.resultsBuffer != null) {
+ //close the results buffer and use a buffer backed tuplesource
this.currentState.resultsBuffer.close();
- this.currentState.ts = this.currentState.resultsBuffer.createIndexedTupleSource();
- }
- this.cursorStates.put(rsName.toUpperCase(), this.currentState);
+ this.currentState.ts = this.currentState.resultsBuffer.createIndexedTupleSource(true);
+ }
+ CursorState old = this.cursorStates.put(rsName, this.currentState);
+ if (old != null) {
+ removeState(old);
+ }
//keep a reference to the tuple source
//it may be the last one
- if (keepRs) {
- this.lastTupleSource = this.currentState.ts;
+ if (mode == Mode.HOLD) {
+ this.last = this.currentState;
}
this.currentState = null;
}
@@ -647,6 +670,7 @@
public void push(Program program) throws XATransactionException {
program.reset(this.getContext().getConnectionId());
+ program.setTrappingExceptions(program.getExceptionGroup() != null || (!this.programs.isEmpty() && this.programs.peek().isTrappingExceptions()));
TempTableStore tts = getTempTableStore();
getContext().setTempTableStore(program.getTempTableStore());
program.getTempTableStore().setParentTempTableStore(tts);
@@ -680,15 +704,13 @@
}
public List<?> getCurrentRow(String rsName) throws TeiidComponentException {
- return getCursorState(rsName.toUpperCase()).currentRow;
+ return getCursorState(rsName).currentRow;
}
public boolean iterateCursor(String rsName)
throws TeiidComponentException, TeiidProcessingException {
- String rsKey = rsName.toUpperCase();
-
- CursorState state = getCursorState(rsKey);
+ CursorState state = getCursorState(rsName);
state.currentRow = state.ts.nextTuple();
return (state.currentRow != null);
@@ -703,15 +725,21 @@
}
public void removeResults(String rsName) {
- String rsKey = rsName.toUpperCase();
- CursorState state = this.cursorStates.remove(rsKey);
- if (state != null) {
+ CursorState state = this.cursorStates.remove(rsName);
+ removeState(state);
+ }
+
+ private void removeState(CursorState state) {
+ if (state != null) {
state.processor.closeProcessing();
if (state.resultsBuffer != null) {
state.resultsBuffer.remove();
}
}
- }
+ if (state == last) {
+ last = null;
+ }
+ }
/**
* Get the schema from the tuple source that
@@ -721,20 +749,14 @@
* @throws QueryProcessorException if the list of elements is null
*/
public List getSchema(String rsName) throws TeiidComponentException {
-
- // get the tuple source
- String rsKey = rsName.toUpperCase();
-
- CursorState cursorState = getCursorState(rsKey);
+ CursorState cursorState = getCursorState(rsName);
// get the schema from the tuple source
List schema = cursorState.processor.getOutputElements();
return schema;
}
public boolean resultSetExists(String rsName) {
- String rsKey = rsName.toUpperCase();
- boolean exists = this.cursorStates.containsKey(rsKey);
- return exists;
+ return this.cursorStates.containsKey(rsName);
}
public CommandContext getContext() {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -46,6 +46,7 @@
private boolean startedTxn;
private String exceptionGroup;
private Program exceptionProgram;
+ private boolean trappingExceptions = false;
/**
* Constructor for Program.
@@ -117,6 +118,7 @@
counter = 0;
this.tempTables = new TempTableStore(sessionId, TransactionMode.ISOLATE_WRITES);
this.startedTxn = false;
+ this.trappingExceptions = false;
}
int getProgramCounter(){
@@ -283,5 +285,13 @@
public Program getExceptionProgram() {
return exceptionProgram;
}
+
+ public boolean isTrappingExceptions() {
+ return trappingExceptions;
+ }
+
+ public void setTrappingExceptions(boolean trappingExceptions) {
+ this.trappingExceptions = trappingExceptions;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.teiid.api.exception.query.QueryMetadataException;
@@ -270,7 +271,6 @@
} else if (currentCommand instanceof CreateProcedureCommand) {
CreateProcedureCommand cupc = (CreateProcedureCommand)currentCommand;
cupc.setVirtualGroup(container);
-
if (type == Command.TYPE_STORED_PROCEDURE) {
StoredProcedureInfo info = metadata.getStoredProcedureInfoForProcedure(container.getName());
// Create temporary metadata that defines a group based on either the stored proc
@@ -281,15 +281,22 @@
List<ElementSymbol> tempElements = new ArrayList<ElementSymbol>(info.getParameters().size());
boolean[] updatable = new boolean[info.getParameters().size()];
int i = 0;
+ List<ElementSymbol> rsColumns = Collections.emptyList();
for (SPParameter param : info.getParameters()) {
if(param.getParameterType() != ParameterInfo.RESULT_SET) {
ElementSymbol symbol = param.getParameterSymbol();
tempElements.add(symbol);
updatable[i++] = param.getParameterType() != ParameterInfo.IN;
+ } else {
+ rsColumns = param.getResultSetColumns();
}
}
-
ProcedureContainerResolver.addScalarGroup(procName, childMetadata, externalGroups, tempElements, updatable);
+ cupc.setResultSetColumns(rsColumns);
+ //the relational planner will override this with the appropriate value
+ cupc.setProjectedSymbols(rsColumns);
+ } else {
+ cupc.setUpdateType(type);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -59,7 +59,6 @@
import org.teiid.query.sql.lang.SubqueryContainer;
import org.teiid.query.sql.lang.UnaryFromClause;
import org.teiid.query.sql.navigator.DeepPostOrderNavigator;
-import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.symbol.AliasSymbol;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -103,14 +102,6 @@
if (command == null) {
return null;
}
- if (command instanceof CreateProcedureCommand) {
- CreateProcedureCommand cupCommand = (CreateProcedureCommand)command;
- cupCommand.setUserCommand(proc);
- //if the subcommand is virtual stored procedure, it must have the same
- //projected symbol as its parent.
- cupCommand.setProjectedSymbols(proc.getProjectedSymbols());
- cupCommand.setResultSetColumns(proc.getResultSetColumns());
- }
resolveCommand(command, proc.getGroup(), proc.getType(), metadata.getDesignTimeMetadata());
return command;
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -22,7 +22,6 @@
package org.teiid.query.resolver.command;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
@@ -67,11 +66,6 @@
*/
public class UpdateProcedureResolver implements CommandResolver {
- public static class StatementNode {
- CommandStatement cs;
- List<StatementNode> children;
- }
-
public static final List<ElementSymbol> exceptionGroup;
static {
ElementSymbol es1 = new ElementSymbol("STATE"); //$NON-NLS-1$
@@ -95,7 +89,11 @@
if (command instanceof TriggerAction) {
TriggerAction ta = (TriggerAction)command;
- resolveBlock(new CreateProcedureCommand(), ta.getBlock(), ta.getExternalGroupContexts(), metadata, null);
+ CreateProcedureCommand cmd = new CreateProcedureCommand(ta.getBlock());
+ cmd.setVirtualGroup(ta.getView());
+ //TODO: this is not generally correct - we should update the api to set the appropriate type
+ cmd.setUpdateType(Command.TYPE_INSERT);
+ resolveBlock(cmd, ta.getBlock(), ta.getExternalGroupContexts(), metadata);
return;
}
@@ -112,41 +110,11 @@
symbols.add(updateCount);
ProcedureContainerResolver.addScalarGroup(ProcedureReservedWords.VARIABLES, metadata.getMetadataStore(), externalGroups, symbols);
- StatementNode sn = new StatementNode();
- resolveBlock(procCommand, procCommand.getBlock(), externalGroups, metadata, sn);
-
- //validate the possible returned resultsets
- if (procCommand.getResultSetColumns() == null || !procCommand.getResultSetColumns().isEmpty()) {
- setReturnable(procCommand, sn);
- }
+ resolveBlock(procCommand, procCommand.getBlock(), externalGroups, metadata);
}
- private void setReturnable(CreateProcedureCommand procCommand, StatementNode sn) {
- if (sn.cs != null) {
- sn.cs.setReturnable(true);
- //this logic is for designer, which want's to populate a resultset from the proc text
- if (procCommand.getResultSetColumns() == null) {
- List<? extends Expression> symbols = sn.cs.getCommand().getProjectedSymbols();
- if (sn.cs.getCommand() instanceof StoredProcedure) {
- StoredProcedure sp = (StoredProcedure)sn.cs.getCommand();
- if (sp.isCallableStatement()) {
- symbols = sp.getResultSetColumns();
- }
- }
- procCommand.setResultSetColumns(symbols);
- //TODO: what about out parameters
- procCommand.setProjectedSymbols(symbols);
- }
- }
- if (sn.children != null) {
- for (StatementNode child : sn.children) {
- setReturnable(procCommand, child);
- }
- }
- }
-
public void resolveBlock(CreateProcedureCommand command, Block block, GroupContext externalGroups,
- TempMetadataAdapter metadata, org.teiid.query.resolver.command.UpdateProcedureResolver.StatementNode sn)
+ TempMetadataAdapter metadata)
throws QueryResolverException, QueryMetadataException, TeiidComponentException {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving block", block}); //$NON-NLS-1$
@@ -159,7 +127,7 @@
GroupSymbol variables = ProcedureContainerResolver.addScalarGroup(ProcedureReservedWords.VARIABLES, store, externalGroups, new LinkedList<Expression>());
for (Statement statement : block.getStatements()) {
- resolveStatement(command, statement, externalGroups, variables, metadata, sn);
+ resolveStatement(command, statement, externalGroups, variables, metadata);
}
if (block.getExceptionGroup() != null) {
@@ -175,13 +143,13 @@
if (block.getExceptionStatements() != null) {
ProcedureContainerResolver.addScalarGroup(block.getExceptionGroup(), store, externalGroups, exceptionGroup, false);
for (Statement statement : block.getExceptionStatements()) {
- resolveStatement(command, statement, externalGroups, variables, metadata, sn);
+ resolveStatement(command, statement, externalGroups, variables, metadata);
}
}
}
}
- private void resolveStatement(CreateProcedureCommand command, Statement statement, GroupContext externalGroups, GroupSymbol variables, TempMetadataAdapter metadata, StatementNode sn)
+ private void resolveStatement(CreateProcedureCommand command, Statement statement, GroupContext externalGroups, GroupSymbol variables, TempMetadataAdapter metadata)
throws QueryResolverException, QueryMetadataException, TeiidComponentException {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving statement", statement}); //$NON-NLS-1$
@@ -193,9 +161,9 @@
resolveEmbeddedCommand(metadata, externalGroups, container.getCommand());
}
ResolverVisitor.resolveLanguageObject(ifCrit, null, externalGroups, metadata);
- resolveBlock(command, ifStmt.getIfBlock(), externalGroups, metadata, pushChild(sn));
+ resolveBlock(command, ifStmt.getIfBlock(), externalGroups, metadata);
if(ifStmt.hasElseBlock()) {
- resolveBlock(command, ifStmt.getElseBlock(), externalGroups, metadata, pushChild(sn));
+ resolveBlock(command, ifStmt.getElseBlock(), externalGroups, metadata);
}
break;
case Statement.TYPE_COMMAND:
@@ -234,15 +202,19 @@
DynamicCommand dynCommand = (DynamicCommand)subCommand;
if(dynCommand.getIntoGroup() == null
- && !dynCommand.isAsClauseSet() && !command.getProjectedSymbols().isEmpty()) {
- dynCommand.setAsColumns(command.getProjectedSymbols());
+ && !dynCommand.isAsClauseSet()) {
+ if ((command.getResultSetColumns() != null && command.getResultSetColumns().isEmpty()) || !cmdStmt.isReturnable()) {
+ //we're not interested in the resultset
+ dynCommand.setAsColumns(Collections.EMPTY_LIST);
+ } else {
+ //should match the procedure
+ dynCommand.setAsColumns(command.getResultSetColumns());
+ }
}
}
-
- //this could be the last select statement, set the projected symbol
- //on the virtual procedure command
- if (subCommand.returnsResultSet() && sn != null) {
- clearReturnableStatement(sn, cmdStmt);
+
+ if (command.getResultSetColumns() == null && cmdStmt.isReturnable() && subCommand.returnsResultSet() && !subCommand.getResultSetColumns().isEmpty()) {
+ command.setResultSetColumns(subCommand.getResultSetColumns());
}
break;
@@ -283,9 +255,6 @@
exprStmt.setExpression(ResolverUtil.convertExpression(exprStmt.getExpression(), varTypeName, metadata));
if (statement.getType() == Statement.TYPE_ERROR) {
ResolverVisitor.checkException(exprStmt.getExpression());
- if (!((RaiseStatement)statement).isWarning()) {
- clearReturnableStatement(sn, null);
- }
}
}
break;
@@ -296,7 +265,7 @@
resolveEmbeddedCommand(metadata, externalGroups, container.getCommand());
}
ResolverVisitor.resolveLanguageObject(whileCrit, null, externalGroups, metadata);
- resolveBlock(command, whileStmt.getBlock(), externalGroups, metadata, pushChild(sn));
+ resolveBlock(command, whileStmt.getBlock(), externalGroups, metadata);
break;
case Statement.TYPE_LOOP:
LoopStatement loopStmt = (LoopStatement) statement;
@@ -314,24 +283,14 @@
ProcedureContainerResolver.addScalarGroup(groupName, store, externalGroups, symbols, false);
- resolveBlock(command, loopStmt.getBlock(), externalGroups, metadata, pushChild(sn));
+ resolveBlock(command, loopStmt.getBlock(), externalGroups, metadata);
break;
case Statement.TYPE_COMPOUND:
- resolveBlock(command, (Block)statement, externalGroups, metadata, sn);
+ resolveBlock(command, (Block)statement, externalGroups, metadata);
break;
}
}
- private void clearReturnableStatement(StatementNode sn,
- CommandStatement cmdStmt) {
- updateDynamicAs(sn);
-
- sn.cs = cmdStmt;
- if (sn.children != null) {
- sn.children.clear();
- }
- }
-
private void isValidGroup(TempMetadataAdapter metadata, String groupName)
throws QueryResolverException {
if (metadata.getMetadataStore().getTempGroupID(groupName) != null) {
@@ -344,32 +303,6 @@
}
}
- private void updateDynamicAs(StatementNode sn) {
- if (sn.cs != null && sn.cs.getCommand().getType() == Command.TYPE_DYNAMIC) {
- DynamicCommand dynamicCommand = (DynamicCommand)sn.cs.getCommand();
- if (!dynamicCommand.isAsClauseSet()) {
- dynamicCommand.setAsColumns(Collections.EMPTY_LIST);
- }
- }
- if (sn.children != null) {
- for (StatementNode child : sn.children) {
- updateDynamicAs(child);
- }
- }
- }
-
- private StatementNode pushChild(StatementNode sn) {
- if (sn != null) {
- if (sn.children == null) {
- sn.children = new ArrayList<StatementNode>();
- }
- StatementNode child = new StatementNode();
- sn.children.add(child);
- sn = child;
- }
- return sn;
- }
-
private boolean isAssignable(TempMetadataAdapter metadata, SPParameter param)
throws TeiidComponentException, QueryMetadataException {
if (!(param.getExpression() instanceof ElementSymbol)) {
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -232,15 +232,13 @@
return command;
}
- private Command rewriteUpdateProcedure(CreateProcedureCommand command)
- throws TeiidComponentException, TeiidProcessingException{
+ private Command rewriteUpdateProcedure(CreateProcedureCommand command) throws TeiidComponentException {
Block block = rewriteBlock(command.getBlock());
command.setBlock(block);
return command;
}
- private Block rewriteBlock(Block block)
- throws TeiidComponentException, TeiidProcessingException{
+ private Block rewriteBlock(Block block) throws TeiidComponentException {
List<Statement> statements = block.getStatements();
List<Statement> newStmts = rewriteStatements(statements);
block.setStatements(newStmts);
@@ -250,15 +248,23 @@
return block;
}
- private List<Statement> rewriteStatements(List<Statement> statements)
- throws TeiidComponentException, TeiidProcessingException {
+ private List<Statement> rewriteStatements(List<Statement> statements) throws TeiidComponentException {
Iterator<Statement> stmtIter = statements.iterator();
List<Statement> newStmts = new ArrayList<Statement>(statements.size());
// plan each statement in the block
while(stmtIter.hasNext()) {
Statement stmnt = stmtIter.next();
- rewriteStatement(stmnt, newStmts);
+ try {
+ rewriteStatement(stmnt, newStmts);
+ } catch (TeiidProcessingException e) {
+ /*
+ * defer the processing of the exception until runtime as there may be an exception handler
+ */
+ RaiseStatement raise = new RaiseStatement(new Constant(e));
+ newStmts.add(raise);
+ break;
+ }
}
return newStmts;
}
@@ -343,9 +349,7 @@
crit = rewriteCriteria(crit);
whileStatement.setCondition(crit);
- if(crit.equals(TRUE_CRITERIA)) {
- throw new QueryValidatorException(QueryPlugin.Event.TEIID30367, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30367));
- } else if(crit.equals(FALSE_CRITERIA) || crit.equals(UNKNOWN_CRITERIA)) {
+ if(crit.equals(FALSE_CRITERIA) || crit.equals(UNKNOWN_CRITERIA)) {
return;
}
whileStatement.setBlock(rewriteBlock(whileStatement.getBlock()));
@@ -354,6 +358,9 @@
return;
}
break;
+ case Statement.TYPE_COMPOUND:
+ statement = rewriteBlock((Block) statement);
+ break;
}
newStmts.add(statement);
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -102,30 +102,15 @@
public String toString() {
StringBuffer val = new StringBuffer("BatchedUpdate{"); //$NON-NLS-1$
if (commands != null && commands.size() > 0) {
- val.append(getCommandToken(commands.get(0)));
+ val.append(getCommandToken(commands.get(0).getType()));
for (int i = 1; i < commands.size(); i++) {
- val.append(',').append(getCommandToken(commands.get(i)));
+ val.append(',').append(getCommandToken(commands.get(i).getType()));
}
}
val.append('}');
return val.toString();
}
- private char getCommandToken(Command command) {
- int commandType = command.getType();
- if (commandType == Command.TYPE_INSERT) {
- return 'I';
- } else if (commandType == Command.TYPE_UPDATE) {
- return 'U';
- } else if (commandType == Command.TYPE_DELETE) {
- return 'D';
- } else if (commandType == Command.TYPE_QUERY) {
- // SELECT INTO command
- return 'S';
- }
- return '?';
- }
-
public void setVariableContexts(List<VariableContext> variableContexts) {
this.variableContexts = variableContexts;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -75,11 +75,6 @@
public static final int TYPE_DELETE = 4;
/**
- * Represents any SQL statement, wrapped as a string
- */
- public static final int TYPE_SQL = 5;
-
- /**
* Represents a stored procedure command
*/
public static final int TYPE_STORED_PROCEDURE = 6;
@@ -349,4 +344,46 @@
public boolean returnsResultSet() {
return false;
}
+
+ /**
+ * @return null if unknown, empty if results are not returned, or the resultset columns
+ */
+ public List<? extends Expression> getResultSetColumns() {
+ if (returnsResultSet()) {
+ return getProjectedSymbols();
+ }
+ return Collections.emptyList();
+ }
+
+ //TODO: replace with enum
+ public static String getCommandToken(int commandType) {
+ switch (commandType) {
+ case Command.TYPE_INSERT:
+ return "I"; //$NON-NLS-1$
+ case Command.TYPE_UPDATE:
+ return "U"; //$NON-NLS-1$
+ case Command.TYPE_DELETE:
+ return "D"; //$NON-NLS-1$
+ case Command.TYPE_DROP:
+ return "DT"; //$NON-NLS-1$
+ case Command.TYPE_ALTER_PROC:
+ return "AP"; //$NON-NLS-1$
+ case Command.TYPE_ALTER_TRIGGER:
+ return "AT"; //$NON-NLS-1$
+ case Command.TYPE_ALTER_VIEW:
+ return "AV"; //$NON-NLS-1$
+ case Command.TYPE_CREATE:
+ return "CT"; //$NON-NLS-1$
+ case Command.TYPE_DYNAMIC:
+ return "Dy"; //$NON-NLS-1$
+ case Command.TYPE_QUERY:
+ return "S"; //$NON-NLS-1$
+ case Command.TYPE_STORED_PROCEDURE:
+ return "Sp"; //$NON-NLS-1$
+ case Command.TYPE_UPDATE_PROCEDURE:
+ return "Up"; //$NON-NLS-1$
+ }
+ return "?"; //$NON-NLS-1$
+ }
+
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -260,5 +260,14 @@
public boolean returnsResultSet() {
return intoGroup == null;
}
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<? extends Expression> getResultSetColumns() {
+ if (returnsResultSet()) {
+ return asColumns;
+ }
+ return Collections.emptyList();
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -22,8 +22,6 @@
package org.teiid.query.sql.lang;
-import java.util.List;
-
import org.teiid.query.validator.UpdateValidator.UpdateInfo;
@@ -66,9 +64,5 @@
public void setUpdateInfo(UpdateInfo updateInfo) {
this.updateInfo = updateInfo;
}
-
- public List getResultSetColumns() {
- return getProjectedSymbols();
- }
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/CommandStatement.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/proc/CommandStatement.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/CommandStatement.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -37,7 +37,7 @@
// the command this statement represents
Command command;
- private boolean returnable;
+ private boolean returnable = true;
/**
* Constructor for CommandStatement.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -46,15 +46,12 @@
// top level block for the procedure
private Block block;
- // the command the user submitted against the virtual group being updated
- private Command userCommand;
-
private List projectedSymbols;
- private List resultSetColumns;
+ private List<? extends Expression> resultSetColumns;
private GroupSymbol virtualGroup;
- private String updateType;
+ private int updateType = Command.TYPE_UNKNOWN;
/**
* Constructor for CreateUpdateProcedureCommand.
@@ -96,22 +93,6 @@
this.block = block;
}
- /**
- * Set the user's command to which this obj which is the subcommand
- * @param command The user's command
- */
- public void setUserCommand(Command command) {
- this.userCommand = command;
- }
-
- /**
- * Get the user's command to which this obj which is the subcommand
- * @return The user's command
- */
- public Command getUserCommand() {
- return this.userCommand;
- }
-
// =========================================================================
// P R O C E S S I N G M E T H O D S
// =========================================================================
@@ -207,11 +188,11 @@
return Collections.EMPTY_LIST;
}
- public List getResultSetColumns() {
+ public List<? extends Expression> getResultSetColumns() {
return resultSetColumns;
}
- public void setResultSetColumns(List resultSetColumns) {
+ public void setResultSetColumns(List<? extends Expression> resultSetColumns) {
this.resultSetColumns = resultSetColumns;
}
@@ -237,11 +218,12 @@
this.virtualGroup = virtualGroup;
}
- public void setUpdateType(String updateType) {
- this.updateType = updateType;
+ public void setUpdateType(int type) {
+ this.resultSetColumns = Collections.emptyList();
+ this.updateType = type;
}
- public String getUpdateType() {
+ public int getUpdateType() {
return updateType;
}
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 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -47,7 +47,6 @@
import org.teiid.query.sql.lang.TextTable.TextColumn;
import org.teiid.query.sql.lang.XMLTable.XMLColumn;
import org.teiid.query.sql.proc.*;
-import org.teiid.query.sql.proc.BranchingStatement.BranchingMode;
import org.teiid.query.sql.proc.Statement.Labeled;
import org.teiid.query.sql.symbol.*;
import org.teiid.query.sql.symbol.AggregateSymbol.Type;
@@ -1418,6 +1417,12 @@
public void visit( CommandStatement obj ) {
visitNode(obj.getCommand());
+ if (!obj.isReturnable()) {
+ append(SPACE);
+ append(WITHOUT);
+ append(SPACE);
+ append(RETURN);
+ }
append(";"); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -408,11 +408,14 @@
public void visit(CreateProcedureCommand obj) {
//check that the procedure does not contain references to itself
- if (obj.getUpdateType() == null) {
+ if (obj.getUpdateType() == Command.TYPE_UNKNOWN) {
if (GroupCollectorVisitor.getGroups(obj,true).contains(obj.getVirtualGroup())) {
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.Procedure_has_group_self_reference"),obj); //$NON-NLS-1$
}
- this.createProc = obj;
+ if (obj.getResultSetColumns() != null) {
+ //some unit tests bypass setting the columns
+ this.createProc = obj;
+ }
}
}
@@ -1471,20 +1474,20 @@
@Override
public void visit(CommandStatement obj) {
- if (obj.isReturnable() && this.createProc != null) {
- List<? extends Expression> symbols = obj.getCommand().getProjectedSymbols();
- if (obj.getCommand() instanceof StoredProcedure) {
- StoredProcedure sp = (StoredProcedure)obj.getCommand();
- if (sp.isCallableStatement()) {
- symbols = sp.getResultSetColumns();
- }
- }
- try {
- QueryResolver.validateProjectedSymbols(createProc.getVirtualGroup(), createProc.getResultSetColumns(), symbols);
- } catch (QueryValidatorException e) {
- handleValidationError(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31121, createProc.getVirtualGroup(), obj, e.getMessage()), obj);
- }
+ if (this.createProc == null || this.createProc.getResultSetColumns().isEmpty() || !obj.isReturnable() || !obj.getCommand().returnsResultSet()) {
+ return;
}
+ List<? extends Expression> symbols = obj.getCommand().getResultSetColumns();
+ if (symbols == null && obj.getCommand() instanceof DynamicCommand) {
+ DynamicCommand cmd = (DynamicCommand)obj.getCommand();
+ cmd.setAsColumns(this.createProc.getResultSetColumns());
+ return;
+ }
+ try {
+ QueryResolver.validateProjectedSymbols(createProc.getVirtualGroup(), createProc.getResultSetColumns(), symbols);
+ } catch (QueryValidatorException e) {
+ handleValidationError(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31121, createProc.getVirtualGroup(), obj, e.getMessage()), obj);
+ }
}
@Override
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2012-09-26 23:15:59 UTC (rev 4475)
@@ -906,7 +906,7 @@
/*
name=raise statement
description=Raises an error or warning with the given message.
-example={code:sql}RAISE SQLEXCEPTION '00A' 'something went wrong'{code}
+example={code:sql}RAISE SQLEXCEPTION 'something went wrong'{code}
*/
RaiseStatement raiseStatement(ParseInfo info) :
{
@@ -1187,7 +1187,7 @@
{
variableID = new ElementSymbol(var);
}
- [[<COLON>]<EQ>
+ [<EQ>
value = assignStatementOperand(info)
]
@@ -1205,28 +1205,31 @@
/*
name=assignment statement
description=Assigns a variable a value in a procedure.
-example={code:sql}x := 'b'{code}
+example={code:sql}x = 'b'{code}
*/
Statement assignStatement(ParseInfo info) :
{
LanguageObject value = null;
String var = null;
ElementSymbol elementID = null;
+ boolean returnable=true;
}
{
var = id()
{
elementID = new ElementSymbol(var);
}
- [<COLON>]<EQ>
+ <EQ>
(value = assignStatementOperand(info) |
- value = storedProcedure(info, 2) {
+ (value = storedProcedure(info, 2) [(<WITH>|<WITHOUT> {returnable = false;}) <RETURN>]) {
StoredProcedure storedProcedure = (StoredProcedure)value;
SPParameter parameter = new SPParameter(1, SPParameter.RETURN_VALUE, "return"); //$NON-NLS-1$
parameter.setExpression(elementID);
storedProcedure.setParameter(parameter);
- storedProcedure.setCalledWithReturn(true);
- return new CommandStatement(storedProcedure);
+ storedProcedure.setCalledWithReturn(true);
+ CommandStatement cs = new CommandStatement(storedProcedure);
+ cs.setReturnable(returnable);
+ return cs;
}
)
@@ -1265,7 +1268,7 @@
/*
name=data statement
-description=A procedure statement that executes a SQL statement. An update statement can have its update count accessed via the ROWS_UPDATED variable.
+description=A procedure statement that executes a SQL statement. An update statement can have its update count accessed via the ROWCOUNT variable.
*/
CommandStatement sqlStatement(ParseInfo info) :
{
@@ -1273,14 +1276,17 @@
String var = null;
ElementSymbol elementID = null;
StoredProcedure storedProcedure = null;
+ boolean returnable = true;
}
{
(LOOKAHEAD(2) cmd = userCommand(info) |
cmd = dynamicCommand(info)
- )
+ ) [(<WITH>|<WITHOUT> {returnable = false;}) <RETURN>]
{
- return new CommandStatement(cmd);
+ CommandStatement cs = new CommandStatement(cmd);
+ cs.setReturnable(returnable);
+ return cs;
}
}
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-09-26 23:15:59 UTC (rev 4475)
@@ -752,8 +752,6 @@
XMLQuery.resolvingError=Failed to resolve the query ''{0}''
TEIID30085=Invalid order by at {0}
-TEIID30367=Infinite loop detected, procedure will not be executed.
-
TEIID30244=The batch contained an unrecognized command: {0}
TEIID30272=Error getting modelID
TEIID30213=Cannot find namespace URI for namespace {0} of element {1}
@@ -1032,7 +1030,8 @@
TEIID31115=Function based index {1} expression {0} is not deterministic.
TEIID31116=Function based index {1} expression {0} could not be resolved: {2}
TEIID31120=An exception may only be chained to another exception. {0} is not valid.
-TEIID31121=The expected result set of the procedure {0} does not match the result set from returnable statement {1} - {2}
+TEIID31121=The expected result set of the procedure {0} does not match the result set from returnable statement {1} use WITHOUT RETURN to indicate the statement should not be returned - {2}
+TEIID31122=Null exception reference.
SQLParser.proc_type_conflict=Result type {1} conflicts with return type {2} for procedure {0}
SQLParser.param_out=Procedure {0} RESULT param {1} must be of type OUT.
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTriggerActions.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTriggerActions.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTriggerActions.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -122,7 +122,7 @@
helpProcess(plan, context, dm, null);
fail();
} catch (QueryProcessingException e) {
- assertEquals("TEIID30168 Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'delete from gx where gx.x = new.x'\" with the SQL statement \"'delete from gx where gx.x = new.x'\" due to: TEIID30347 There is a recursive invocation of group 'Insert gx'. Please correct the SQL.", e.getMessage());
+ assertEquals("TEIID30168 Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'delete from gx where gx.x = new.x'\" with the SQL statement \"'delete from gx where gx.x = new.x'\" due to: TEIID30347 There is a recursive invocation of group 'I gx'. Please correct the SQL.", e.getMessage());
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcErrors.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcErrors.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcErrors.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -74,7 +74,20 @@
assertEquals("abc", tse.getSQLState());
assertEquals(1, tse.getErrorCode());
}
+ }
+
+ @Test public void testExceptionGroup() throws Exception {
+ String ddl =
+ "create virtual procedure vproc () returns string as begin select 1/0; exception e \"return\" = e.state || ' ' || e.errorcode || ' ' || e.teiidcode || ' ' || cast(e.exception as string) || ' ' || cast(e.chain as string); end;";
+ TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
+
+ String sql = "call vproc()"; //$NON-NLS-1$
+
+ ProcessorPlan plan = getProcedurePlan(sql, tm);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager(tm);
+ helpTestProcess(plan, new List[] {Arrays.asList("50000 30328 TEIID30328 org.teiid.jdbc.TeiidSQLException: TEIID30328 Unable to evaluate (1 / 0): TEIID30384 Error while evaluating function / org.teiid.api.exception.query.ExpressionEvaluationException: TEIID30328 Unable to evaluate (1 / 0): TEIID30384 Error while evaluating function /")}, dataManager, tm);
}
@Test public void testExceptionHandling() throws Exception {
@@ -99,5 +112,39 @@
assertEquals("caught", tse.getMessage());
assertEquals("hello world", tse.getCause().getMessage());
}
+
+ /**
+ * ensures that a processing error is trappable
+ */
+ @Test public void testExceptionHandlingWithResultSet() throws Exception {
+ String ddl =
+ "create virtual procedure proc2 (x integer) as begin atomic select 1; begin select 1/x; end exception e end;";
+ TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
+
+ String sql = "call proc2(0)"; //$NON-NLS-1$
+
+ ProcessorPlan plan = getProcedurePlan(sql, tm);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager(tm);
+
+ helpTestProcess(plan, new List[] {Arrays.asList(1)}, dataManager, tm);
+ }
+
+ /**
+ * ensures that the whole result is formed so that the error does not escape the handler
+ */
+ @Test public void testExceptionHandlingWithResultSet1() throws Exception {
+ String ddl =
+ "create virtual procedure proc2 (x integer) as begin create local temporary table t (i integer); insert into t (i) values (1); declare integer y = 0; while (y < 16) begin insert into t (i) select 1 from t; y = y+1; end insert into t (i) values (0); select cast(1/i as string) from t; exception e end;";
+ TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
+
+ String sql = "call proc2(0)"; //$NON-NLS-1$
+
+ ProcessorPlan plan = getProcedurePlan(sql, tm);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager(tm);
+
+ helpTestProcess(plan, new List[0], dataManager, tm);
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -930,7 +930,6 @@
helpTestProcess(plan, null, dataMgr, metadata);
fail("exception expected");
} catch (QueryProcessingException e) {
- assertTrue(e.getCause() instanceof QueryValidatorException);
}
}
@@ -2056,7 +2055,7 @@
}
@Test public void testNestedBlock() throws Exception {
- String ddl = "create virtual procedure proc (z STRING) returns table (x string, y string) as begin declare string x = z; select x; begin select x, x; end end;";
+ String ddl = "create virtual procedure proc (z STRING) returns table (x string, y string) as begin declare string x = z; select x without return; begin select x, x; end end;";
TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
String sql = "call proc('a')"; //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -38,7 +38,6 @@
import org.junit.Ignore;
import org.junit.Test;
import org.teiid.api.exception.query.QueryMetadataException;
-import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidComponentException;
@@ -1107,26 +1106,6 @@
helpTestRewriteCriteria("(pm1.g1.e1 = 1 and pm1.g1.e2 = 2) and (pm1.g1.e3 = 1 and pm1.g1.e4 = 2.0e0)", "(pm1.g1.e1 = '1') AND (pm1.g1.e2 = 2) AND (pm1.g1.e3 = TRUE) AND (pm1.g1.e4 = 2.0e0)"); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testRewriteWhile() throws Exception {
-
- String procedure = "FOR EACH ROW\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "while (1 = 1)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "Select vm1.g1.e1 from vm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userQuery = "Insert into vm1.g1 (e1, e2) values ('String', 1)"; //$NON-NLS-1$
-
- try {
- getRewritenProcedure(procedure, userQuery, Table.TriggerEvent.INSERT);
- fail("exception expected"); //$NON-NLS-1$
- } catch (QueryValidatorException e) {
- assertEquals("TEIID30367 Infinite loop detected, procedure will not be executed.", e.getMessage()); //$NON-NLS-1$
- }
- }
-
@Test public void testRewriteWhile1() throws Exception {
String procedure = "FOR EACH ROW\n"; //$NON-NLS-1$
@@ -1196,6 +1175,17 @@
String expected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nBEGIN ATOMIC\nSELECT e1 FROM pm1.g1;\nEND\nEND"; //$NON-NLS-1$
helpTestRewriteCommand(procedure1, expected);
+ }
+
+ @Test public void testExceptionHandling() {
+ String procedure1 = "CREATE virtual PROCEDURE begin "; //$NON-NLS-1$
+ procedure1 += "select 1/0;\n"; //$NON-NLS-1$
+ procedure1 += "exception e\n"; //$NON-NLS-1$
+ procedure1 += "end\n"; //$NON-NLS-1$
+
+ String expected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nRAISE 'org.teiid.api.exception.query.ExpressionEvaluationException: TEIID30328 Unable to evaluate (1 / 0): TEIID30384 Error while evaluating function /';\nEXCEPTION e\nEND"; //$NON-NLS-1$
+
+ helpTestRewriteCommand(procedure1, expected);
}
@Test public void testRewriteDeclare() {
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 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -1381,6 +1381,20 @@
helpTest(cmdStmt, "SELECT x FROM g;"); //$NON-NLS-1$
}
+ @Test public void testCommandStatement1a() {
+ Query q1 = new Query();
+ Select select = new Select();
+ select.addSymbol(new ElementSymbol("x")); //$NON-NLS-1$
+ q1.setSelect(select);
+ From from = new From();
+ from.addGroup(new GroupSymbol("g")); //$NON-NLS-1$
+ q1.setFrom(from);
+
+ CommandStatement cmdStmt = new CommandStatement(q1);
+ cmdStmt.setReturnable(false);
+ helpTest(cmdStmt, "SELECT x FROM g WITHOUT RETURN;"); //$NON-NLS-1$
+ }
+
@Test public void testCommandStatement2() {
Delete d1 = new Delete();
d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -301,7 +301,7 @@
ColumnSet<Procedure> vsprs7 = createResultSet("TEIIDSP7.vsprs1", new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
ProcedureParameter vsp7p1 = createParameter("p1", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
- QueryNode vspqn7 = new QueryNode("CREATE VIRTUAL PROCEDURE BEGIN declare integer x; x = exec spTest9(p1); declare integer y; exec spTest11(inkey=>x, outkey=>y); select convert(x, string) || y; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vspqn7 = new QueryNode("CREATE VIRTUAL PROCEDURE BEGIN declare integer x; x = exec spTest9(p1); declare integer y; exec spTest11(inkey=>x, outkey=>y) without return; select convert(x, string) || y; END"); //$NON-NLS-1$ //$NON-NLS-2$
Procedure vsp7 = createVirtualProcedure("TEIIDSP7", mmspTest1, Arrays.asList(vsp7p1), vspqn7); //$NON-NLS-1$
vsp7.setResultSet(vsprs7);
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestAlterValidation.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestAlterValidation.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestAlterValidation.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -46,7 +46,7 @@
@Test public void testValidateAlterProcedure() {
TestValidator.helpValidate("alter procedure spTest8a as begin select 1; end", new String[] {"spTest8a"}, RealMetadataFactory.exampleBQTCached());
- TestValidator.helpValidate("alter procedure MMSP1 as begin select 1; end", new String[] {"BEGIN\nSELECT 1;\nEND"}, RealMetadataFactory.exampleBQTCached());
+ TestValidator.helpValidate("alter procedure MMSP1 as begin select 1; end", new String[] {"SELECT 1;"}, RealMetadataFactory.exampleBQTCached());
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -1469,7 +1469,7 @@
.append("BEGIN\n") //$NON-NLS-1$
.append("CREATE LOCAL TEMPORARY TABLE x (column1 string);") //$NON-NLS-1$
.append("execute string 'SELECT e1 FROM pm1.g2' as e1 string INTO x;\n") //$NON-NLS-1$
- .append("select column1 from x;\n") //$NON-NLS-1$
+ .append("select cast(column1 as integer) from x;\n") //$NON-NLS-1$
.append("END\n"); //$NON-NLS-1$
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
Modified: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -265,6 +265,8 @@
protected boolean detectTransactions = true;
private Boolean running;
private EmbeddedConfiguration config;
+ private SessionAwareCache<CachedResults> rs;
+ private SessionAwareCache<PreparedPlan> ppc;
public EmbeddedServer() {
@@ -321,8 +323,8 @@
startVDBRepository();
- SessionAwareCache<CachedResults> rs = new SessionAwareCache<CachedResults>("resultset", config.getCacheFactory(), SessionAwareCache.Type.RESULTSET, config.getMaxResultSetCacheStaleness()); //$NON-NLS-1$
- SessionAwareCache<PreparedPlan> ppc = new SessionAwareCache<PreparedPlan>("preparedplan", config.getCacheFactory(), SessionAwareCache.Type.PREPAREDPLAN, 0); //$NON-NLS-1$
+ rs = new SessionAwareCache<CachedResults>("resultset", config.getCacheFactory(), SessionAwareCache.Type.RESULTSET, config.getMaxResultSetCacheStaleness()); //$NON-NLS-1$
+ ppc = new SessionAwareCache<PreparedPlan>("preparedplan", config.getCacheFactory(), SessionAwareCache.Type.PREPAREDPLAN, 0); //$NON-NLS-1$
rs.setTupleBufferCache(bs.getTupleBufferCache());
this.dqp.setResultsetCache(rs);
@@ -378,6 +380,8 @@
if (replicator != null) {
replicator.stop(vdb.getVDB().getAttachment(GlobalTableStore.class));
}
+ rs.clearForVDB(name, 1);
+ ppc.clearForVDB(name, 1);
}
@Override
@@ -500,6 +504,7 @@
}
public void undeployVDB(String vdbName) {
+ checkStarted();
this.repo.removeVDB(vdbName, 1);
}
Modified: trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -332,7 +332,8 @@
mmd1.setSchemaSourceType("ddl");
mmd1.setSchemaText("create view v as select 1; " +
"create virtual procedure proc () options (updatecount 2) as begin select * from v; end; " +
- "create virtual procedure proc1 () as begin atomic select * from v; end; ");
+ "create virtual procedure proc1 () as begin atomic select * from v; end; " +
+ "create virtual procedure proc2 (x integer) as begin atomic select 1; begin select 1/x; end exception e end;");
es.deployVDB("test", mmd1);
@@ -365,6 +366,14 @@
s.execute("set noexec on");
s.execute("select 1");
assertFalse(s.getResultSet().next());
+
+ s.execute("set autoCommitTxn off");
+ s.execute("set noexec off");
+ s.execute("call proc2(0)");
+ //verify that the block txn was committed because the exception was caught
+ assertEquals(1, tm.txnHistory.size());
+ txn = tm.txnHistory.remove(0);
+ Mockito.verify(txn).commit();
}
}
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -230,9 +230,10 @@
assertEquals(2, stats.objectsRead); // handshake response, logon,
assertEquals(1, stats.sockets);
conn.cleanUp();
+ assertEquals(1, this.service.getActiveSessionsCount());
helpEstablishConnection(false, config, p);
conn.selectServerInstance(false);
- assertEquals(2, this.service.getActiveSessions().size());
+ assertEquals(2, this.service.getActiveSessionsCount());
assertTrue(conn.isOpen(1000));
stats = listener.getStats();
assertEquals(7, stats.objectsRead); // ping (pool test), assert identity, ping (isOpen)
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -201,10 +201,6 @@
return this.repo.getLiveVDB(vdbName, 1);
}
- public void undeployVDB(String vdbName) {
- this.repo.removeVDB(vdbName, 1);
- }
-
public ConnectionImpl createConnection(String embeddedURL) throws Exception {
return getDriver().connect(embeddedURL, null);
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java 2012-09-26 17:05:51 UTC (rev 4474)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMetadataUpdates.java 2012-09-26 23:15:59 UTC (rev 4475)
@@ -29,7 +29,9 @@
import java.sql.SQLException;
import java.sql.Statement;
+import org.junit.After;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
@@ -45,15 +47,29 @@
@SuppressWarnings("nls")
public class TestMetadataUpdates {
- static Connection connection;
+ Connection connection;
static final String VDB = "metadata";
+
+ private static FakeServer server;
- @BeforeClass public static void setUp() throws Exception {
- FakeServer server = new FakeServer(true);
- server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/metadata.vdb", new DeployVDBParameter(null, getMetadataRepo()));
- connection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$ //$NON-NLS-2$
+ @BeforeClass public static void oneTimeSetUp() throws Exception {
+ server = new FakeServer(true);
}
+
+ @AfterClass public static void oneTimeTearDown() throws Exception {
+ server.stop();
+ }
+
+ @Before public void setup() throws Exception {
+ server.undeployVDB(VDB);
+ server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/metadata.vdb", new DeployVDBParameter(null, getMetadataRepo()));
+ connection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @After public void tearDown() throws SQLException {
+ connection.close();
+ }
private static DefaultMetadataRepository getMetadataRepo() {
DefaultMetadataRepository repo = Mockito.mock(DefaultMetadataRepository.class);
@@ -92,10 +108,6 @@
return repo;
}
- @AfterClass public static void tearDown() throws SQLException {
- connection.close();
- }
-
@Test public void testViewMetadataRepositoryMerge() throws Exception {
Statement s = connection.createStatement();
ResultSet rs = s.executeQuery("select * from vw");
@@ -152,7 +164,6 @@
assertEquals(2011, rs.getInt(1));
assertFalse(s.execute("alter procedure proc as begin select '2012'; end"));
-
//the sleep is needed to ensure that the plan is invalidated
Thread.sleep(100);
12 years, 3 months
teiid SVN: r4474 - in trunk: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc and 6 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-09-26 13:05:51 -0400 (Wed, 26 Sep 2012)
New Revision: 4474
Added:
trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPQLDirectQueryExecution.java
trunk/connectors/translator-jpa/src/test/java/org/teiid/translator/jpa/TestJPADirectQueryExecution.java
Modified:
trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java
trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPA2ExecutionFactory.java
trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPAPlugin.java
trunk/connectors/translator-jpa/src/main/resources/org/teiid/translator/jpa/i18n.properties
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
Log:
TEIID-2176: Adding the native query procedures JPA2 translator.
Modified: trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java 2012-09-26 00:32:18 UTC (rev 4473)
+++ trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -461,7 +461,7 @@
return delegate.supportsNativeQueries();
}
@Override
- public ResultSetExecution createDirectExecution(List<Argument> arguments,
+ public ProcedureExecution createDirectExecution(List<Argument> arguments,
Command command, ExecutionContext executionContext,
RuntimeMetadata metadata, C connection) throws TranslatorException {
return delegate.createDirectExecution(arguments, command, executionContext, metadata, connection);
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-09-26 00:32:18 UTC (rev 4473)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -302,7 +302,7 @@
}
@SuppressWarnings("unused")
- public ResultSetExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, C connection) throws TranslatorException {
+ public ProcedureExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, C connection) throws TranslatorException {
throw new TranslatorException(DataPlugin.Event.TEIID60001, DataPlugin.Util.gs(DataPlugin.Event.TEIID60001, "createDirectExecution")); //$NON-NLS-1$
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2012-09-26 00:32:18 UTC (rev 4473)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -208,7 +208,7 @@
}
@Override
- public ResultSetExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection conn)
+ public ProcedureExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection conn)
throws TranslatorException {
//TODO: This is not correct; this should be only called once for connection creation
obtainedConnection(conn);
Modified: trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPA2ExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPA2ExecutionFactory.java 2012-09-26 00:32:18 UTC (rev 4473)
+++ trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPA2ExecutionFactory.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -31,6 +31,7 @@
import javax.persistence.EntityManagerFactory;
import org.teiid.core.util.PropertiesUtils;
+import org.teiid.language.Argument;
import org.teiid.language.Call;
import org.teiid.language.Command;
import org.teiid.language.QueryExpression;
@@ -51,6 +52,10 @@
public class JPA2ExecutionFactory extends ExecutionFactory<EntityManagerFactory, EntityManager> {
private Map<String, FunctionModifier> functionModifiers = new TreeMap<String, FunctionModifier>(String.CASE_INSENSITIVE_ORDER);
+ public JPA2ExecutionFactory() {
+ setSupportsNativeQueries(true);
+ }
+
@Override
public void start() throws TranslatorException {
super.start();
@@ -95,6 +100,12 @@
}
@Override
+ public ProcedureExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, EntityManager connection) throws TranslatorException {
+ return new JPQLDirectQueryExecution(arguments, command, executionContext, metadata, connection);
+ }
+
+
+ @Override
public void getMetadata(MetadataFactory mf, EntityManager em) throws TranslatorException {
JPAMetadataProcessor metadataProcessor = new JPAMetadataProcessor();
PropertiesUtils.setBeanProperties(metadataProcessor, mf.getImportProperties(), "importer"); //$NON-NLS-1$
Modified: trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPAPlugin.java
===================================================================
--- trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPAPlugin.java 2012-09-26 00:32:18 UTC (rev 4473)
+++ trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPAPlugin.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -40,6 +40,7 @@
TEIID14004,
TEIID14005,
TEIID14006,
- TEIID14007
+ TEIID14007,
+ TEIID14008
}
}
Added: trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPQLDirectQueryExecution.java
===================================================================
--- trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPQLDirectQueryExecution.java (rev 0)
+++ trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPQLDirectQueryExecution.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -0,0 +1,131 @@
+/*
+ * 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.jpa;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.teiid.language.Argument;
+import org.teiid.language.Command;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+
+public class JPQLDirectQueryExecution extends JPQLBaseExecution implements ProcedureExecution{
+ private Iterator resultsIterator;
+ private List<Argument> arguments;
+ private int updateCount = -1;
+ private boolean updateQuery;
+
+ @SuppressWarnings("unused")
+ public JPQLDirectQueryExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, EntityManager em) {
+ super(executionContext, metadata, em);
+ this.arguments = arguments;
+ }
+
+ @Override
+ public void execute() throws TranslatorException {
+ String query = (String)arguments.get(0).getArgumentValue().getValue();
+ String firstToken = null;
+
+ StringTokenizer st = new StringTokenizer(query, ";"); //$NON-NLS-1$
+ if (st.hasMoreTokens()) {
+ firstToken = st.nextToken();
+ if (!firstToken.equalsIgnoreCase("search") && !firstToken.equalsIgnoreCase("create") && !firstToken.equalsIgnoreCase("update") && !firstToken.equalsIgnoreCase("delete")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ throw new TranslatorException(JPAPlugin.Util.gs(JPAPlugin.Event.TEIID14008));
+ }
+ }
+
+ String jpql = query.substring(7);
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "JPA Source-Query:", jpql); //$NON-NLS-1$
+
+ if (firstToken.equalsIgnoreCase("search")) { // //$NON-NLS-1$
+ Query queryCommand = this.enityManager.createQuery(jpql);
+ List results = queryCommand.getResultList();
+ this.resultsIterator = results.iterator();
+ }
+ else if (firstToken.equalsIgnoreCase("create")) { // //$NON-NLS-1$
+ Object entity = arguments.get(1).getArgumentValue().getValue();
+ this.enityManager.merge(entity);
+ this.updateCount = 1;
+ this.updateQuery = true;
+ }
+ else if (firstToken.equalsIgnoreCase("update") || firstToken.equalsIgnoreCase("delete")) { // //$NON-NLS-1$ //$NON-NLS-2$
+ Query queryCmd = this.enityManager.createQuery(jpql);
+ this.updateCount = queryCmd.executeUpdate();
+ this.updateQuery = true;
+ }
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+
+ // for insert/update/delete clauses
+ if (this.updateQuery) {
+ if (this.updateCount != -1) {
+ List<Object[]> row = new ArrayList<Object[]>(1);
+ row.add(new Object[] {this.updateCount});
+ this.updateCount = -1;
+ return row;
+ }
+ return null;
+ }
+
+ if (this.resultsIterator != null && this.resultsIterator.hasNext()) {
+ Object obj = this.resultsIterator.next();
+ if (obj instanceof Object[]) {
+ List<Object[]> row = new ArrayList<Object[]>(1);
+ row.add((Object[])obj);
+ return row;
+ }
+ return Arrays.asList(new Object[] {obj});
+ }
+ return null;
+ }
+
+ @Override
+ public void close() {
+ // no close
+ this.resultsIterator = null;
+
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+ // no cancel
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ return null;
+ }
+}
Property changes on: trunk/connectors/translator-jpa/src/main/java/org/teiid/translator/jpa/JPQLDirectQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-jpa/src/main/resources/org/teiid/translator/jpa/i18n.properties
===================================================================
--- trunk/connectors/translator-jpa/src/main/resources/org/teiid/translator/jpa/i18n.properties 2012-09-26 00:32:18 UTC (rev 4473)
+++ trunk/connectors/translator-jpa/src/main/resources/org/teiid/translator/jpa/i18n.properties 2012-09-26 17:05:51 UTC (rev 4474)
@@ -4,4 +4,5 @@
TEIID14004=No parent table found for {0}
TEIID14005=Bushy joins are not supported.
TEIID14006=Unsupported join semantics, join can only be done where relationship exists
-TEIID14007=Columns.size and values.size are not the same
\ No newline at end of file
+TEIID14007=Columns.size and values.size are not the same
+TEIID14008=Unknown JPAQL Request; the query string must start with [search|create|update|delete]
\ No newline at end of file
Added: trunk/connectors/translator-jpa/src/test/java/org/teiid/translator/jpa/TestJPADirectQueryExecution.java
===================================================================
--- trunk/connectors/translator-jpa/src/test/java/org/teiid/translator/jpa/TestJPADirectQueryExecution.java (rev 0)
+++ trunk/connectors/translator-jpa/src/test/java/org/teiid/translator/jpa/TestJPADirectQueryExecution.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -0,0 +1,132 @@
+/*
+ * 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.jpa;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.teiid.cdk.api.TranslationUtility;
+import org.teiid.cdk.unittest.FakeTranslationFactory;
+import org.teiid.language.Command;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TranslatorException;
+
+@SuppressWarnings("nls")
+public class TestJPADirectQueryExecution {
+
+ private static JPA2ExecutionFactory TRANSLATOR;
+
+ @BeforeClass
+ public static void setUp() throws TranslatorException {
+ TRANSLATOR = new JPA2ExecutionFactory();
+ TRANSLATOR.start();
+ }
+
+ @Test public void testSearch() throws Exception {
+ String input = "exec native('search;SELECT Account.Id, Account.Type, Account.Name FROM Account')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ EntityManager connection = Mockito.mock(EntityManager.class);
+ Query query = Mockito.mock(Query.class);
+
+ Mockito.stub(connection.createQuery("SELECT Account.Id, Account.Type, Account.Name FROM Account")).toReturn(query);
+
+ JPQLDirectQueryExecution execution = (JPQLDirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+ Mockito.verify(connection, Mockito.times(1)).createQuery("SELECT Account.Id, Account.Type, Account.Name FROM Account");
+ }
+
+ @Test public void testWithoutMarker() throws Exception {
+ String input = "exec native('jpa query')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ EntityManager connection = Mockito.mock(EntityManager.class);
+
+ try {
+ JPQLDirectQueryExecution execution = (JPQLDirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+ fail("the above should have thrown exception");
+ } catch (TranslatorException e) {
+ }
+ }
+
+ @Test public void testDelete() throws Exception {
+ String input = "exec native('delete;delete-query')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ EntityManager connection = Mockito.mock(EntityManager.class);
+
+ Query query = Mockito.mock(Query.class);
+ Mockito.stub(query.executeUpdate()).toReturn(12);
+ Mockito.stub(connection.createQuery("delete-query")).toReturn(query);
+
+ ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
+
+ JPQLDirectQueryExecution execution = (JPQLDirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+ Mockito.verify(connection, Mockito.times(1)).createQuery(argument.capture());
+
+ assertEquals("delete-query", argument.getValue());
+
+ assertArrayEquals(new Object[] {12}, (Object[])execution.next().get(0));
+ }
+
+ @Test public void testCreate() throws Exception {
+ String input = "exec native('create;', 'one')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ EntityManager connection = Mockito.mock(EntityManager.class);
+
+ ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
+ Mockito.stub(connection.merge(argument.capture())).toReturn(new String("one"));
+
+ JPQLDirectQueryExecution execution = (JPQLDirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+ Mockito.verify(connection).merge(argument.capture());
+
+ assertEquals("one", argument.getValue());
+ }
+}
Property changes on: trunk/connectors/translator-jpa/src/test/java/org/teiid/translator/jpa/TestJPADirectQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2012-09-26 00:32:18 UTC (rev 4473)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -33,6 +33,7 @@
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ProcedureExecution;
import org.teiid.translator.ResultSetExecution;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
@@ -105,7 +106,7 @@
}
@Override
- public ResultSetExecution createDirectExecution(List<Argument> arguments,Command command, ExecutionContext executionContext,RuntimeMetadata metadata, LdapContext context) throws TranslatorException {
+ public ProcedureExecution createDirectExecution(List<Argument> arguments,Command command, ExecutionContext executionContext,RuntimeMetadata metadata, LdapContext context) throws TranslatorException {
String query = (String) arguments.get(0).getArgumentValue().getValue();
if (query.startsWith("search;")) { //$NON-NLS-1$
return new LDAPDirectSearchQueryExecution(arguments, this, executionContext, context);
Modified: trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java
===================================================================
--- trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java 2012-09-26 00:32:18 UTC (rev 4473)
+++ trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -36,7 +36,7 @@
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
-import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.ProcedureExecution;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
@@ -51,7 +51,7 @@
}
@Override
- public ResultSetExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection connection) throws TranslatorException {
+ public ProcedureExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection connection) throws TranslatorException {
return new OlapQueryExecution(arguments, command, unwrap(connection), executionContext, this);
}
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2012-09-26 00:32:18 UTC (rev 4473)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2012-09-26 17:05:51 UTC (rev 4474)
@@ -118,7 +118,7 @@
}
@Override
- public ResultSetExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, SalesforceConnection connection) throws TranslatorException {
+ public ProcedureExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, SalesforceConnection connection) throws TranslatorException {
return new DirectQueryExecution(arguments, command, connection, metadata, executionContext);
}
12 years, 3 months
teiid SVN: r4473 - in trunk/engine/src: main/java/org/teiid/query/optimizer and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-25 20:32:18 -0400 (Tue, 25 Sep 2012)
New Revision: 4473
Added:
trunk/engine/src/main/java/org/teiid/query/processor/proc/BlockInstruction.java
Modified:
trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
Log:
TEIID-2229 adding resolving and processing support for directly nested blocks
Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-09-25 22:15:11 UTC (rev 4472)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-09-26 00:32:18 UTC (rev 4473)
@@ -250,7 +250,6 @@
TEIID30240,
TEIID30241,
TEIID30242,
- TEIID30243,
TEIID30244,
TEIID30245,
TEIID30247,
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2012-09-25 22:15:11 UTC (rev 4472)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2012-09-26 00:32:18 UTC (rev 4473)
@@ -31,7 +31,6 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.id.IDGenerator;
import org.teiid.core.util.Assertion;
-import org.teiid.query.QueryPlugin;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
@@ -318,8 +317,14 @@
instruction = new WhileInstruction(whileProgram, whileStmt.getCondition(), whileStmt.getLabel());
break;
}
+ case Statement.TYPE_COMPOUND:
+ {
+ Block block = (Block)statement;
+ instruction = new BlockInstruction(planBlock(parentProcCommand, block, metadata, debug, idGenerator, capFinder, analysisRecord, context));
+ break;
+ }
default:
- throw new QueryPlannerException(QueryPlugin.Event.TEIID30243, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30243, stmtType));
+ throw new AssertionError("Error while planning update procedure, unknown statement type encountered: " + statement); //$NON-NLS-1$
}
return instruction;
}
Added: trunk/engine/src/main/java/org/teiid/query/processor/proc/BlockInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/BlockInstruction.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/BlockInstruction.java 2012-09-26 00:32:18 UTC (rev 4473)
@@ -0,0 +1,66 @@
+/*
+ * 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.proc;
+
+import static org.teiid.query.analysis.AnalysisRecord.*;
+
+import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
+public class BlockInstruction extends ProgramInstruction {
+
+ private Program program;
+
+ public BlockInstruction(Program ifProgram) {
+ this.program = ifProgram;
+ }
+
+ public void process(ProcedurePlan procEnv)
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
+ procEnv.push(program);
+ }
+
+ public Program getProgram(){
+ return this.program;
+ }
+
+ /**
+ * Returns a deep clone
+ */
+ public BlockInstruction clone(){
+ return new BlockInstruction(this.program.clone());
+ }
+
+ public String toString() {
+ return "BLOCK INSTRUCTION:\n " + this.program; //$NON-NLS-1$
+ }
+
+ public PlanNode getDescriptionProperties() {
+ PlanNode props = new PlanNode("BLOCK"); //$NON-NLS-1$
+ props.addProperty(PROP_PROGRAM, this.program.getDescriptionProperties());
+ return props;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/query/processor/proc/BlockInstruction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2012-09-25 22:15:11 UTC (rev 4472)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2012-09-26 00:32:18 UTC (rev 4473)
@@ -316,6 +316,9 @@
resolveBlock(command, loopStmt.getBlock(), externalGroups, metadata, pushChild(sn));
break;
+ case Statement.TYPE_COMPOUND:
+ resolveBlock(command, (Block)statement, externalGroups, metadata, sn);
+ break;
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2012-09-25 22:15:11 UTC (rev 4472)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2012-09-26 00:32:18 UTC (rev 4473)
@@ -277,12 +277,20 @@
ifStmt.setCondition(evalCrit);
if(evalCrit.equals(TRUE_CRITERIA)) {
Block ifblock = rewriteBlock(ifStmt.getIfBlock());
- newStmts.addAll(ifblock.getStatements());
+ if (ifblock.isAtomic()) {
+ newStmts.add(ifblock);
+ } else {
+ newStmts.addAll(ifblock.getStatements());
+ }
return;
} else if(evalCrit.equals(FALSE_CRITERIA) || evalCrit.equals(UNKNOWN_CRITERIA)) {
if(ifStmt.hasElseBlock()) {
Block elseBlock = rewriteBlock(ifStmt.getElseBlock());
- newStmts.addAll(elseBlock.getStatements());
+ if (elseBlock.isAtomic()) {
+ newStmts.add(elseBlock);
+ } else {
+ newStmts.addAll(elseBlock.getStatements());
+ }
return;
}
return;
@@ -1186,8 +1194,14 @@
case CompareCriteria.LE:
case CompareCriteria.GE:
case CompareCriteria.EQ:
+ if (leftExpr instanceof Constant) {
+ return TRUE_CRITERIA;
+ }
return getSimpliedCriteria(criteria, criteria.getLeftExpression(), true, true);
default:
+ if (leftExpr instanceof Constant) {
+ return FALSE_CRITERIA;
+ }
return getSimpliedCriteria(criteria, criteria.getLeftExpression(), false, true);
}
}
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-09-25 22:15:11 UTC (rev 4472)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-09-26 00:32:18 UTC (rev 4473)
@@ -755,7 +755,6 @@
TEIID30367=Infinite loop detected, procedure will not be executed.
TEIID30244=The batch contained an unrecognized command: {0}
-TEIID30243=Error while planning update procedure, unknown statement type encountered: {0}
TEIID30272=Error getting modelID
TEIID30213=Cannot find namespace URI for namespace {0} of element {1}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2012-09-25 22:15:11 UTC (rev 4472)
+++ trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2012-09-26 00:32:18 UTC (rev 4473)
@@ -2054,7 +2054,19 @@
List[] expected = new List[] { Arrays.asList("1") }; //$NON-NLS-1$
helpTestProcess(plan, expected, dataManager, tm);
}
+
+ @Test public void testNestedBlock() throws Exception {
+ String ddl = "create virtual procedure proc (z STRING) returns table (x string, y string) as begin declare string x = z; select x; begin select x, x; end end;";
+ TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
+ String sql = "call proc('a')"; //$NON-NLS-1$
+ ProcessorPlan plan = getProcedurePlan(sql, tm);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager(tm);
+ List[] expected = new List[] { Arrays.asList("a", "a") }; //$NON-NLS-1$
+ helpTestProcess(plan, expected, dataManager, tm);
+ }
+
private static final boolean DEBUG = false;
}
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java 2012-09-25 22:15:11 UTC (rev 4472)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java 2012-09-26 00:32:18 UTC (rev 4473)
@@ -192,6 +192,24 @@
assertEquals("loopCursor", value.getGroupSymbol().getName()); //$NON-NLS-1$
}
+ @Test(expected=QueryResolverException.class) public void testBlockResolving() throws Exception {
+ StringBuffer proc = new StringBuffer("FOR EACH ROW") //$NON-NLS-1$
+ .append("\nBEGIN") //$NON-NLS-1$
+ //note that this declare takes presedense over the proc INPUTS.e1 and CHANGING.e1 variables
+ .append("\n declare integer e1 = 1;") //$NON-NLS-1$
+ .append("\n BEGIN") //$NON-NLS-1$
+ //inside the scope of the loop, an unqualified e1 should resolve to the loop variable group
+ .append("\n variables.e1 = e2;") //$NON-NLS-1$
+ .append("\n END") //$NON-NLS-1$
+ .append("\nEND"); //$NON-NLS-1$
+
+ String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+ helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
+ Table.TriggerEvent.UPDATE);
+
+ }
+
// variable resolution, variable used in if statement, variable compared against
// different datatype element
@Test public void testCreateUpdateProcedure4() {
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2012-09-25 22:15:11 UTC (rev 4472)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2012-09-26 00:32:18 UTC (rev 4473)
@@ -1184,6 +1184,18 @@
String expected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nSELECT e1 FROM pm1.g1;\nEND"; //$NON-NLS-1$
helpTestRewriteCommand(procedure1, expected);
+ }
+
+ @Test public void testRetainAtomic() {
+ String procedure1 = "CREATE virtual PROCEDURE "; //$NON-NLS-1$
+ procedure1 += "if (true)\n"; //$NON-NLS-1$
+ procedure1 += "begin atomic\n"; //$NON-NLS-1$
+ procedure1 += "select e1 from pm1.g1;\n"; //$NON-NLS-1$
+ procedure1 += "end\n"; //$NON-NLS-1$
+
+ String expected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nBEGIN ATOMIC\nSELECT e1 FROM pm1.g1;\nEND\nEND"; //$NON-NLS-1$
+
+ helpTestRewriteCommand(procedure1, expected);
}
@Test public void testRewriteDeclare() {
12 years, 3 months
teiid SVN: r4472 - in trunk: api/src/main/java/org/teiid/translator and 17 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-09-25 18:15:11 -0400 (Tue, 25 Sep 2012)
New Revision: 4472
Added:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCDirectQueryExecution.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCDirectQueryExecution.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectCreateUpdateDeleteQueryExecution.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectSearchQueryExecution.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPQueryExecution.java
trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestLDAPDirectQueryExecution.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DirectQueryExecution.java
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestSalesForceDirectQueryExecution.java
trunk/engine/src/main/java/org/teiid/query/metadata/DirectQueryMetadataRepository.java
Modified:
trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java
trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/api/src/test/java/org/teiid/translator/TestBaseDelegatingExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionException.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPPlugin.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSearchDetails.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java
trunk/connectors/translator-ldap/src/main/resources/org/teiid/translator/ldap/i18n.properties
trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForcePlugin.java
trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/salesforce/i18n.properties
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
trunk/pom.xml
trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java
Log:
TEIID-2176: Adding the native query procedures to JDBC, LDAP, Salesforce and OLAP translators.
Modified: trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -24,6 +24,7 @@
import java.util.List;
+import org.teiid.language.Argument;
import org.teiid.language.Call;
import org.teiid.language.Command;
import org.teiid.language.LanguageFactory;
@@ -451,4 +452,18 @@
public boolean supportsArrayType() {
return delegate.supportsArrayType();
}
+ @Override
+ public String getNativeQueryProcedureName() {
+ return delegate.getNativeQueryProcedureName();
+ }
+
+ public boolean supportsNativeQueries() {
+ return delegate.supportsNativeQueries();
+ }
+ @Override
+ public ResultSetExecution createDirectExecution(List<Argument> arguments,
+ Command command, ExecutionContext executionContext,
+ RuntimeMetadata metadata, C connection) throws TranslatorException {
+ return delegate.createDirectExecution(arguments, command, executionContext, metadata, connection);
+ }
}
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -33,6 +33,7 @@
import org.teiid.connector.DataPlugin;
import org.teiid.core.TeiidException;
import org.teiid.core.util.ReflectionHelper;
+import org.teiid.language.Argument;
import org.teiid.language.BatchedUpdates;
import org.teiid.language.Call;
import org.teiid.language.Command;
@@ -113,8 +114,9 @@
private int maxInSize = DEFAULT_MAX_IN_CRITERIA_SIZE;
private int maxDependentInPredicates = DEFAULT_MAX_IN_CRITERIA_SIZE;
private boolean copyLobs;
-
+ private boolean supportsNativeQueries;
private LinkedList<FunctionMethod> pushdownFunctionMethods = new LinkedList<FunctionMethod>();
+ private String nativeProcedureName = "native"; //$NON-NLS-1$
/**
* Initialize the connector with supplied configuration
@@ -268,6 +270,13 @@
* @return An execution object that can use to execute the command
*/
public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, C connection) throws TranslatorException {
+ if (command instanceof Call) {
+ Call obj = (Call)command;
+ if (supportsNativeQueries() && obj.getMetadataObject().getName().equals(getNativeQueryProcedureName())) {
+ List<Argument> arguments = obj.getArguments();
+ return createDirectExecution(arguments, command, executionContext, metadata, connection);
+ }
+ }
if (command instanceof QueryExpression) {
return createResultSetExecution((QueryExpression)command, executionContext, metadata, connection);
}
@@ -292,6 +301,11 @@
throw new TranslatorException(DataPlugin.Event.TEIID60001, DataPlugin.Util.gs(DataPlugin.Event.TEIID60001, "createUpdateExecution")); //$NON-NLS-1$
}
+ @SuppressWarnings("unused")
+ public ResultSetExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, C connection) throws TranslatorException {
+ throw new TranslatorException(DataPlugin.Event.TEIID60001, DataPlugin.Util.gs(DataPlugin.Event.TEIID60001, "createDirectExecution")); //$NON-NLS-1$
+ }
+
/**
* Support indicates connector can accept queries with SELECT DISTINCT
* @since 3.1 SP2
@@ -1035,5 +1049,31 @@
public boolean supportsArrayType() {
return false;
}
-
+
+ /**
+ * True, if this translator supports execution of source specific commands unaltered through 'native' procedure.
+ * @return
+ */
+ @TranslatorProperty(display="Supports Native Queries", description="True, if this translator supports execution of source specific commands unaltered through 'native' procedure", advanced=true)
+ public boolean supportsNativeQueries() {
+ return this.supportsNativeQueries;
+ }
+
+ public void setSupportsNativeQueries(boolean state) {
+ this.supportsNativeQueries = state;
+ }
+
+ /**
+ * Defines the name of the procedure that need to be treated as "native" query processing procedure. This metadata or signature
+ * of the procedure is defined automatically.
+ * @return
+ */
+ @TranslatorProperty(display="Name of the native query", description="The name of the procedure that is considered as the name of the direct query procedure", advanced=true)
+ public String getNativeQueryProcedureName() {
+ return this.nativeProcedureName;
+ }
+
+ public void setNativeQueryProcedureName(String name) {
+ this.nativeProcedureName = name;
+ }
}
Modified: trunk/api/src/test/java/org/teiid/translator/TestBaseDelegatingExecutionFactory.java
===================================================================
--- trunk/api/src/test/java/org/teiid/translator/TestBaseDelegatingExecutionFactory.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/api/src/test/java/org/teiid/translator/TestBaseDelegatingExecutionFactory.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -34,7 +34,7 @@
Method[] methods = ExecutionFactory.class.getDeclaredMethods();
Method[] proxyMethods = BaseDelegatingExecutionFactory.class.getDeclaredMethods();
//excluding the setter methods the counts should be equal
- assertEquals(methods.length - 10, proxyMethods.length);
+ assertEquals(methods.length - 12, proxyMethods.length);
}
}
Added: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCDirectQueryExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCDirectQueryExecution.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCDirectQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -0,0 +1,158 @@
+/*
+ * 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.jdbc;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.language.Argument;
+import org.teiid.language.Command;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+
+
+public class JDBCDirectQueryExecution extends JDBCQueryExecution implements ProcedureExecution {
+
+ protected int columnCount;
+ private List<Argument> arguments;
+ protected int updateCount = -1;
+
+ public JDBCDirectQueryExecution(List<Argument> arguments, Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env) {
+ super(command, connection, context, env);
+ this.arguments = arguments;
+ }
+
+ @Override
+ public void execute() throws TranslatorException {
+ String sourceSQL = (String) this.arguments.get(0).getArgumentValue().getValue();
+ List<Argument> parameters = this.arguments.subList(1, this.arguments.size());
+
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Source sql", sourceSQL); //$NON-NLS-1$
+ boolean prepared = (sourceSQL.indexOf('?') != -1);
+ boolean callable = (sourceSQL.indexOf("call ") != -1); //$NON-NLS-1$
+ int paramCount = getParamCount(sourceSQL);
+
+ try {
+ if (callable) {
+ CallableStatement cstmt = getCallableStatement(sourceSQL);
+ this.results = this.executionFactory.executeStoredProcedure(cstmt, parameters, TypeFacility.RUNTIME_TYPES.OBJECT);
+ this.columnCount = this.results.getMetaData().getColumnCount();
+ }
+ else {
+ Statement stmt;
+ boolean hasResults = false;
+
+ if(prepared) {
+ PreparedStatement pstatement = getPreparedStatement(sourceSQL);
+ for (int i = 0; i < paramCount; i++) {
+ if (this.arguments.size()-1 < paramCount) {
+ throw new TranslatorException(JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11019, sourceSQL));
+ }
+ Argument arg = this.arguments.get(i+1);
+ pstatement.setObject(i+1, arg.getArgumentValue().getValue());
+ }
+ stmt = pstatement;
+ hasResults = pstatement.execute();
+ }
+ else {
+ stmt = getStatement();
+ hasResults = stmt.execute(sourceSQL);
+ }
+
+ if (hasResults) {
+ this.results = stmt.getResultSet();
+ this.columnCount = this.results.getMetaData().getColumnCount();
+ }
+ else {
+ this.updateCount = stmt.getUpdateCount();
+ }
+ }
+ addStatementWarnings();
+ } catch (SQLException e) {
+ throw new JDBCExecutionException(JDBCPlugin.Event.TEIID11008, e, sourceSQL);
+ }
+ }
+
+ private int getParamCount(String sourceSQL) {
+ int paramCount = 0;
+ int idx = -1;
+ while (true) {
+ idx = sourceSQL.indexOf('?', idx+1);
+ if (idx == -1) {
+ break;
+ }
+ paramCount++;
+ }
+ return paramCount;
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ try {
+ ArrayList<Object[]> row = new ArrayList<Object[]>(1);
+
+ if (this.results != null) {
+ if (this.results.next()) {
+ // New row for result set
+ List<Object> vals = new ArrayList<Object>(this.columnCount);
+
+ for (int i = 0; i < this.columnCount; i++) {
+ // Convert from 0-based to 1-based
+ Object value = this.executionFactory.retrieveValue(this.results, i+1, TypeFacility.RUNTIME_TYPES.OBJECT);
+ vals.add(value);
+ }
+ row.add(vals.toArray(new Object[vals.size()]));
+ return row;
+ }
+ }
+ else if (this.updateCount != -1) {
+ List<Object> vals = new ArrayList<Object>(1);
+ vals.add(new Integer(this.updateCount));
+ this.updateCount = -1;
+ row.add(vals.toArray(new Object[vals.size()]));
+ return row;
+ }
+ } catch (SQLException e) {
+ throw new TranslatorException(e,JDBCPlugin.Util.getString("JDBCTranslator.Unexpected_exception_translating_results___8", e.getMessage())); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ return null;
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCDirectQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionException.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionException.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionException.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -37,4 +37,9 @@
super(error, commands == null || commands.length == 0 ? event.toString()+":"+error.getMessage() : event.toString()+":"+JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11004, Arrays.toString(commands))); //$NON-NLS-1$ //$NON-NLS-2$
setCode(String.valueOf(error.getErrorCode()));
}
+
+ public JDBCExecutionException(BundleUtil.Event event, SQLException error, String command) {
+ super(error, event.toString()+":"+JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11004, command)); //$NON-NLS-1$
+ setCode(String.valueOf(error.getErrorCode()));
+ }
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -140,6 +140,7 @@
setSupportsInnerJoins(true);
setMaxInCriteriaSize(DEFAULT_MAX_IN_CRITERIA);
setMaxDependentInPredicates(DEFAULT_MAX_DEPENDENT_PREDICATES);
+ setSupportsNativeQueries(true);
}
@Override
@@ -207,6 +208,14 @@
}
@Override
+ public ResultSetExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection conn)
+ throws TranslatorException {
+ //TODO: This is not correct; this should be only called once for connection creation
+ obtainedConnection(conn);
+ return new JDBCDirectQueryExecution(arguments, command, conn, executionContext, this);
+ }
+
+ @Override
public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection conn)
throws TranslatorException {
//TODO: This is not correct; this should be only called once for connection creation
@@ -717,15 +726,14 @@
* stored procedures differently, subclasses should override this method
* if necessary.
*/
- public ResultSet executeStoredProcedure(CallableStatement statement, TranslatedCommand command, Class<?> returnType) throws SQLException {
- List params = command.getPreparedValues();
+ public ResultSet executeStoredProcedure(CallableStatement statement, List<Argument> preparedValues, Class<?> returnType) throws SQLException {
int index = 1;
if(returnType != null){
registerSpecificTypeOfOutParameter(statement, returnType, index++);
}
- Iterator iter = params.iterator();
+ Iterator iter = preparedValues.iterator();
while(iter.hasNext()){
Argument param = (Argument)iter.next();
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCPlugin.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -54,5 +54,6 @@
TEIID11016,
TEIID11017,
TEIID11018,
+ TEIID11019
}
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -64,7 +64,7 @@
try{
//create parameter index map
CallableStatement cstmt = getCallableStatement(sql);
- this.results = this.executionFactory.executeStoredProcedure(cstmt, translatedComm, procedure.getReturnType());
+ this.results = this.executionFactory.executeStoredProcedure(cstmt, translatedComm.getPreparedValues(), procedure.getReturnType());
addStatementWarnings();
}catch(SQLException e){
throw new TranslatorException(JDBCPlugin.Event.TEIID11004, e, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11004, sql));
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -730,8 +730,8 @@
@Override
public ResultSet executeStoredProcedure(CallableStatement statement,
- TranslatedCommand command, Class<?> returnType) throws SQLException {
- ResultSet rs = super.executeStoredProcedure(statement, command, returnType);
+ List<Argument> preparedValues, Class<?> returnType) throws SQLException {
+ ResultSet rs = super.executeStoredProcedure(statement, preparedValues, returnType);
if (!oracleSuppliedDriver || returnType != RefCursorType.class) {
return rs;
}
Modified: trunk/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties
===================================================================
--- trunk/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties 2012-09-25 22:15:11 UTC (rev 4472)
@@ -32,4 +32,5 @@
TEIID11002=Failed to report the JDBC driver and connection information
TEIID11006=Teiid runtime names, which are case insensitive, for the imported metadata are not unique. If not already set, use the setting importer.useFullSchemaName to create Teiid names that include the source schema.
TEIID11017=Invalid name in source sequence format. Expected <element name> {0} <sequence name>.<sequence value>, but was {1}
-TEIID11018=Connection is null; Datasource may not have been defined. Requires a active connection to retrieve the metadata.
\ No newline at end of file
+TEIID11018=Connection is null; Datasource may not have been defined. Requires a active connection to retrieve the metadata.
+TEIID11019=For direct JDBC execution of command "{0}", not any/all parameters are supplied for the prepared jdbc call.
\ No newline at end of file
Added: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCDirectQueryExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCDirectQueryExecution.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCDirectQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -0,0 +1,136 @@
+/*
+ * 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.jdbc;
+
+import static org.junit.Assert.*;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
+
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.language.Command;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
+
+@SuppressWarnings("nls")
+public class TestJDBCDirectQueryExecution {
+
+ @Test public void testProcedureExecution() throws Exception {
+ Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "exec native('{?=call spTest8a()}')"); //$NON-NLS-1$
+ Connection connection = Mockito.mock(Connection.class);
+ CallableStatement cs = Mockito.mock(CallableStatement.class);
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSetMetaData rsm = Mockito.mock(ResultSetMetaData.class);
+
+ Mockito.stub(cs.getUpdateCount()).toReturn(-1);
+ Mockito.stub(cs.getResultSet()).toReturn(rs);
+ Mockito.stub(rs.getMetaData()).toReturn(rsm);
+ Mockito.stub(rsm.getColumnCount()).toReturn(1);
+ Mockito.stub(connection.prepareCall("{?=call spTest8a()}")).toReturn(cs); //$NON-NLS-1$
+ Mockito.stub(rs.next()).toReturn(true);
+ Mockito.stub(rs.getObject(1)).toReturn(5);
+ Mockito.stub(connection.getMetaData()).toReturn(Mockito.mock(DatabaseMetaData.class));
+
+ JDBCExecutionFactory ef = new JDBCExecutionFactory();
+ ResultSetExecution execution = (ResultSetExecution)ef.createExecution(command, Mockito.mock(ExecutionContext.class), Mockito.mock(RuntimeMetadata.class), connection);
+ execution.execute();
+ assertArrayEquals(new Object[] {5}, (Object[])execution.next().get(0));
+ }
+
+ @Test public void testSelectExecution() throws Exception {
+ Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "call native('select * from Source')"); //$NON-NLS-1$
+ Connection connection = Mockito.mock(Connection.class);
+ Statement stmt = Mockito.mock(Statement.class);
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSetMetaData rsm = Mockito.mock(ResultSetMetaData.class);
+
+ Mockito.stub(stmt.getUpdateCount()).toReturn(-1);
+ Mockito.stub(stmt.getResultSet()).toReturn(rs);
+ Mockito.stub(rs.getMetaData()).toReturn(rsm);
+ Mockito.stub(rsm.getColumnCount()).toReturn(2);
+ Mockito.stub(connection.createStatement()).toReturn(stmt); //$NON-NLS-1$
+ Mockito.stub(stmt.execute("select * from Source")).toReturn(true);
+ Mockito.stub(rs.next()).toReturn(true);
+ Mockito.stub(rs.getObject(1)).toReturn(5);
+ Mockito.stub(rs.getObject(2)).toReturn("five");
+ Mockito.stub(connection.getMetaData()).toReturn(Mockito.mock(DatabaseMetaData.class));
+
+ JDBCExecutionFactory ef = new JDBCExecutionFactory();
+ ResultSetExecution execution = (ResultSetExecution)ef.createExecution(command, Mockito.mock(ExecutionContext.class), Mockito.mock(RuntimeMetadata.class), connection);
+ execution.execute();
+ assertArrayEquals(new Object[] {5, "five"}, (Object[])execution.next().get(0));
+ }
+
+ @Test public void testPrepareExecution() throws Exception {
+ Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "call native('select * from Source where e1 = ?', 2)"); //$NON-NLS-1$
+ Connection connection = Mockito.mock(Connection.class);
+ PreparedStatement stmt = Mockito.mock(PreparedStatement.class);
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSetMetaData rsm = Mockito.mock(ResultSetMetaData.class);
+
+ Mockito.stub(stmt.getUpdateCount()).toReturn(-1);
+ Mockito.stub(stmt.getResultSet()).toReturn(rs);
+ Mockito.stub(stmt.execute()).toReturn(true);
+ Mockito.stub(rs.getMetaData()).toReturn(rsm);
+ Mockito.stub(rsm.getColumnCount()).toReturn(2);
+ Mockito.stub(connection.prepareStatement("select * from Source where e1 = ?")).toReturn(stmt); //$NON-NLS-1$
+ Mockito.stub(rs.next()).toReturn(true);
+ Mockito.stub(rs.getObject(1)).toReturn(5);
+ Mockito.stub(rs.getObject(2)).toReturn("five");
+ Mockito.stub(connection.getMetaData()).toReturn(Mockito.mock(DatabaseMetaData.class));
+
+ JDBCExecutionFactory ef = new JDBCExecutionFactory();
+ ResultSetExecution execution = (ResultSetExecution)ef.createExecution(command, Mockito.mock(ExecutionContext.class), Mockito.mock(RuntimeMetadata.class), connection);
+ execution.execute();
+ assertArrayEquals(new Object[] {5, "five"}, (Object[])execution.next().get(0));
+ }
+
+ @Test public void testPrepareUpdateCount() throws Exception {
+ Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "call native('update source set e1=? where e2 = ?', 2, 'foo')"); //$NON-NLS-1$
+ Connection connection = Mockito.mock(Connection.class);
+ PreparedStatement stmt = Mockito.mock(PreparedStatement.class);
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSetMetaData rsm = Mockito.mock(ResultSetMetaData.class);
+
+ Mockito.stub(stmt.getUpdateCount()).toReturn(-1);
+ Mockito.stub(stmt.getUpdateCount()).toReturn(5);
+ Mockito.stub(stmt.execute()).toReturn(false);
+ Mockito.stub(rs.getMetaData()).toReturn(rsm);
+ Mockito.stub(rsm.getColumnCount()).toReturn(2);
+ Mockito.stub(connection.prepareStatement("update source set e1=? where e2 = ?")).toReturn(stmt); //$NON-NLS-1$
+ Mockito.stub(connection.getMetaData()).toReturn(Mockito.mock(DatabaseMetaData.class));
+
+ JDBCExecutionFactory ef = new JDBCExecutionFactory();
+ ResultSetExecution execution = (ResultSetExecution)ef.createExecution(command, Mockito.mock(ExecutionContext.class), Mockito.mock(RuntimeMetadata.class), connection);
+ execution.execute();
+ assertArrayEquals(new Object[] {5}, (Object[])execution.next().get(0));
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCDirectQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -41,32 +41,10 @@
import java.util.LinkedList;
import java.util.List;
-import javax.naming.NamingException;
-import javax.naming.directory.BasicAttribute;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.SortKey;
-import org.teiid.language.AggregateFunction;
-import org.teiid.language.AndOr;
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Comparison;
-import org.teiid.language.Condition;
-import org.teiid.language.DerivedColumn;
-import org.teiid.language.Exists;
-import org.teiid.language.Expression;
-import org.teiid.language.Function;
-import org.teiid.language.In;
-import org.teiid.language.Like;
-import org.teiid.language.Limit;
-import org.teiid.language.Literal;
-import org.teiid.language.NamedTable;
-import org.teiid.language.Not;
-import org.teiid.language.OrderBy;
-import org.teiid.language.ScalarSubquery;
-import org.teiid.language.SearchedCase;
-import org.teiid.language.Select;
-import org.teiid.language.SortSpecification;
-import org.teiid.language.TableReference;
+import org.teiid.language.*;
import org.teiid.language.Comparison.Operator;
import org.teiid.language.SortSpecification.Ordering;
import org.teiid.logging.LogConstants;
@@ -113,7 +91,6 @@
public LDAPSearchDetails translateSQLQueryToLDAPSearch(Select query) throws TranslatorException {
// Parse SELECT symbols.
// The columns will be translated into LDAP attributes of interest.
- ArrayList<BasicAttribute> attributeList = getAttributesFromSelectSymbols(query);
ArrayList<Column> elementList = getElementsFromSelectSymbols(query);
// Parse FROM table.
@@ -165,14 +142,9 @@
}
// Create Search Details
- LDAPSearchDetails sd = new LDAPSearchDetails(contextName, searchScope, filterBuilder.toString(), attributeList, sortKeys, countLimit, elementList);
+ LDAPSearchDetails sd = new LDAPSearchDetails(contextName, searchScope, filterBuilder.toString(), sortKeys, countLimit, elementList);
// Search Details logging
- try {
- sd.printDetailsToLog();
- } catch (NamingException nme) {
- final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.searchDetailsLoggingError"); //$NON-NLS-1$
- throw new TranslatorException(msg);
- }
+ sd.printDetailsToLog();
return sd;
@@ -588,7 +560,7 @@
// GHH 20080326 - found that code to fall back on Name if NameInSource
// was null wasn't working properly, so replaced with tried and true
// code from another custom connector.
- public String getNameFromElement(Column e) {
+ public static String getNameFromElement(Column e) {
String ldapAttributeName = null;
ldapAttributeName = e.getNameInSource();
if (ldapAttributeName == null || ldapAttributeName.equals("")) { //$NON-NLS-1$
@@ -614,28 +586,6 @@
return selectElementList;
}
- /**
- * Method to get attribute list from the supplied query
- * @param query the supplied Query
- * @return the list of attributes
- */
- private ArrayList<BasicAttribute> getAttributesFromSelectSymbols(Select query) {
- ArrayList<BasicAttribute> ldapAttributeList = new ArrayList<BasicAttribute>();
-
- Iterator<DerivedColumn> selectSymbolItr = query.getDerivedColumns().iterator();
- int i=0;
- while(selectSymbolItr.hasNext()) {
- Column e = getElementFromSymbol(selectSymbolItr.next());
- String ldapAttributeName = this.getNameFromElement(e);
- Object ldapAttributeClass = e.getJavaType();
-
- // Store the element's name and class type, so that we know what to look for in the search results.
- BasicAttribute newAttr = new BasicAttribute(ldapAttributeName, ldapAttributeClass);
- ldapAttributeList.add(newAttr);
- i++;
- }
- return ldapAttributeList;
- }
/**
* Helper method for getting runtime {@link org.teiid.connector.metadata.runtime.Element} from a
Added: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectCreateUpdateDeleteQueryExecution.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectCreateUpdateDeleteQueryExecution.java (rev 0)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectCreateUpdateDeleteQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -0,0 +1,190 @@
+/*
+ * 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.ldap;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.naming.NamingException;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.ldap.LdapContext;
+
+import org.teiid.language.Argument;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+
+public class LDAPDirectCreateUpdateDeleteQueryExecution implements ProcedureExecution {
+ private static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ private List<Argument> arguments;
+ protected LdapContext ldapConnection;
+ protected LDAPExecutionFactory executionFactory;
+ protected ExecutionContext executionContext;
+ private int updateCount = -1;
+
+ public LDAPDirectCreateUpdateDeleteQueryExecution(List<Argument> arguments, LDAPExecutionFactory factory, ExecutionContext executionContext, LdapContext connection) {
+ this.arguments = arguments;
+ this.executionFactory = factory;
+ this.executionContext = executionContext;
+ this.ldapConnection = connection;
+ }
+
+ @Override
+ public void execute() throws TranslatorException {
+ String query = (String)arguments.get(0).getArgumentValue().getValue();
+ String firstToken = null;
+
+ StringTokenizer st = new StringTokenizer(query, ";"); //$NON-NLS-1$
+ if (st.hasMoreTokens()) {
+ firstToken = st.nextToken();
+ if (!firstToken.equalsIgnoreCase("create") && !firstToken.equalsIgnoreCase("update") && !firstToken.equalsIgnoreCase("delete")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ throw new TranslatorException(LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12009));
+ }
+ }
+
+ LdapContext ldapCtx = null;
+ try {
+ ldapCtx = (LdapContext)this.ldapConnection.lookup(""); //$NON-NLS-1$
+ } catch (NamingException ne) {
+ throw new TranslatorException(LDAPPlugin.Util.getString("LDAPUpdateExecution.createContextError",ne.getExplanation()));//$NON-NLS-1$
+ }
+
+ if (firstToken.equalsIgnoreCase("delete")) { // //$NON-NLS-1$
+ String theDN = getDN(st); // the token after the marker is always DN
+ try {
+ ldapCtx.destroySubcontext(theDN);
+ this.updateCount = 1;
+ } catch (NamingException ne) {
+ throw new TranslatorException(LDAPPlugin.Util.getString("LDAPUpdateExecution.deleteFailed",theDN,ne.getExplanation()));//$NON-NLS-1$
+ } catch (Exception e) {
+ throw new TranslatorException(e, LDAPPlugin.Util.getString("LDAPUpdateExecution.deleteFailedUnexpected",theDN));//$NON-NLS-1$
+ }
+ }
+ else if (firstToken.equalsIgnoreCase("create")) { //$NON-NLS-1$
+ String theDN = getDN(st); // the token after the marker is always DN
+ ArrayList<BasicAttribute> attributes = getAttributes(st, this.arguments);
+ BasicAttributes attrs = new BasicAttributes();
+ for (BasicAttribute ba:attributes) {
+ attrs.put(ba);
+ }
+ try {
+ ldapCtx.createSubcontext(theDN, attrs);
+ this.updateCount = 1;
+ } catch (NamingException ne) {
+ throw new TranslatorException(LDAPPlugin.Util.getString("LDAPUpdateExecution.insertFailed", theDN, ne.getExplanation()));//$NON-NLS-1$
+ } catch (Exception e) {
+ throw new TranslatorException(e,LDAPPlugin.Util.getString("LDAPUpdateExecution.insertFailedUnexpected", theDN));//$NON-NLS-1$
+ }
+ }
+ else if (firstToken.equalsIgnoreCase("update")) { //$NON-NLS-1$
+ String theDN = getDN(st); // the token after the marker is always DN
+ ArrayList<BasicAttribute> attributes = getAttributes(st, this.arguments);
+ ModificationItem[] updateMods = new ModificationItem[attributes.size()];
+ int i=0;
+ for (BasicAttribute ba:attributes) {
+ updateMods[i++] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, ba);
+ }
+ try {
+ ldapCtx.modifyAttributes(theDN, updateMods);
+ this.updateCount = 1;
+ } catch (NamingException ne) {
+ throw new TranslatorException(LDAPPlugin.Util.getString("LDAPUpdateExecution.updateFailed", theDN, ne.getExplanation()));//$NON-NLS-1$
+ } catch (Exception e) {
+ throw new TranslatorException(e, LDAPPlugin.Util.getString("LDAPUpdateExecution.updateFailedUnexpected",theDN));//$NON-NLS-1$
+ }
+ }
+
+ }
+
+ private String getDN(StringTokenizer st) throws TranslatorException {
+ if (!st.hasMoreTokens()) {
+ throw new TranslatorException(LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12010));
+ }
+ return st.nextToken();
+ }
+
+ private ArrayList<BasicAttribute> getAttributes(StringTokenizer st, List<Argument> arguments) throws TranslatorException {
+ if (!st.hasMoreTokens()) {
+ throw new TranslatorException(LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12011));
+ }
+
+ ArrayList<BasicAttribute> attributes = new ArrayList<BasicAttribute>();
+
+ while(st.hasMoreElements()) {
+ String var = st.nextToken();
+
+ int index = var.indexOf('=');
+ if (index == -1) {
+ continue;
+ }
+ String key = var.substring(0, index).trim().toLowerCase();
+ String value = var.substring(index+1).trim();
+
+ if (key.equalsIgnoreCase(ATTRIBUTES)) {
+ StringTokenizer attrTokens = new StringTokenizer(value, ","); //$NON-NLS-1$
+ int attrCount = 1;
+ while(attrTokens.hasMoreElements()) {
+ String name = attrTokens.nextToken().trim();
+ if (arguments.size() <= attrCount) {
+ throw new TranslatorException(LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12012, name));
+ }
+ Argument argument = arguments.get(attrCount++);
+ Object anObj = argument.getArgumentValue().getValue();
+ attributes.add(new BasicAttribute(name, anObj));
+ }
+
+ }
+ }
+ return attributes;
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ return null;
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ if (this.updateCount != -1) {
+ Object[] columns = new Object[1];
+ columns[0] = this.updateCount;
+ List<Object[]> row = new ArrayList<Object[]>(1);
+ row.add(columns);
+ this.updateCount = -1;
+ return row;
+ }
+ return null;
+ }
+
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+ }
+}
Property changes on: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectCreateUpdateDeleteQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectSearchQueryExecution.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectSearchQueryExecution.java (rev 0)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectSearchQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -0,0 +1,161 @@
+/*
+ * 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.ldap;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.naming.directory.SearchControls;
+import javax.naming.ldap.LdapContext;
+
+import org.teiid.language.Argument;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.Datatype;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+
+public class LDAPDirectSearchQueryExecution extends LDAPSyncQueryExecution implements ProcedureExecution {
+
+ private static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ private static final String COUNT_LIMIT = "count-limit"; //$NON-NLS-1$
+ private static final String TIMEOUT = "timeout";//$NON-NLS-1$
+ private static final String SEARCH_SCOPE = "search-scope";//$NON-NLS-1$
+ private static final String CRITERIA = "filter";//$NON-NLS-1$
+ private static final String CONTEXT_NAME = "context-name";//$NON-NLS-1$
+
+ private List<Argument> arguments;
+
+ public LDAPDirectSearchQueryExecution(List<Argument> arguments, LDAPExecutionFactory factory, ExecutionContext executionContext, LdapContext connection) {
+ super(null, factory, executionContext, connection);
+ this.arguments = arguments;
+ }
+
+ @Override
+ public void execute() throws TranslatorException {
+ this.delegate = buildRequest();
+ this.delegate.execute();
+ }
+
+ private LDAPQueryExecution buildRequest() throws TranslatorException {
+ String query = (String)arguments.get(0).getArgumentValue().getValue();
+
+ ArrayList<String> attributes = new ArrayList<String>();
+ ArrayList<Column> columns = new ArrayList<Column>();
+ String contextName = null;
+ String criteria = ""; //$NON-NLS-1$
+ String searchScope = this.executionFactory.getSearchDefaultScope().name();
+ int timeLimit = 0;
+ long countLimit = 0;
+
+ StringTokenizer st = new StringTokenizer(query, ";"); //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String var = st.nextToken();
+ int index = var.indexOf('=');
+ if (index == -1) {
+ continue;
+ }
+ String key = var.substring(0, index).trim().toLowerCase();
+ String value = var.substring(index+1).trim();
+
+ if (key.equalsIgnoreCase(CONTEXT_NAME)) {
+ contextName = value;
+ }
+ else if (key.equalsIgnoreCase(CRITERIA)) {
+ criteria = value;
+ }
+ else if (key.equalsIgnoreCase(SEARCH_SCOPE)) {
+ searchScope = value;
+ }
+ else if (key.equalsIgnoreCase(TIMEOUT)) {
+ timeLimit = Integer.parseInt(value);
+ }
+ else if (key.equalsIgnoreCase(COUNT_LIMIT)) {
+ countLimit = Long.parseLong(value);
+ }
+ else if (key.equalsIgnoreCase(ATTRIBUTES)) {
+ StringTokenizer attrTokens = new StringTokenizer(value, ","); //$NON-NLS-1$
+ while(attrTokens.hasMoreElements()) {
+ String name = attrTokens.nextToken().trim();
+ attributes.add(name);
+
+ Column column = new Column();
+ column.setName(name);
+ Datatype type = new Datatype();
+ type.setName(TypeFacility.RUNTIME_NAMES.OBJECT);
+ type.setJavaClassName(Object.class.getCanonicalName());
+ column.setDatatype(type, true);
+ columns.add(column);
+ }
+ }
+ }
+
+ int searchScopeInt = buildSearchScope(searchScope);
+
+ // build search controls
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(searchScopeInt);
+ controls.setTimeLimit(timeLimit);
+ controls.setCountLimit(countLimit);
+ controls.setReturningAttributes(attributes.toArray(new String[attributes.size()]));
+
+ LDAPSearchDetails searchDetails = new LDAPSearchDetails(contextName, searchScopeInt, criteria, null, countLimit, columns);
+
+ // Create and configure the new search context.
+ LdapContext context = createSearchContext(contextName);
+ return new LDAPQueryExecution(context, searchDetails, controls, this.executionFactory, this.executionContext);
+ }
+
+ private int buildSearchScope(String searchScope) {
+ int searchScopeInt = 0;
+ // this could be one of OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE
+ if (searchScope.equalsIgnoreCase("OBJECT_SCOPE")) { //$NON-NLS-1$
+ searchScopeInt = SearchControls.OBJECT_SCOPE;
+ }
+ else if (searchScope.equalsIgnoreCase("ONELEVEL_SCOPE")) {//$NON-NLS-1$
+ searchScopeInt = SearchControls.ONELEVEL_SCOPE;
+ }
+ else if (searchScope.equalsIgnoreCase("SUBTREE_SCOPE")) {//$NON-NLS-1$
+ searchScopeInt = SearchControls.SUBTREE_SCOPE;
+ }
+ return searchScopeInt;
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ List<?> vals = super.next();
+ if (vals == null) {
+ return null;
+ }
+ List<Object[]> row = new ArrayList<Object[]>(1);
+ row.add(vals.toArray(new Object[vals.size()]));
+ return row;
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ return null;
+ }
+}
Property changes on: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPDirectSearchQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -21,9 +21,12 @@
*/
package org.teiid.translator.ldap;
+import java.util.List;
+
import javax.naming.ldap.LdapContext;
import javax.resource.cci.ConnectionFactory;
+import org.teiid.language.Argument;
import org.teiid.language.Command;
import org.teiid.language.QueryExpression;
import org.teiid.language.Select;
@@ -59,6 +62,7 @@
public LDAPExecutionFactory() {
this.setMaxInCriteriaSize(1000);
this.setMaxDependentInPredicates(25); //no spec limit on query size, AD is 10MB for the query
+ setSupportsNativeQueries(true);
}
@TranslatorProperty(display="Default Search Base DN", description="Default Base DN for LDAP Searches")
@@ -101,6 +105,15 @@
}
@Override
+ public ResultSetExecution createDirectExecution(List<Argument> arguments,Command command, ExecutionContext executionContext,RuntimeMetadata metadata, LdapContext context) throws TranslatorException {
+ String query = (String) arguments.get(0).getArgumentValue().getValue();
+ if (query.startsWith("search;")) { //$NON-NLS-1$
+ return new LDAPDirectSearchQueryExecution(arguments, this, executionContext, context);
+ }
+ return new LDAPDirectCreateUpdateDeleteQueryExecution(arguments, this, executionContext, context);
+ }
+
+ @Override
public boolean supportsCompareCriteriaEquals() {
return true;
}
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPPlugin.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPPlugin.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPPlugin.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -46,6 +46,10 @@
TEIID12005,
TEIID12006,
TEIID12007,
- TEIID12008
+ TEIID12008,
+ TEIID12009,
+ TEIID12010,
+ TEIID12011,
+ TEIID12012,
}
}
Added: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPQueryExecution.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPQueryExecution.java (rev 0)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -0,0 +1,437 @@
+/*
+ * 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.
+ */
+
+/**
+ *
+ * Please see the user's guide for a full description of capabilties, etc.
+ *
+ * Description/Assumptions:
+ * 1. Table's name in source defines the base DN (or context) for the search.
+ * Example: Table.NameInSource=ou=people,dc=gene,dc=com
+ * [Optional] The table's name in source can also define a search scope. Append
+ * a "?" character as a delimiter to the base DN, and add the search scope string.
+ * The following scopes are available:
+ * SUBTREE_SCOPE
+ * ONELEVEL_SCOPE
+ * OBJECT_SCOPE
+ * [Default] LDAPConnectorConstants.ldapDefaultSearchScope
+ * is the default scope used, if no scope is defined (currently, ONELEVEL_SCOPE).
+ *
+ * 2. Column's name in source defines the LDAP attribute name.
+ * [Default] If no name in source is defined, then we attempt to use the column name
+ * as the LDAP attribute name.
+ *
+ *
+ * TODO: Implement paged searches -- the LDAP server must support VirtualListViews.
+ * TODO: Implement cancel.
+ * TODO: Add Sun/Netscape implementation, AD/OpenLDAP implementation.
+ *
+ *
+ * Note:
+ * Greater than is treated as >=
+ * Less-than is treater as <=
+ * If an LDAP entry has more than one entry for an attribute of interest (e.g. a select item), we only return the
+ * first occurrance. The first occurance is not predictably the same each time, either, according to the LDAP spec.
+ * If an attribute is not present, we return the empty string. Arguably, we could throw an exception.
+ *
+ * Sun LDAP won't support Sort Orders for very large datasets. So, we've set the sorting to NONCRITICAL, which
+ * allows Sun to ignore the sort order. This will result in the results to come back as unsorted, without any error.
+ *
+ * Removed support for ORDER BY for two reasons:
+ * 1: LDAP appears to have a limit to the number of records that
+ * can be server-side sorted. When the limit is reached, two things can happen:
+ * a. If sortControl is set to CRITICAL, then the search fails.
+ * b. If sortControl is NONCRITICAL, then the search returns, unsorted.
+ * We'd like to support ORDER BY, no matter how large the size, so we turn it off,
+ * and allow MetaMatrix to do it for us.
+ * 2: Supporting ORDER BY appears to negatively effect the query plan
+ * when cost analysis is used. We stop using dependent queries, and start
+ * using inner joins.
+ *
+ */
+
+package org.teiid.translator.ldap;
+
+import java.io.IOException;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.SizeLimitExceededException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.PagedResultsControl;
+import javax.naming.ldap.PagedResultsResponseControl;
+import javax.naming.ldap.SortControl;
+import javax.naming.ldap.SortKey;
+
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.Column;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+
+
+
+/**
+ * LDAPSyncQueryExecution is responsible for executing an LDAP search
+ * corresponding to a read-only "select" query from MetaMatrix.
+ */
+public class LDAPQueryExecution implements ResultSetExecution {
+
+ private static final String delimiter = "?"; //$NON-NLS-1$
+
+ private LDAPSearchDetails searchDetails;
+ private LdapContext ldapCtx;
+ private NamingEnumeration<?> searchEnumeration;
+ private LDAPExecutionFactory executionFactory;
+ private ExecutionContext executionContext;
+ private SearchControls ctrls;
+ private int resultCount;
+
+ /**
+ * Constructor
+ * @param executionMode the execution mode.
+ * @param ctx the execution context.
+ * @param logger the ConnectorLogger
+ * @param connection the LDAP Context
+ */
+ public LDAPQueryExecution(LdapContext ldapContext,LDAPSearchDetails search, SearchControls searchControls, LDAPExecutionFactory factory,ExecutionContext context) {
+ this.searchDetails = search;
+ this.ldapCtx = ldapContext;
+ this.ctrls = searchControls;
+ this.executionFactory = factory;
+ this.executionContext = context;
+ }
+
+ /**
+ * method to execute the supplied query
+ * @param query the query object.
+ * @param maxBatchSize the max batch size.
+ */
+ @Override
+ public void execute() throws TranslatorException {
+ String ctxName = this.searchDetails.getContextName();
+ String filter = this.searchDetails.getContextFilter();
+ if (ctxName == null || filter == null || this.ctrls == null) {
+ throw new TranslatorException("Search context, filter, or controls were null. Cannot execute search."); //$NON-NLS-1$
+ }
+ setRequestControls(null);
+ // Execute the search.
+ executeSearch();
+ }
+
+ /**
+ * Set the standard request controls
+ */
+ private void setRequestControls(byte[] cookie) throws TranslatorException {
+ List<Control> ctrl = new ArrayList<Control>();
+ SortKey[] keys = searchDetails.getSortKeys();
+ try {
+ if (keys != null) {
+ ctrl.add(new SortControl(keys, Control.NONCRITICAL));
+ }
+ if (this.executionFactory.usePagination()) {
+ ctrl.add(new PagedResultsControl(this.executionContext.getBatchSize(), cookie, Control.CRITICAL));
+ }
+ if (!ctrl.isEmpty()) {
+ this.ldapCtx.setRequestControls(ctrl.toArray(new Control[ctrl.size()]));
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Sort/pagination controls were created successfully."); //$NON-NLS-1$
+ }
+ } catch (NamingException ne) {
+ final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.setControlsError") + //$NON-NLS-1$
+ " : "+ne.getExplanation(); //$NON-NLS-1$
+ throw new TranslatorException(ne, msg);
+ } catch(IOException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ /**
+ * Perform the LDAP search against the subcontext, using the filter and
+ * search controls appropriate to the query and model metadata.
+ */
+ private void executeSearch() throws TranslatorException {
+ String filter = searchDetails.getContextFilter();
+ try {
+ searchEnumeration = this.ldapCtx.search("", filter, ctrls); //$NON-NLS-1$
+ } catch (NamingException ne) {
+ final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); //$NON-NLS-1$
+ throw new TranslatorException(ne, msg + " : " + ne.getExplanation()); //$NON-NLS-1$
+ } catch(Exception e) {
+ final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); //$NON-NLS-1$
+ throw new TranslatorException(e, msg);
+ }
+ }
+
+ // GHH 20080326 - attempt to implement cancel here. First try to
+ // close the searchEnumeration, then the search context.
+ // We are very conservative when closing the enumeration
+ // but less so when closing context, since it is safe to call close
+ // on contexts multiple times
+ @Override
+ public void cancel() throws TranslatorException {
+ close();
+ }
+
+ // GHH 20080326 - replaced existing implementation with the same
+ // code as used by cancel method. First try to
+ // close the searchEnumeration, then the search context
+ // We are very conservative when closing the enumeration
+ // but less so when closing context, since it is safe to call close
+ // on contexts multiple times
+ @Override
+ public void close() {
+ if (searchEnumeration != null) {
+ try {
+ searchEnumeration.close();
+ } catch (Exception e) { } // catch everything, because NamingEnumeration has undefined behavior if it previously hit an exception
+ }
+ if (ldapCtx != null) {
+ try {
+ ldapCtx.close();
+ } catch (NamingException ne) {
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12003, ne.getExplanation()));
+ }
+ }
+ }
+
+ /**
+ * Fetch the next batch of data from the LDAP searchEnumerationr result.
+ * @return the next Batch of results.
+ */
+ // GHH 20080326 - set all batches as last batch after an exception
+ // is thrown calling a method on the enumeration. Per Javadoc for
+ // javax.naming.NamingEnumeration, enumeration is invalid after an
+ // exception is thrown - by setting last batch indicator we prevent
+ // it from being used again.
+ // GHH 20080326 - also added return of explanation for generic
+ // NamingException
+ public List<?> next() throws TranslatorException {
+ try {
+ // The search has been executed, so process up to one batch of
+ // results.
+ List<?> result = null;
+ while (result == null && searchEnumeration != null && searchEnumeration.hasMore())
+ {
+ SearchResult searchResult = (SearchResult) searchEnumeration.next();
+ result = getRow(searchResult);
+ }
+
+ if (result == null && this.executionFactory.usePagination()) {
+ byte[] cookie = null;
+ Control[] controls = ldapCtx.getResponseControls();
+ if (controls != null) {
+ for (int i = 0; i < controls.length; i++) {
+ if (controls[i] instanceof PagedResultsResponseControl) {
+ PagedResultsResponseControl prrc = (PagedResultsResponseControl)controls[i];
+ cookie = prrc.getCookie();
+ }
+ }
+ }
+
+ if (cookie == null) {
+ return null;
+ }
+
+ setRequestControls(cookie);
+ executeSearch();
+ return next();
+ }
+
+ if (result != null) {
+ resultCount++;
+ }
+ return result;
+ } catch (SizeLimitExceededException e) {
+ if (resultCount != searchDetails.getCountLimit()) {
+ String msg = LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12008);
+ TranslatorException te = new TranslatorException(e, msg);
+ if (executionFactory.isExceptionOnSizeLimitExceeded()) {
+ throw te;
+ }
+ this.executionContext.addWarning(te);
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, msg);
+ }
+ return null; // GHH 20080326 - if size limit exceeded don't try to read more results
+ } catch (NamingException ne) {
+ throw new TranslatorException(ne, LDAPPlugin.Util.gs("ldap_error")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Create a row using the searchResult and add it to the supplied batch.
+ * @param batch the supplied batch
+ * @param result the search result
+ */
+ // GHH 20080326 - added fetching of DN of result, for directories that
+ // do not include it as an attribute
+ private List<?> getRow(SearchResult result) throws TranslatorException {
+ Attributes attrs = result.getAttributes();
+ String resultDN = result.getNameInNamespace(); // added GHH 20080326
+ ArrayList<Column> attributeList = searchDetails.getElementList();
+ List<Object> row = new ArrayList<Object>(attributeList.size());
+
+ for (Column col : attributeList) {
+ addResultToRow(col, resultDN, attrs, row); // GHH 20080326 - added resultDN parameter to call
+ }
+ return row;
+ }
+
+ /**
+ * Add Result to Row
+ * @param modelElement the model element
+ * @param attrs the attributes
+ * @param row the row
+ */
+ // GHH 20080326 - added resultDistinguishedName to method signature. If
+ // there is an element in the model named "DN" and there is no attribute
+ // with this name in the search result, we return this new parameter
+ // value for that column in the result
+ // GHH 20080326 - added handling of ClassCastException when non-string
+ // attribute is returned
+ private void addResultToRow(Column modelElement, String resultDistinguishedName, Attributes attrs, List<Object> row) throws TranslatorException {
+
+ String strResult = null;
+ String modelAttrName = IQueryToLdapSearchParser.getNameFromElement(modelElement);
+ Class<?> modelAttrClass = modelElement.getJavaType();
+
+ String multivalAttr = modelElement.getDefaultValue();
+
+ if(modelAttrName == null) {
+ final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.nullAttrError"); //$NON-NLS-1$
+ throw new TranslatorException(msg);
+ }
+
+ Attribute resultAttr = attrs.get(modelAttrName);
+
+ // If the attribute is not present, we return NULL.
+ if(resultAttr == null) {
+ // MPW - 2-20-07 - Changed from returning empty string to returning null.
+ //row.add("");
+ //logger.logTrace("Did not find a match for attribute named: " + modelAttrName);
+ // GHH 20080326 - return DN from input parameter
+ // if DN attribute is not present in search result
+ if (modelAttrName.toUpperCase().equals("DN")) { //$NON-NLS-1$
+ row.add(resultDistinguishedName);
+ }
+ else {
+ row.add(null);
+ }
+ return;
+ }
+ Object objResult = null;
+ try {
+ if(TypeFacility.RUNTIME_TYPES.STRING.equals(modelAttrClass) && "multivalued-concat".equalsIgnoreCase(multivalAttr)) { //$NON-NLS-1$
+ // mpw 5/09
+ // Order the multi-valued attrs alphabetically before creating a single string,
+ // using the delimiter to separate each token
+ ArrayList<String> multivalList = new ArrayList<String>();
+ NamingEnumeration<?> attrNE = resultAttr.getAll();
+ int length = 0;
+ while(attrNE.hasMore()) {
+ String val = (String)attrNE.next();
+ multivalList.add(val);
+ length += ((val==null?0:val.length()) + 1);
+ }
+ Collections.sort(multivalList);
+
+ StringBuilder multivalSB = new StringBuilder(length);
+ Iterator<String> itr = multivalList.iterator();
+ while(itr.hasNext()) {
+ multivalSB.append(itr.next());
+ if (itr.hasNext()) {
+ multivalSB.append(delimiter);
+ }
+ }
+ row.add(multivalSB.toString());
+ return;
+ }
+
+ //just a single value
+ objResult = resultAttr.get();
+ } catch (NamingException ne) {
+ final String msg = LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12004, modelAttrName) +" : "+ne.getExplanation(); //$NON-NLS-1$m
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg);
+ throw new TranslatorException(msg);
+ }
+
+ // GHH 20080326 - if attribute is not a string or empty, just
+ // return null.
+ // TODO - allow return of non-strings (always byte[]) as
+ // MM object (or blob). Perhaps also add directory-specific logic
+ // to deserialize byte[] attributes into Java objects
+ // when appropriate
+ if (objResult instanceof String) {
+ strResult = (String)objResult;
+ // MPW - 3.9.07 - Also return NULL when attribute is unset or empty string.
+ // There is no way to differentiate between being unset and being the empty string.
+ if(strResult.equals("")) { //$NON-NLS-1$
+ strResult = null;
+ }
+ }
+
+ // MPW: 3-11-07: Added support for java.lang.Integer conversion.
+ if(TypeFacility.RUNTIME_TYPES.TIMESTAMP.equals(modelAttrClass)) {
+ String timestampFormat = modelElement.getFormat();
+ if(timestampFormat == null) {
+ timestampFormat = LDAPConnectorConstants.ldapTimestampFormat;
+ }
+ SimpleDateFormat dateFormat = new SimpleDateFormat(timestampFormat);
+ try {
+ if(strResult != null) {
+ Date dateResult = dateFormat.parse(strResult);
+ Timestamp tsResult = new Timestamp(dateResult.getTime());
+ row.add(tsResult);
+ } else {
+ row.add(null);
+ }
+ } catch(ParseException pe) {
+ throw new TranslatorException(pe, LDAPPlugin.Util.getString("LDAPSyncQueryExecution.timestampParseFailed", modelAttrName)); //$NON-NLS-1$
+ }
+
+ // TODO: Extend support for more types in the future.
+ // Specifically, add support for byte arrays, since that's actually supported
+ // in the underlying data source.
+ } else {
+ row.add(strResult); //the Teiid type conversion logic will handle refine from here if necessary
+ }
+ }
+
+ // for testing.
+ LDAPSearchDetails getSearchDetails() {
+ return this.searchDetails;
+ }
+}
Property changes on: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSearchDetails.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSearchDetails.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSearchDetails.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -25,8 +25,6 @@
import java.util.ArrayList;
import java.util.Iterator;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.SortKey;
@@ -45,7 +43,6 @@
private String contextName;
private int searchScope;
private String contextFilter;
- private ArrayList attributeList;
private SortKey[] keys;
// private LdapSortKey[] netscapeKeys;
// If limit is set to -1, this means no limit (return all rows)
@@ -62,12 +59,11 @@
* @param limit
* @param elementList
*/
- public LDAPSearchDetails(String name, int searchScope, String filter, ArrayList attributeList, SortKey[] keys, long limit, ArrayList elementList) {
+ public LDAPSearchDetails(String name, int searchScope, String filter, SortKey[] keys, long limit, ArrayList elementList) {
this.contextName = name;
this.searchScope = searchScope;
this.contextFilter = filter;
- this.attributeList = attributeList;
this.keys = keys;
this.limit = limit;
this.elementList = elementList;
@@ -98,14 +94,6 @@
}
/**
- * get the attribute list
- * @return the attribute list
- */
- public ArrayList getAttributeList() {
- return attributeList;
- }
-
- /**
* get the element list
* @return the element list
*/
@@ -150,7 +138,7 @@
/**
* Print Method for Logging - (Detail level logging)
*/
- public void printDetailsToLog() throws NamingException {
+ public void printDetailsToLog() {
// Log Search Scope
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Search context: " + contextName); //$NON-NLS-1$
if(searchScope == SearchControls.SUBTREE_SCOPE) {
@@ -163,11 +151,12 @@
// Log Search Attributes
LogManager.logDetail(LogConstants.CTX_CONNECTOR,"Search attributes: "); //$NON-NLS-1$
- Iterator itr = this.attributeList.iterator();
+ Iterator itr = this.elementList.iterator();
int i = 0;
while(itr.hasNext()) {
- Attribute attr = (Attribute)itr.next();
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Attribute [" + i + "]: " + attr.getID() + " (" +attr.get().toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Column attr = (Column)itr.next();
+ String attrName = IQueryToLdapSearchParser.getNameFromElement(attr);
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Attribute [" + i + "]: " + attrName + " (" +attr.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
i++;
}
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -71,69 +71,45 @@
package org.teiid.translator.ldap;
-import java.io.IOException;
-import java.sql.Timestamp;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Iterator;
import java.util.List;
-import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.SizeLimitExceededException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.Control;
import javax.naming.ldap.LdapContext;
-import javax.naming.ldap.PagedResultsControl;
-import javax.naming.ldap.PagedResultsResponseControl;
-import javax.naming.ldap.SortControl;
-import javax.naming.ldap.SortKey;
import org.teiid.language.Select;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Column;
+import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ResultSetExecution;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.TypeFacility;
/**
* LDAPSyncQueryExecution is responsible for executing an LDAP search
- * corresponding to a read-only "select" query from MetaMatrix.
+ * corresponding to a read-only "select" query from Teiid.
*/
public class LDAPSyncQueryExecution implements ResultSetExecution {
- private static final String delimiter = "?"; //$NON-NLS-1$
-
- private LDAPSearchDetails searchDetails;
- private LdapContext ldapConnection;
- private LdapContext ldapCtx;
- private NamingEnumeration<?> searchEnumeration;
- private IQueryToLdapSearchParser parser;
+ protected LdapContext ldapConnection;
private Select query;
- private LDAPExecutionFactory executionFactory;
- private ExecutionContext executionContext;
- private SearchControls ctrls;
- private int resultCount;
-
+ protected LDAPExecutionFactory executionFactory;
+ protected ExecutionContext executionContext;
+ protected LDAPQueryExecution delegate;
+
/**
* Constructor
* @param executionMode the execution mode.
* @param ctx the execution context.
* @param logger the ConnectorLogger
- * @param ldapCtx the LDAP Context
+ * @param connection the LDAP Context
*/
- public LDAPSyncQueryExecution(Select query, LDAPExecutionFactory factory, ExecutionContext context, LdapContext ldapCtx) {
- this.ldapConnection = ldapCtx;
+ public LDAPSyncQueryExecution(Select query, LDAPExecutionFactory factory, ExecutionContext context, LdapContext connection) {
+ this.ldapConnection = connection;
this.query = query;
this.executionFactory = factory;
this.executionContext = context;
@@ -147,76 +123,46 @@
@Override
public void execute() throws TranslatorException {
// Parse the IQuery, and translate it into an appropriate LDAP search.
- this.parser = new IQueryToLdapSearchParser(this.executionFactory);
- searchDetails = parser.translateSQLQueryToLDAPSearch(query);
+ IQueryToLdapSearchParser parser = new IQueryToLdapSearchParser(this.executionFactory);
+ LDAPSearchDetails searchDetails = parser.translateSQLQueryToLDAPSearch(query);
// Create and configure the new search context.
- createSearchContext();
- ctrls = setSearchControls();
- String ctxName = searchDetails.getContextName();
- String filter = searchDetails.getContextFilter();
- if (ctxName == null || filter == null || ctrls == null) {
- throw new TranslatorException("Search context, filter, or controls were null. Cannot execute search."); //$NON-NLS-1$
- }
- setRequestControls(null);
- // Execute the search.
- executeSearch();
+ LdapContext context = createSearchContext(searchDetails.getContextName());
+ SearchControls ctrls = setSearchControls(searchDetails);
+
+ this.delegate = new LDAPQueryExecution(context, searchDetails, ctrls, this.executionFactory, this.executionContext);
+ this.delegate.execute();
}
- /**
- * Set the standard request controls
- */
- private void setRequestControls(byte[] cookie) throws TranslatorException {
- List<Control> ctrl = new ArrayList<Control>();
- SortKey[] keys = searchDetails.getSortKeys();
- try {
- if (keys != null) {
- ctrl.add(new SortControl(keys, Control.NONCRITICAL));
- }
- if (this.executionFactory.usePagination()) {
- ctrl.add(new PagedResultsControl(this.executionContext.getBatchSize(), cookie, Control.CRITICAL));
- }
- if (!ctrl.isEmpty()) {
- this.ldapCtx.setRequestControls(ctrl.toArray(new Control[ctrl.size()]));
- LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Sort/pagination controls were created successfully."); //$NON-NLS-1$
- }
- } catch (NamingException ne) {
- final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.setControlsError") + //$NON-NLS-1$
- " : "+ne.getExplanation(); //$NON-NLS-1$
- throw new TranslatorException(ne, msg);
- } catch(IOException e) {
- throw new TranslatorException(e);
- }
- }
+
/**
* Perform a lookup against the initial LDAP context, which
* sets the context to something appropriate for the search that is about to occur.
*
*/
- private void createSearchContext() throws TranslatorException {
+ protected LdapContext createSearchContext(String contextName) throws TranslatorException {
try {
- ldapCtx = (LdapContext) this.ldapConnection.lookup(searchDetails.getContextName());
+ return (LdapContext) this.ldapConnection.lookup(contextName);
} catch (NamingException ne) {
- if (searchDetails.getContextName() != null) {
- LogManager.logError(LogConstants.CTX_CONNECTOR, LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12002, searchDetails.getContextName()));
+ if (contextName != null) {
+ LogManager.logError(LogConstants.CTX_CONNECTOR, LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12002, contextName));
}
final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.createContextError"); //$NON-NLS-1$
throw new TranslatorException(msg);
}
}
-
/**
* Set the search controls
*/
- private SearchControls setSearchControls() {
+ private SearchControls setSearchControls(LDAPSearchDetails searchDetails) {
SearchControls ctrls = new SearchControls();
//ArrayList modelAttrList = searchDetails.getAttributeList();
ArrayList<Column> modelAttrList = searchDetails.getElementList();
String[] attrs = new String[modelAttrList.size()];
for (int i = 0; i < attrs.length; i++) {
- attrs[i] = (parser.getNameFromElement(modelAttrList.get(i)));
+ attrs[i] = (IQueryToLdapSearchParser.getNameFromElement(modelAttrList.get(i)));
}
ctrls.setSearchScope(searchDetails.getSearchScope());
@@ -229,255 +175,23 @@
return ctrls;
}
- /**
- * Perform the LDAP search against the subcontext, using the filter and
- * search controls appropriate to the query and model metadata.
- */
- private void executeSearch() throws TranslatorException {
- String filter = searchDetails.getContextFilter();
- try {
- searchEnumeration = this.ldapCtx.search("", filter, ctrls); //$NON-NLS-1$
- } catch (NamingException ne) {
- final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); //$NON-NLS-1$
- throw new TranslatorException(ne, msg + " : " + ne.getExplanation()); //$NON-NLS-1$
- } catch(Exception e) {
- final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); //$NON-NLS-1$
- throw new TranslatorException(e, msg);
- }
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ return this.delegate.next();
}
-
- // GHH 20080326 - attempt to implement cancel here. First try to
- // close the searchEnumeration, then the search context.
- // We are very conservative when closing the enumeration
- // but less so when closing context, since it is safe to call close
- // on contexts multiple times
+
@Override
public void cancel() throws TranslatorException {
- close();
+ this.delegate.cancel();
}
- // GHH 20080326 - replaced existing implementation with the same
- // code as used by cancel method. First try to
- // close the searchEnumeration, then the search context
- // We are very conservative when closing the enumeration
- // but less so when closing context, since it is safe to call close
- // on contexts multiple times
@Override
public void close() {
- if (searchEnumeration != null) {
- try {
- searchEnumeration.close();
- } catch (Exception e) { } // catch everything, because NamingEnumeration has undefined behavior if it previously hit an exception
- }
- if (ldapCtx != null) {
- try {
- ldapCtx.close();
- } catch (NamingException ne) {
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12003, ne.getExplanation()));
- }
- }
+ this.delegate.close();
}
- /**
- * Fetch the next batch of data from the LDAP searchEnumerationr result.
- * @return the next Batch of results.
- */
- // GHH 20080326 - set all batches as last batch after an exception
- // is thrown calling a method on the enumeration. Per Javadoc for
- // javax.naming.NamingEnumeration, enumeration is invalid after an
- // exception is thrown - by setting last batch indicator we prevent
- // it from being used again.
- // GHH 20080326 - also added return of explanation for generic
- // NamingException
- public List<?> next() throws TranslatorException {
- try {
- // The search has been executed, so process up to one batch of
- // results.
- List<?> result = null;
- while (result == null && searchEnumeration != null && searchEnumeration.hasMore())
- {
- SearchResult searchResult = (SearchResult) searchEnumeration.next();
- result = getRow(searchResult);
- }
-
- if (result == null && this.executionFactory.usePagination()) {
- byte[] cookie = null;
- Control[] controls = ldapCtx.getResponseControls();
- if (controls != null) {
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] instanceof PagedResultsResponseControl) {
- PagedResultsResponseControl prrc = (PagedResultsResponseControl)controls[i];
- cookie = prrc.getCookie();
- }
- }
- }
-
- if (cookie == null) {
- return null;
- }
-
- setRequestControls(cookie);
- executeSearch();
- return next();
- }
-
- if (result != null) {
- resultCount++;
- }
- return result;
- } catch (SizeLimitExceededException e) {
- if (resultCount != searchDetails.getCountLimit()) {
- String msg = LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12008);
- TranslatorException te = new TranslatorException(e, msg);
- if (executionFactory.isExceptionOnSizeLimitExceeded()) {
- throw te;
- }
- this.executionContext.addWarning(te);
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, msg);
- }
- return null; // GHH 20080326 - if size limit exceeded don't try to read more results
- } catch (NamingException ne) {
- throw new TranslatorException(ne, LDAPPlugin.Util.gs("ldap_error")); //$NON-NLS-1$
- }
+ // testing
+ LDAPQueryExecution getDelegate() {
+ return this.delegate;
}
-
- /**
- * Create a row using the searchResult and add it to the supplied batch.
- * @param batch the supplied batch
- * @param result the search result
- */
- // GHH 20080326 - added fetching of DN of result, for directories that
- // do not include it as an attribute
- private List<?> getRow(SearchResult result) throws TranslatorException {
- Attributes attrs = result.getAttributes();
- String resultDN = result.getNameInNamespace(); // added GHH 20080326
- ArrayList<Column> attributeList = searchDetails.getElementList();
- List<Object> row = new ArrayList<Object>(attributeList.size());
-
- for (Column col : attributeList) {
- addResultToRow(col, resultDN, attrs, row); // GHH 20080326 - added resultDN parameter to call
- }
- return row;
- }
-
- /**
- * Add Result to Row
- * @param modelElement the model element
- * @param attrs the attributes
- * @param row the row
- */
- // GHH 20080326 - added resultDistinguishedName to method signature. If
- // there is an element in the model named "DN" and there is no attribute
- // with this name in the search result, we return this new parameter
- // value for that column in the result
- // GHH 20080326 - added handling of ClassCastException when non-string
- // attribute is returned
- private void addResultToRow(Column modelElement, String resultDistinguishedName, Attributes attrs, List<Object> row) throws TranslatorException {
-
- String strResult = null;
- String modelAttrName = parser.getNameFromElement(modelElement);
- Class<?> modelAttrClass = modelElement.getJavaType();
-
- String multivalAttr = modelElement.getDefaultValue();
-
- if(modelAttrName == null) {
- final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.nullAttrError"); //$NON-NLS-1$
- throw new TranslatorException(msg);
- }
-
- Attribute resultAttr = attrs.get(modelAttrName);
-
- // If the attribute is not present, we return NULL.
- if(resultAttr == null) {
- // MPW - 2-20-07 - Changed from returning empty string to returning null.
- //row.add("");
- //logger.logTrace("Did not find a match for attribute named: " + modelAttrName);
- // GHH 20080326 - return DN from input parameter
- // if DN attribute is not present in search result
- if (modelAttrName.toUpperCase().equals("DN")) { //$NON-NLS-1$
- row.add(resultDistinguishedName);
- }
- else {
- row.add(null);
- }
- return;
- }
- Object objResult = null;
- try {
- if(TypeFacility.RUNTIME_TYPES.STRING.equals(modelAttrClass) && "multivalued-concat".equalsIgnoreCase(multivalAttr)) { //$NON-NLS-1$
- // mpw 5/09
- // Order the multi-valued attrs alphabetically before creating a single string,
- // using the delimiter to separate each token
- ArrayList<String> multivalList = new ArrayList<String>();
- NamingEnumeration<?> attrNE = resultAttr.getAll();
- int length = 0;
- while(attrNE.hasMore()) {
- String val = (String)attrNE.next();
- multivalList.add(val);
- length += ((val==null?0:val.length()) + 1);
- }
- Collections.sort(multivalList);
-
- StringBuilder multivalSB = new StringBuilder(length);
- Iterator<String> itr = multivalList.iterator();
- while(itr.hasNext()) {
- multivalSB.append(itr.next());
- if (itr.hasNext()) {
- multivalSB.append(delimiter);
- }
- }
- row.add(multivalSB.toString());
- return;
- }
-
- //just a single value
- objResult = resultAttr.get();
- } catch (NamingException ne) {
- final String msg = LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12004, modelAttrName) +" : "+ne.getExplanation(); //$NON-NLS-1$m
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg);
- throw new TranslatorException(msg);
- }
-
- // GHH 20080326 - if attribute is not a string or empty, just
- // return null.
- // TODO - allow return of non-strings (always byte[]) as
- // MM object (or blob). Perhaps also add directory-specific logic
- // to deserialize byte[] attributes into Java objects
- // when appropriate
- if (objResult instanceof String) {
- strResult = (String)objResult;
- // MPW - 3.9.07 - Also return NULL when attribute is unset or empty string.
- // There is no way to differentiate between being unset and being the empty string.
- if(strResult.equals("")) { //$NON-NLS-1$
- strResult = null;
- }
- }
-
- // MPW: 3-11-07: Added support for java.lang.Integer conversion.
- if(TypeFacility.RUNTIME_TYPES.TIMESTAMP.equals(modelAttrClass)) {
- String timestampFormat = modelElement.getFormat();
- if(timestampFormat == null) {
- timestampFormat = LDAPConnectorConstants.ldapTimestampFormat;
- }
- SimpleDateFormat dateFormat = new SimpleDateFormat(timestampFormat);
- try {
- if(strResult != null) {
- Date dateResult = dateFormat.parse(strResult);
- Timestamp tsResult = new Timestamp(dateResult.getTime());
- row.add(tsResult);
- } else {
- row.add(null);
- }
- } catch(ParseException pe) {
- throw new TranslatorException(pe, LDAPPlugin.Util.getString("LDAPSyncQueryExecution.timestampParseFailed", modelAttrName)); //$NON-NLS-1$
- }
-
- // TODO: Extend support for more types in the future.
- // Specifically, add support for byte arrays, since that's actually supported
- // in the underlying data source.
- } else {
- row.add(strResult); //the Teiid type conversion logic will handle refine from here if necessary
- }
- }
-
}
Modified: trunk/connectors/translator-ldap/src/main/resources/org/teiid/translator/ldap/i18n.properties
===================================================================
--- trunk/connectors/translator-ldap/src/main/resources/org/teiid/translator/ldap/i18n.properties 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-ldap/src/main/resources/org/teiid/translator/ldap/i18n.properties 2012-09-25 22:15:11 UTC (rev 4472)
@@ -67,4 +67,8 @@
TEIID12006=Received IScalarSubquery, but it is not supported. Check capabilties.
TEIID12007=Received ISearchedCaseExpression, but it is not supported. Check capabilties.
TEIID12002=Attempted to search context: {0}
-TEIID12008=LDAP Search results exceeded size limit. Results may be incomplete.
\ No newline at end of file
+TEIID12008=LDAP Search results exceeded size limit. Results may be incomplete.
+TEIID12009=Unknown LDAP Request; the query string must start with [search|create|update|delete]
+TEIID12010=The DN is not defined; DN should be the token after the marker tokens [search|create|update|delete]
+TEIID12011=attributes are not defined; use "attributes=..." form using the comma delimited to specify all the names.
+TEIID12012=create/update operation did not find the value for attribute {0}; Each attribute value is defined as the separate parameter in the procedure call.
\ No newline at end of file
Modified: trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -27,7 +27,6 @@
import java.util.Iterator;
import java.util.List;
-import javax.naming.directory.Attribute;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.SortKey;
@@ -92,7 +91,7 @@
// Get all of the actual values
String contextName = searchDetails.getContextName();
String contextFilter = searchDetails.getContextFilter();
- List attrList = searchDetails.getAttributeList();
+ List attrList = searchDetails.getElementList();
long countLimit = searchDetails.getCountLimit();
int searchScope = searchDetails.getSearchScope();
SortKey[] sortKeys = searchDetails.getSortKeys();
@@ -105,7 +104,7 @@
Iterator iter = attrList.iterator();
Iterator eIter = expectedAttrNameList.iterator();
while(iter.hasNext()&&eIter.hasNext()) {
- String actualName = ((Attribute)iter.next()).getID();
+ String actualName = IQueryToLdapSearchParser.getNameFromElement((Column)iter.next());
String expectedName = (String)eIter.next();
assertEquals(actualName, expectedName);
}
Added: trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestLDAPDirectQueryExecution.java
===================================================================
--- trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestLDAPDirectQueryExecution.java (rev 0)
+++ trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestLDAPDirectQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -0,0 +1,187 @@
+/*
+ * 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.ldap;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.math.BigDecimal;
+
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.ModificationItem;
+import javax.naming.ldap.LdapContext;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.teiid.cdk.api.TranslationUtility;
+import org.teiid.cdk.unittest.FakeTranslationFactory;
+import org.teiid.language.Command;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TranslatorException;
+
+@SuppressWarnings("nls")
+public class TestLDAPDirectQueryExecution {
+
+ private static LDAPExecutionFactory TRANSLATOR;
+
+ @BeforeClass
+ public static void setUp() throws TranslatorException {
+ TRANSLATOR = new LDAPExecutionFactory();
+ TRANSLATOR.start();
+ }
+
+ @Test public void testSearch() throws Exception {
+ String input = "exec native('search;context-name=corporate;filter=(objectClass=*);count-limit=5;timout=6;search-scope=ONELEVEL_SCOPE;attributes=uid,cn')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ LdapContext connection = Mockito.mock(LdapContext.class);
+ LdapContext ctx = Mockito.mock(LdapContext.class);
+ Mockito.stub(connection.lookup("corporate")).toReturn(ctx);
+
+ LDAPDirectSearchQueryExecution execution = (LDAPDirectSearchQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+ LDAPSearchDetails details = execution.getDelegate().getSearchDetails();
+
+ assertEquals("corporate", details.getContextName());
+ assertEquals("(objectClass=*)", details.getContextFilter());
+ assertEquals(5, details.getCountLimit());
+ assertEquals(1, details.getSearchScope());
+ assertEquals(2, details.getElementList().size());
+ assertEquals("uid", details.getElementList().get(0).getName());
+ assertEquals("cn", details.getElementList().get(1).getName());
+ }
+
+ @Test public void testWithoutMarker() throws Exception {
+ String input = "exec native('context-name=corporate;filter=(objectClass=*);count-limit=5;timout=6;search-scope=ONELEVEL_SCOPE;attributes=uid,cn')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ LdapContext connection = Mockito.mock(LdapContext.class);
+ LdapContext ctx = Mockito.mock(LdapContext.class);
+ Mockito.stub(connection.lookup("corporate")).toReturn(ctx);
+
+ try {
+ LDAPDirectSearchQueryExecution execution = (LDAPDirectSearchQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+ fail("the above should have thrown exception");
+ } catch (ClassCastException e) {
+ }
+ }
+
+ @Test public void testDelete() throws Exception {
+ String input = "exec native('delete;uid=doe,ou=people,o=teiid.org')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ LdapContext connection = Mockito.mock(LdapContext.class);
+ LdapContext ctx = Mockito.mock(LdapContext.class);
+ Mockito.stub(connection.lookup("")).toReturn(ctx);
+
+ LDAPDirectCreateUpdateDeleteQueryExecution execution = (LDAPDirectCreateUpdateDeleteQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+ Mockito.verify(ctx, Mockito.times(1)).destroySubcontext("uid=doe,ou=people,o=teiid.org");
+ }
+
+ @Test public void testUpdate() throws Exception {
+ String input = "exec native('update;uid=doe,ou=people,o=teiid.org;attributes=one,two,three', 'one', 2, 3.0)";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ LdapContext connection = Mockito.mock(LdapContext.class);
+ LdapContext ctx = Mockito.mock(LdapContext.class);
+ Mockito.stub(connection.lookup("")).toReturn(ctx);
+
+ LDAPDirectCreateUpdateDeleteQueryExecution execution = (LDAPDirectCreateUpdateDeleteQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+ ArgumentCaptor<String> nameArgument = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<ModificationItem[]> modificationItemArgument = ArgumentCaptor.forClass(ModificationItem[].class);
+ Mockito.verify(ctx).modifyAttributes(nameArgument.capture(),modificationItemArgument.capture());
+
+ assertEquals("uid=doe,ou=people,o=teiid.org", nameArgument.getValue());
+ assertEquals("one", modificationItemArgument.getValue()[0].getAttribute().getID());
+ assertEquals("one", modificationItemArgument.getValue()[0].getAttribute().get());
+ assertEquals("two", modificationItemArgument.getValue()[1].getAttribute().getID());
+ assertEquals(2, modificationItemArgument.getValue()[1].getAttribute().get());
+ assertEquals("three", modificationItemArgument.getValue()[2].getAttribute().getID());
+ assertEquals(new BigDecimal("3.0"), modificationItemArgument.getValue()[2].getAttribute().get());
+ }
+
+ @Test public void testCreate() throws Exception {
+ String input = "exec native('create;uid=doe,ou=people,o=teiid.org;attributes=one,two,three', 'one', 2, 3.0)";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ LdapContext connection = Mockito.mock(LdapContext.class);
+ LdapContext ctx = Mockito.mock(LdapContext.class);
+ Mockito.stub(connection.lookup("")).toReturn(ctx);
+
+ LDAPDirectCreateUpdateDeleteQueryExecution execution = (LDAPDirectCreateUpdateDeleteQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+ ArgumentCaptor<String> nameArgument = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<BasicAttributes> createItemArgument = ArgumentCaptor.forClass(BasicAttributes.class);
+ Mockito.verify(ctx).createSubcontext(nameArgument.capture(), createItemArgument.capture());
+
+ assertEquals("uid=doe,ou=people,o=teiid.org", nameArgument.getValue());
+ assertEquals("one", createItemArgument.getValue().get("one").getID());
+ assertEquals("one", createItemArgument.getValue().get("one").get());
+ assertEquals("two", createItemArgument.getValue().get("two").getID());
+ assertEquals(2, createItemArgument.getValue().get("two").get());
+ assertEquals("three", createItemArgument.getValue().get("three").getID());
+ assertEquals(new BigDecimal("3.0"), createItemArgument.getValue().get("three").get());
+ }
+
+ @Test public void testCreateFail() throws Exception {
+ String input = "exec native('create;uid=doe,ou=people,o=teiid.org;attributes=one,two,three', 'one')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ LdapContext connection = Mockito.mock(LdapContext.class);
+ LdapContext ctx = Mockito.mock(LdapContext.class);
+ Mockito.stub(connection.lookup("")).toReturn(ctx);
+
+ try {
+ LDAPDirectCreateUpdateDeleteQueryExecution execution = (LDAPDirectCreateUpdateDeleteQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+ fail("should have failed because there are not enough values");
+ } catch (TranslatorException e) {
+ }
+ }
+}
Property changes on: trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestLDAPDirectQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java
===================================================================
--- trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -23,26 +23,22 @@
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.List;
import javax.sql.DataSource;
import org.olap4j.OlapConnection;
import org.olap4j.OlapWrapper;
-import org.teiid.language.Call;
+import org.teiid.language.Argument;
+import org.teiid.language.Command;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.metadata.MetadataFactory;
-import org.teiid.metadata.Procedure;
-import org.teiid.metadata.ProcedureParameter;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.metadata.BaseColumn.NullType;
-import org.teiid.metadata.ProcedureParameter.Type;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
-import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.ResultSetExecution;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.TypeFacility;
@Translator(name="olap", description="A translator for OLAP Cubes")
public class OlapExecutionFactory extends ExecutionFactory<DataSource, Connection> {
@@ -50,23 +46,13 @@
public OlapExecutionFactory() {
setSourceRequiredForMetadata(false);
+ setSupportsNativeQueries(true);
+ setNativeQueryProcedureName(INVOKE_MDX);
}
- @Override
- public void getMetadata(MetadataFactory metadataFactory, Connection conn) throws TranslatorException {
- Procedure p = metadataFactory.addProcedure(INVOKE_MDX);
- p.setAnnotation("Invokes a XMLA webservice with provided MDX query that returns an XML result"); //$NON-NLS-1$
-
- // mdx query in xml form
- ProcedureParameter param = metadataFactory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
- param.setAnnotation("The MDX query to execute"); //$NON-NLS-1$
- param.setNullType(NullType.Nullable);
- metadataFactory.addProcedureResultSetColumn("tuple", TypeFacility.RUNTIME_NAMES.OBJECT, p); //$NON-NLS-1$
- }
-
@Override
- public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection connection) throws TranslatorException {
- return new OlapQueryExecution(command, unwrap(connection), executionContext, this);
+ public ResultSetExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection connection) throws TranslatorException {
+ return new OlapQueryExecution(arguments, command, unwrap(connection), executionContext, this);
}
private OlapConnection unwrap(Connection conn) throws TranslatorException {
Modified: trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
===================================================================
--- trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -35,7 +35,6 @@
import org.olap4j.Position;
import org.olap4j.metadata.Member;
import org.teiid.language.Argument;
-import org.teiid.language.Call;
import org.teiid.language.Command;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -57,8 +56,10 @@
private CellSetAxis columnsAxis;
private int colWidth;
private ListIterator<Position> rowPositionIterator;
+ private String mdxQuery;
- public OlapQueryExecution(Command command, OlapConnection connection, ExecutionContext context, OlapExecutionFactory executionFactory) {
+ public OlapQueryExecution(List<Argument> arguments, Command command, OlapConnection connection, ExecutionContext context, OlapExecutionFactory executionFactory) {
+ this.mdxQuery = (String) arguments.get(0).getArgumentValue().getValue();;
this.command = command;
this.connection = connection;
this.context = context;
@@ -68,11 +69,7 @@
@Override
public void execute() throws TranslatorException {
try {
- Call procedure = (Call) this.command;
- List<Argument> arguments = procedure.getArguments();
- String mdxQuery = (String) arguments.get(0).getArgumentValue().getValue();
stmt = this.connection.createStatement();
-
cellSet = stmt.executeOlapQuery(mdxQuery);
CellSetAxis rowAxis = this.cellSet.getAxes().get(Axis.ROWS.axisOrdinal());
rowPositionIterator = rowAxis.iterator();
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -29,6 +29,7 @@
import javax.resource.cci.ConnectionFactory;
+import org.teiid.language.Argument;
import org.teiid.language.Call;
import org.teiid.language.Command;
import org.teiid.language.QueryExpression;
@@ -49,6 +50,7 @@
import org.teiid.translator.TypeFacility;
import org.teiid.translator.UpdateExecution;
import org.teiid.translator.salesforce.execution.DeleteExecutionImpl;
+import org.teiid.translator.salesforce.execution.DirectQueryExecution;
import org.teiid.translator.salesforce.execution.InsertExecutionImpl;
import org.teiid.translator.salesforce.execution.ProcedureExecutionParentImpl;
import org.teiid.translator.salesforce.execution.QueryExecutionImpl;
@@ -68,6 +70,7 @@
setSupportsOrderBy(false);
setSupportsOuterJoins(true);
setSupportedJoinCriteria(SupportedJoinCriteria.KEY);
+ setSupportsNativeQueries(true);
}
@TranslatorProperty(display="Audit Model Fields", advanced=true)
@@ -113,7 +116,13 @@
throws TranslatorException {
return new ProcedureExecutionParentImpl(command, connection, metadata, executionContext);
}
+
@Override
+ public ResultSetExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, SalesforceConnection connection) throws TranslatorException {
+ return new DirectQueryExecution(arguments, command, connection, metadata, executionContext);
+ }
+
+ @Override
public void getMetadata(MetadataFactory metadataFactory, SalesforceConnection connection) throws TranslatorException {
MetadataProcessor processor = new MetadataProcessor(connection,metadataFactory, this);
processor.processMetadata();
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForcePlugin.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForcePlugin.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForcePlugin.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -43,6 +43,10 @@
public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,BUNDLE_NAME,ResourceBundle.getBundle(BUNDLE_NAME));
public static enum Event implements BundleUtil.Event{
- TEIID13001
+ TEIID13001,
+ TEIID13002,
+ TEIID13003,
+ TEIID13004,
+ TEIID13005,
}
}
Added: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DirectQueryExecution.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DirectQueryExecution.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DirectQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -0,0 +1,289 @@
+/*
+ * 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.salesforce.execution;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.resource.ResourceException;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.teiid.language.Argument;
+import org.teiid.language.Command;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.salesforce.SalesForcePlugin;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.w3c.dom.Element;
+
+import com.sforce.soap.partner.QueryResult;
+import com.sforce.soap.partner.sobject.SObject;
+
+public class DirectQueryExecution implements ProcedureExecution {
+
+ private static final String DELETE_IDS = "ids"; //$NON-NLS-1$
+ private static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ private static final String TYPE = "type"; //$NON-NLS-1$
+ private static final String ID = "id"; //$NON-NLS-1$
+
+ private List<Argument> arguments;
+ private Command command;
+ private SalesforceConnection connection;
+ private RuntimeMetadata metadata;
+ private ExecutionContext context;
+ private QueryResult results;
+ private List<List<Object>> currentBatch;
+ private int updateCount = -1;
+ private boolean updateQuery = false;
+
+ public DirectQueryExecution(List<Argument> arguments, Command command, SalesforceConnection connection, RuntimeMetadata metadata, ExecutionContext context) {
+ this.arguments = arguments;
+ this.command = command;
+ this.connection = connection;
+ this.metadata = metadata;
+ this.context = context;
+ }
+
+ @Override
+ public void execute() throws TranslatorException {
+ String query = (String)this.arguments.get(0).getArgumentValue().getValue();
+ if (query.startsWith("search;")) { //$NON-NLS-1$
+ doSelect(query.substring(7));
+ }
+ else if (query.startsWith("create;")) { //$NON-NLS-1$
+ doInsert(query.substring(7));
+ }
+ else if (query.startsWith("update;")) { //$NON-NLS-1$
+ doUpdate(query.substring(7));
+ }
+ else if (query.startsWith("delete;")) { //$NON-NLS-1$
+ doDelete(query.substring(7));
+ }
+ else {
+ throw new TranslatorException(SalesForcePlugin.Util.gs(SalesForcePlugin.Event.TEIID13002));
+ }
+
+ }
+
+ private void doDelete(String query) throws TranslatorException {
+ List<String> ids = getIds(query);
+ try {
+ this.updateCount = this.connection.delete(ids.toArray(new String[ids.size()]));
+ this.updateQuery = true;
+ } catch (ResourceException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ private void doUpdate(String query) throws TranslatorException {
+ DataPayload payload = buildDataPlayload(query, this.arguments);
+ try {
+ this.updateCount = this.connection.update(Arrays.asList(payload));
+ this.updateQuery = true;
+ } catch (ResourceException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ private void doInsert(String query) throws TranslatorException {
+ DataPayload payload = buildDataPlayload(query, this.arguments);
+ try {
+ this.updateCount = this.connection.create(payload);
+ this.updateQuery = true;
+ } catch (ResourceException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ private void doSelect(String query) throws TranslatorException {
+ try {
+ this.results = this.connection.query(query, this.context.getBatchSize(), Boolean.FALSE);
+ } catch (ResourceException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ List<?> vals = getRow(this.results);
+ if (vals == null) {
+ return null;
+ }
+ List<Object[]> row = new ArrayList<Object[]>(1);
+ row.add(vals.toArray(new Object[vals.size()]));
+ return row;
+ }
+
+ private List<Object> getRow(QueryResult result) throws TranslatorException {
+
+ // for insert/update/delete clauses
+ if (this.updateQuery) {
+ if (this.updateCount != -1) {
+ List updateResult = Arrays.asList(this.updateCount);
+ this.updateCount = -1;
+ return updateResult;
+ }
+ return null;
+ }
+
+ // select clauses
+ List<Object> row = null;
+
+ if(this.currentBatch == null) {
+ this.currentBatch = loadBatch(this.results);
+ }
+
+ if(!this.currentBatch.isEmpty()) {
+ row = this.currentBatch.remove(0);
+ }
+ else {
+ if(!result.isDone()) {
+ // fetch more results
+ try {
+ this.results = this.connection.queryMore(results.getQueryLocator(), context.getBatchSize());
+ } catch (ResourceException e) {
+ throw new TranslatorException(e);
+ }
+ this.currentBatch = loadBatch(this.results);
+
+ // read next row
+ row = this.currentBatch.remove(0);
+ }
+ }
+ return row;
+ }
+
+ private List<List<Object>> loadBatch(QueryResult queryResult) {
+ List<List<Object>> batch = new ArrayList<List<Object>>();
+ for(SObject sObject : queryResult.getRecords()) {
+ List<Object> fields = sObject.getAny();
+ List<Object> row = new ArrayList<Object>();
+ if (sObject.getId() != null) {
+ row.add(sObject.getId());
+ }
+ for (Object field:fields) {
+ Element elem = (Element)field;
+ String value = elem.getTextContent();
+ row.add(value);
+ }
+ batch.add(row);
+ }
+ return batch;
+ }
+
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+ }
+
+ private ArrayList<String> getIds(String query) throws TranslatorException {
+ StringTokenizer st = new StringTokenizer(query, ";"); //$NON-NLS-1$
+ if (!st.hasMoreTokens()) {
+ throw new TranslatorException(SalesForcePlugin.Util.gs(SalesForcePlugin.Event.TEIID13003));
+ }
+
+ ArrayList<String> ids = new ArrayList<String>();
+
+ while(st.hasMoreElements()) {
+ String var = st.nextToken();
+ int index = var.indexOf('=');
+ if (index == -1) {
+ continue;
+ }
+ String key = var.substring(0, index).trim().toLowerCase();
+ String value = var.substring(index+1).trim();
+
+ if (key.equalsIgnoreCase(DELETE_IDS)) {
+ StringTokenizer attrTokens = new StringTokenizer(value, ","); //$NON-NLS-1$
+ while (attrTokens.hasMoreElements()) {
+ ids.add(attrTokens.nextToken());
+ }
+ }
+ }
+ return ids;
+ }
+
+ private DataPayload buildDataPlayload(String query, List<Argument> arguments) throws TranslatorException {
+ StringTokenizer st = new StringTokenizer(query, ";"); //$NON-NLS-1$
+ if (!st.hasMoreTokens()) {
+ throw new TranslatorException(SalesForcePlugin.Util.gs(SalesForcePlugin.Event.TEIID13004));
+ }
+
+ ArrayList<JAXBElement> attributes = new ArrayList<JAXBElement>();
+ String type = null;
+ String id = null;
+
+ while(st.hasMoreElements()) {
+ String var = st.nextToken();
+
+ int index = var.indexOf('=');
+ if (index == -1) {
+ continue;
+ }
+ String key = var.substring(0, index).trim().toLowerCase();
+ String value = var.substring(index+1).trim();
+
+
+ if (key.equalsIgnoreCase(ATTRIBUTES)) {
+ StringTokenizer attrTokens = new StringTokenizer(value, ","); //$NON-NLS-1$
+ int attrCount = 1;
+ while(attrTokens.hasMoreElements()) {
+ String name = attrTokens.nextToken().trim();
+ if (arguments.size() <= attrCount) {
+ throw new TranslatorException(SalesForcePlugin.Util.gs(SalesForcePlugin.Event.TEIID13005, name));
+ }
+ Argument argument = arguments.get(attrCount++);
+ Object anObj = argument.getArgumentValue().getValue();
+ QName qname = new QName(name);
+ @SuppressWarnings( "unchecked" )
+ JAXBElement jbe = new JAXBElement( qname, String.class, anObj );
+ attributes.add(jbe);
+ }
+ }
+ else if (key.equalsIgnoreCase(TYPE)) {
+ type = value;
+ }
+ else if (key.equalsIgnoreCase(ID)) {
+ id = value;
+ }
+ }
+ DataPayload payload = new DataPayload();
+ payload.setID(id);
+ payload.setType(type);
+ payload.setMessageElements(attributes);
+ return payload;
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ return null;
+ }
+}
Property changes on: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DirectQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/salesforce/i18n.properties
===================================================================
--- trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/salesforce/i18n.properties 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/salesforce/i18n.properties 2012-09-25 22:15:11 UTC (rev 4472)
@@ -37,4 +37,8 @@
CriteriaVisitor.LIKE.not.supported.on.Id=LIKE criteria are not allowed on columns of native type Id
CriteriaVisitor.LIKE.not.supported.on.multiselect=LIKE criteria are not allowed on columns of native type Multi-Select Picklist
-TEIID13001=Unknown type returned by SalesForce: {0}
\ No newline at end of file
+TEIID13001=Unknown type returned by SalesForce: {0}
+TEIID13002=Unknown request; query must start with one of [search|create|update|delete]
+TEIID13003=The query is missing "id=x,y.." values.
+TEIID13004=The query is missing type, id and attribute values.
+TEIID13005=The attribute count does not match with the value parameters supplied.
\ No newline at end of file
Added: trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestSalesForceDirectQueryExecution.java
===================================================================
--- trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestSalesForceDirectQueryExecution.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestSalesForceDirectQueryExecution.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -0,0 +1,210 @@
+/*
+ * 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.salesforce.execution;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.teiid.cdk.api.TranslationUtility;
+import org.teiid.cdk.unittest.FakeTranslationFactory;
+import org.teiid.language.Command;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.salesforce.SalesForceExecutionFactory;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.w3c.dom.Element;
+
+import com.sforce.soap.partner.QueryResult;
+import com.sforce.soap.partner.sobject.SObject;
+
+@SuppressWarnings("nls")
+public class TestSalesForceDirectQueryExecution {
+
+ private static SalesForceExecutionFactory TRANSLATOR;
+
+ @BeforeClass
+ public static void setUp() throws TranslatorException {
+ TRANSLATOR = new SalesForceExecutionFactory();
+ TRANSLATOR.start();
+ }
+
+ @Test public void testSearch() throws Exception {
+ String input = "exec native('search;SELECT Account.Id, Account.Type, Account.Name FROM Account')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ SalesforceConnection connection = Mockito.mock(SalesforceConnection.class);
+
+ QueryResult qr = Mockito.mock(QueryResult.class);
+ Mockito.stub(qr.isDone()).toReturn(true);
+
+ ArrayList<SObject> results = new ArrayList<SObject>();
+ ArrayList<Object> values = new ArrayList<Object>();
+
+ SObject s = Mockito.mock(SObject.class);
+ //Mockito.stub(s.getId()).toReturn("theID");
+ Mockito.stub(s.getType()).toReturn("Account");
+ results.add(s);
+
+ Element e1 = Mockito.mock(Element.class);
+ Mockito.stub(e1.getTextContent()).toReturn("The ID");
+ values.add(e1);
+
+ Element e2 = Mockito.mock(Element.class);
+ Mockito.stub(e2.getTextContent()).toReturn("The Type");
+ values.add(e2);
+
+ Element e3 = Mockito.mock(Element.class);
+ Mockito.stub(e3.getTextContent()).toReturn("The Name");
+ values.add(e3);
+
+ Mockito.stub(s.getAny()).toReturn(values);
+ Mockito.stub(qr.getRecords()).toReturn(results);
+ Mockito.stub(connection.query("SELECT Account.Id, Account.Type, Account.Name FROM Account", 0, false)).toReturn(qr);
+
+ DirectQueryExecution execution = (DirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+ Mockito.verify(connection, Mockito.times(1)).query("SELECT Account.Id, Account.Type, Account.Name FROM Account", 0, false);
+
+ assertArrayEquals(new Object[] {"The ID", "The Type", "The Name"}, (Object[])execution.next().get(0));
+
+ }
+
+ @Test public void testWithoutMarker() throws Exception {
+ String input = "exec native('salesforce query')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ SalesforceConnection connection = Mockito.mock(SalesforceConnection.class);
+
+ try {
+ DirectQueryExecution execution = (DirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+ fail("the above should have thrown exception");
+ } catch (TranslatorException e) {
+ }
+ }
+
+ @Test public void testDelete() throws Exception {
+ String input = "exec native('delete;ids=id1,id2')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ SalesforceConnection connection = Mockito.mock(SalesforceConnection.class);
+
+ ArgumentCaptor<String[]> payloadArgument = ArgumentCaptor.forClass(String[].class);
+ Mockito.stub(connection.delete(payloadArgument.capture())).toReturn(23);
+
+ DirectQueryExecution execution = (DirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+ Mockito.verify(connection, Mockito.times(1)).delete(payloadArgument.capture());
+
+ assertEquals("id1", payloadArgument.getValue()[0]);
+ assertEquals("id2", payloadArgument.getValue()[1]);
+
+ assertArrayEquals(new Object[] {23}, (Object[])execution.next().get(0));
+ }
+
+ @Test public void testUpdate() throws Exception {
+ String input = "exec native('update;id=pk;type=table;attributes=one,two,three', 'one', 2, 3.0)";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ SalesforceConnection connection = Mockito.mock(SalesforceConnection.class);
+
+ ArgumentCaptor<List> payloadArgument = ArgumentCaptor.forClass(List.class);
+ Mockito.stub(connection.update(payloadArgument.capture())).toReturn(23);
+
+ DirectQueryExecution execution = (DirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+ Mockito.verify(connection).update(payloadArgument.capture());
+
+ assertEquals(1, payloadArgument.getValue().size());
+ assertEquals("pk", ((DataPayload)payloadArgument.getValue().get(0)).getID());
+ assertEquals("table", ((DataPayload)payloadArgument.getValue().get(0)).getType());
+ assertEquals(3, ((DataPayload)payloadArgument.getValue().get(0)).getMessageElements().size());
+
+ assertArrayEquals(new Object[] {23}, (Object[])execution.next().get(0));
+ }
+
+ @Test public void testCreate() throws Exception {
+ String input = "exec native('create;id=pk;type=table;attributes=one,two,three', 'one', 2, 3.0)";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ SalesforceConnection connection = Mockito.mock(SalesforceConnection.class);
+
+ ArgumentCaptor<DataPayload> payloadArgument = ArgumentCaptor.forClass(DataPayload.class);
+ Mockito.stub(connection.create(payloadArgument.capture())).toReturn(23);
+
+ DirectQueryExecution execution = (DirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+
+
+ Mockito.verify(connection).create(payloadArgument.capture());
+
+ assertEquals("pk", payloadArgument.getValue().getID());
+ assertEquals("table", payloadArgument.getValue().getType());
+ assertEquals(3, payloadArgument.getValue().getMessageElements().size());
+
+ assertArrayEquals(new Object[] {23}, (Object[])execution.next().get(0));
+ }
+
+ @Test public void testCreateFail() throws Exception {
+ String input = "exec native('create;id=pk;type=table;attributes=one,two,three', 'one')";
+
+ TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
+ Command command = util.parseCommand(input);
+ ExecutionContext ec = Mockito.mock(ExecutionContext.class);
+ RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
+ SalesforceConnection connection = Mockito.mock(SalesforceConnection.class);
+
+ try {
+ DirectQueryExecution execution = (DirectQueryExecution)TRANSLATOR.createExecution(command, ec, rm, connection);
+ execution.execute();
+ fail("should have failed because there are not enough values");
+ } catch (TranslatorException e) {
+ }
+ }
+}
Property changes on: trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/TestSalesForceDirectQueryExecution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/engine/src/main/java/org/teiid/query/metadata/DirectQueryMetadataRepository.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/DirectQueryMetadataRepository.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/DirectQueryMetadataRepository.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -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.query.metadata;
+
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.ProcedureParameter.Type;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+
+/**
+ * This Metadata repository adds the "native" procedure to all the execution factories that support them.
+ */
+public class DirectQueryMetadataRepository extends BaseMetadataRepository {
+
+ @Override
+ public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException {
+
+ if (executionFactory != null && executionFactory.supportsNativeQueries()) {
+ Procedure p = factory.addProcedure(executionFactory.getNativeQueryProcedureName());
+ p.setAnnotation("Invokes translator with provided native query that returns result in array of values"); //$NON-NLS-1$
+
+ ProcedureParameter param = factory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param.setAnnotation("The native query to execute"); //$NON-NLS-1$
+ param.setNullType(NullType.No_Nulls);
+
+ param = factory.addProcedureParameter("variable", TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p); //$NON-NLS-1$
+ param.setAnnotation("Any number of varaibles, depends upon how a translator uses them individually"); //$NON-NLS-1$
+ param.setNullType(NullType.Nullable);
+ param.setVarArg(true);
+
+ factory.addProcedureResultSetColumn("tuple", TypeFacility.RUNTIME_NAMES.OBJECT, p); //$NON-NLS-1$
+ }
+ super.loadMetadata(factory, executionFactory, connectionFactory);
+ }
+}
Property changes on: trunk/engine/src/main/java/org/teiid/query/metadata/DirectQueryMetadataRepository.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -114,6 +114,14 @@
Table lobTable = createPhysicalGroup("LobTbl", lob); //$NON-NLS-1$
Table library = createPhysicalGroup("LOB_TESTING_ONE", lob); //$NON-NLS-1$
+ // add direct query procedure
+ ColumnSet<Procedure> nativeProcResults = createResultSet("bqt1.nativers", new String[] {"tuple"}, new String[] { DataTypeManager.DefaultDataTypes.OBJECT}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProcedureParameter nativeparam = createParameter("param", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$
+ ProcedureParameter vardic = createParameter("varag", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.OBJECT); //$NON-NLS-1$
+ vardic.setVarArg(true);
+ Procedure nativeProc = createStoredProcedure("native", bqt1, Arrays.asList(nativeparam,vardic)); //$NON-NLS-1$ //$NON-NLS-2$
+ nativeProc.setResultSet(nativeProcResults);
+
createElements( library, new String[] { "CLOB_COLUMN", "BLOB_COLUMN", "KEY_EMULATOR" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new String[] { DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.BLOB, DataTypeManager.DefaultDataTypes.INTEGER });
@@ -1014,6 +1022,13 @@
//end case 3281
+ ColumnSet<Procedure> nativeProcResults = createResultSet("pm1.nativers", new String[] {"tuple"}, new String[] { DataTypeManager.DefaultDataTypes.OBJECT}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProcedureParameter nativeparam = createParameter("param", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$
+ ProcedureParameter vardic = createParameter("varag", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.OBJECT); //$NON-NLS-1$
+ vardic.setVarArg(true);
+ Procedure nativeProc = createStoredProcedure("native", pm1, Arrays.asList(nativeparam,vardic)); //$NON-NLS-1$ //$NON-NLS-2$
+ nativeProc.setResultSet(nativeProcResults);
+
ColumnSet<Procedure> rs3 = createResultSet("pm1.rs3", new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Procedure sp1 = createStoredProcedure("sp1", pm1, null); //$NON-NLS-1$ //$NON-NLS-2$
sp1.setResultSet(rs3);
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/pom.xml 2012-09-25 22:15:11 UTC (rev 4472)
@@ -252,7 +252,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
- <version>1.5</version>
+ <version>1.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Modified: trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -45,6 +45,7 @@
import org.teiid.metadata.MetadataStore;
import org.teiid.query.metadata.DDLMetadataRepository;
import org.teiid.query.metadata.NativeMetadataRepository;
+import org.teiid.query.metadata.DirectQueryMetadataRepository;
import org.teiid.translator.TranslatorException;
public abstract class AbstractVDBDeployer {
@@ -76,11 +77,14 @@
private MetadataRepository<?, ?> getMetadataRepository(VDBMetaData vdb, ModelMetaData model, MetadataRepository<?, ?> defaultRepo) throws VirtualDatabaseException {
if (model.getSchemaSourceType() == null) {
if (!vdb.isDynamic()) {
+ defaultRepo.setNext(new DirectQueryMetadataRepository());
return defaultRepo;
}
if (model.isSource()) {
- return new NativeMetadataRepository();
+ NativeMetadataRepository repo = new NativeMetadataRepository();
+ repo.setNext(new DirectQueryMetadataRepository());
+ return repo;
}
throw new VirtualDatabaseException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40094, model.getName(), vdb.getName(), vdb.getVersion(), null));
}
@@ -88,7 +92,8 @@
MetadataRepository<?, ?> first = null;
MetadataRepository<?, ?> current = null;
MetadataRepository<?, ?> previous = null;
- StringTokenizer st = new StringTokenizer(model.getSchemaSourceType(), ","); //$NON-NLS-1$
+ String schemaTypes = model.getSchemaSourceType();
+ StringTokenizer st = new StringTokenizer(schemaTypes, ","); //$NON-NLS-1$
while (st.hasMoreTokens()) {
String repoType = st.nextToken().trim();
current = getMetadataRepository(repoType);
@@ -106,6 +111,12 @@
previous = current;
current = null;
}
+
+ // TODO:there is good chance that the instances of metadata factory sharing is not good between models,
+ // may that be for chaining purposes, we should do metadata repository factory model here.
+ if (model.getModelType() == ModelMetaData.Type.PHYSICAL) {
+ previous.setNext(new DirectQueryMetadataRepository());
+ }
return first;
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java 2012-09-25 18:58:05 UTC (rev 4471)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java 2012-09-25 22:15:11 UTC (rev 4472)
@@ -21,7 +21,8 @@
*/
package org.teiid.dqp.internal.process;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -35,9 +36,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
-import org.mockito.internal.progress.OngoingStubbing;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import org.mockito.stubbing.DeprecatedOngoingStubbing;
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
@@ -100,9 +101,9 @@
@Before public void setup() throws DataNotAvailableException, TranslatorException {
execution = Mockito.mock(FakeReusableExecution.class);
ec = null;
- OngoingStubbing stubbing = Mockito.stub(execution.next()).toReturn((List) Arrays.asList((Object)null)).toReturn(null);
+ DeprecatedOngoingStubbing stubbing = Mockito.stub(execution.next()).toReturn((List) Arrays.asList((Object)null)).toReturn(null);
for (int i = 1; i < EXEC_COUNT; i++) {
- stubbing.toReturn((List<Object>) Arrays.asList((Object)null)).toReturn(null);
+ stubbing.toReturn(Arrays.asList((Object)null)).toReturn(null);
}
Mockito.doAnswer(new Answer<Void>() {
@Override
12 years, 3 months